Skip to content

Commit 8b6d134

Browse files
author
Shoshana Berleant
committed
add axis param
1 parent d5760b0 commit 8b6d134

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

nipype/algorithms/confounds.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def _run_interface(self, runtime):
408408
# defined as the standard deviation of the time series after the removal
409409
# of low-frequency nuisance terms (e.g., linear and quadratic drift)."
410410
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
412412

413413
time_voxels = imgseries.T
414414
num_voxels = np.prod(time_voxels.shape[1:])
@@ -509,15 +509,15 @@ def _list_outputs(self):
509509
outputs['detrended_file'] = op.abspath(self.inputs.detrended_file)
510510
return outputs
511511

512-
def regress_poly(degree, data, remove_mean=False):
512+
def regress_poly(degree, data, remove_mean=False, axis=-1):
513513
''' 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)
515515
'''
516516
datashape = data.shape
517-
timepoints = datashape[-1]
517+
timepoints = datashape[axis]
518518

519519
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')
521521

522522
# Rearrange all voxel-wise time-series in rows
523523
data = data.reshape((-1, timepoints))

0 commit comments

Comments
 (0)