Skip to content

Commit da1e59a

Browse files
author
Shoshana Berleant
committed
add use_regress_poly Boolean to compcor
1 parent 62bb3bd commit da1e59a

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

nipype/algorithms/compcor.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ class CompCorInputSpec(BaseInterfaceInputSpec):
1414
desc='already realigned brain image (4D)')
1515
mask_file = File(exists=True, mandatory=False,
1616
desc='mask file that determines ROI (3D)')
17-
components_file = File('components_file.txt', exists=False, mandatory=False,
18-
usedefault=True,
19-
desc='filename to store physiological components in')
17+
components_file = File('components_file.txt', exists=False,
18+
mandatory=False, usedefault=True,
19+
desc='filename to store physiological components')
2020
num_components = traits.Int(6, usedefault=True) # 6 for BOLD, 4 for ASL
21-
regress_poly = traits.Range(low=1, default=1, usedefault=True)
21+
use_regress_poly = traits.Bool(True, usedefault=True,
22+
desc='use polynomial regression'
23+
'pre-component extraction')
24+
regress_poly_degree = traits.Range(low=1, default=1, usedefault=True,
25+
desc='the degree polynomial to use')
2226

2327
class CompCorOutputSpec(TraitedSpec):
2428
components_file = File(exists=True,
@@ -35,6 +39,8 @@ class CompCor(BaseInterface):
3539
>>> ccinterface.inputs.realigned_file = 'nipype/testing/data/functional.nii'
3640
>>> ccinterface.inputs.mask_file = 'nipype/testing/data/mask.nii'
3741
>>> ccinterface.inputs.num_components = 1
42+
>>> ccinterface.inputs.use_regress_poly = True
43+
>>> ccinterface.inputs.regress_poly_degree = 2
3844
'''
3945
input_spec = CompCorInputSpec
4046
output_spec = CompCorOutputSpec
@@ -51,16 +57,21 @@ def _run_interface(self, runtime):
5157
# placed in a matrix M of size Nxm, with time along the row dimension
5258
# and voxels along the column dimension."
5359
# voxel_timecourses.shape == [nvoxels, time]
60+
5461
M = voxel_timecourses.T
5562
numvols = M.shape[0]
5663
numvoxels = M.shape[1]
5764

58-
# "The constant and linear trends of the columns in the matrix M were removed ..."
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+
'''
5970
timesteps = range(numvols)
6071
for voxel in range(numvoxels):
6172
m, b, _, _, _ = stats.linregress(M[:, voxel], timesteps)
6273
M[:, voxel] = M[:, voxel] - [m*t + b for t in timesteps]
63-
74+
'''
6475
# "... prior to column-wise variance normalization."
6576
M = M / self._compute_tSTD(M, 1.)
6677

0 commit comments

Comments
 (0)