@@ -408,7 +408,7 @@ def _run_interface(self, runtime):
408
408
# defined as the standard deviation of the time series after the removal
409
409
# of low-frequency nuisance terms (e.g., linear and quadratic drift)."
410
410
imgseries = regress_poly (2 , imgseries )
411
- imgseries = imgseries - np . mean ( imgseries , axis = 1 )[:, np . newaxis ]
411
+ imgseries = regress_poly ( 0 , imgseries , remove_mean = True , axis = 1 ) #this is super weird
412
412
413
413
time_voxels = imgseries .T
414
414
num_voxels = np .prod (time_voxels .shape [1 :])
@@ -509,15 +509,15 @@ def _list_outputs(self):
509
509
outputs ['detrended_file' ] = op .abspath (self .inputs .detrended_file )
510
510
return outputs
511
511
512
- def regress_poly (degree , data , remove_mean = False ):
512
+ def regress_poly (degree , data , remove_mean = False , axis = - 1 ):
513
513
''' returns data with degree polynomial regressed out.
514
- The last dimension (i.e. data.shape[-1]) should be time.
514
+ Be default it is calculated along the last axis (usu. time)
515
515
'''
516
516
datashape = data .shape
517
- timepoints = datashape [- 1 ]
517
+ timepoints = datashape [axis ]
518
518
519
519
if remove_mean : # i.e. regress_poly degree 0, which the following does not do
520
- data = signal .detrend (data , axis = - 1 , type = 'constant' )
520
+ data = signal .detrend (data , axis = axis , type = 'constant' )
521
521
522
522
# Rearrange all voxel-wise time-series in rows
523
523
data = data .reshape ((- 1 , timepoints ))
0 commit comments