@@ -14,11 +14,15 @@ class CompCorInputSpec(BaseInterfaceInputSpec):
14
14
desc = 'already realigned brain image (4D)' )
15
15
mask_file = File (exists = True , mandatory = False ,
16
16
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' )
20
20
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' )
22
26
23
27
class CompCorOutputSpec (TraitedSpec ):
24
28
components_file = File (exists = True ,
@@ -35,6 +39,8 @@ class CompCor(BaseInterface):
35
39
>>> ccinterface.inputs.realigned_file = 'nipype/testing/data/functional.nii'
36
40
>>> ccinterface.inputs.mask_file = 'nipype/testing/data/mask.nii'
37
41
>>> ccinterface.inputs.num_components = 1
42
+ >>> ccinterface.inputs.use_regress_poly = True
43
+ >>> ccinterface.inputs.regress_poly_degree = 2
38
44
'''
39
45
input_spec = CompCorInputSpec
40
46
output_spec = CompCorOutputSpec
@@ -51,16 +57,21 @@ def _run_interface(self, runtime):
51
57
# placed in a matrix M of size Nxm, with time along the row dimension
52
58
# and voxels along the column dimension."
53
59
# voxel_timecourses.shape == [nvoxels, time]
60
+
54
61
M = voxel_timecourses .T
55
62
numvols = M .shape [0 ]
56
63
numvoxels = M .shape [1 ]
57
64
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
+ '''
59
70
timesteps = range(numvols)
60
71
for voxel in range(numvoxels):
61
72
m, b, _, _, _ = stats.linregress(M[:, voxel], timesteps)
62
73
M[:, voxel] = M[:, voxel] - [m*t + b for t in timesteps]
63
-
74
+ '''
64
75
# "... prior to column-wise variance normalization."
65
76
M = M / self ._compute_tSTD (M , 1. )
66
77
0 commit comments