Skip to content

Commit 1995a01

Browse files
author
Shoshana Berleant
committed
use regress_poly from TSNR in compcor
1 parent dfdd6b0 commit 1995a01

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

nipype/algorithms/compcor.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,21 @@ def _run_interface(self, runtime):
5353
voxel_timecourses[np.isnan(np.sum(voxel_timecourses, axis=1)), :] = 0
5454

5555
# from paper:
56+
# "The constant and linear trends of the columns in the matrix M were
57+
# removed [prior to ...]"
58+
if self.inputs.use_regress_poly:
59+
regressed = regress_poly(self.inputs.regress_poly_degree,
60+
voxel_timecourses)
61+
regressed = regressed - np.mean(regressed, axis=1)[:,None]
62+
5663
# "Voxel time series from the noise ROI (either anatomical or tSTD) were
5764
# placed in a matrix M of size Nxm, with time along the row dimension
5865
# and voxels along the column dimension."
59-
# voxel_timecourses.shape == [nvoxels, time]
60-
61-
M = voxel_timecourses.T
66+
M = regressed.T
6267
numvols = M.shape[0]
6368
numvoxels = M.shape[1]
6469

65-
if self.inputs.use_regress_poly:
66-
# "The constant and linear trends of the columns in the matrix M were removed ..."
67-
regress_poly(self.inputs.regress_poly_degree, voxel_timecourses)
68-
69-
timesteps = range(numvols)
70-
for voxel in range(numvoxels):
71-
m, b, _, _, _ = stats.linregress(timesteps, M[:, voxel])
72-
M[:, voxel] = M[:, voxel] - [m*t + b for t in timesteps]
73-
74-
# "... prior to column-wise variance normalization."
70+
# "[... were removed] prior to column-wise variance normalization."
7571
M = M / self._compute_tSTD(M, 1.)
7672

7773
# "The covariance matrix C = MMT was constructed and decomposed into its

0 commit comments

Comments
 (0)