@@ -325,7 +325,7 @@ class CompCorInputSpec(BaseInterfaceInputSpec):
325
325
components_file = traits .Str ('components_file.txt' , usedefault = True ,
326
326
desc = 'Filename to store physiological components' )
327
327
num_components = traits .Int (6 , usedefault = True ) # 6 for BOLD, 4 for ASL
328
- use_regress_poly = traits .Bool (True , usedefault = True ,
328
+ use_regress_poly = traits .Bool (True , usedefault = True , xor = [ 'high_pass_filter' ],
329
329
desc = ('use polynomial regression '
330
330
'pre-component extraction' ))
331
331
regress_poly_degree = traits .Range (low = 1 , default = 1 , usedefault = True ,
@@ -334,7 +334,7 @@ class CompCorInputSpec(BaseInterfaceInputSpec):
334
334
'file (one column). If undefined, will '
335
335
'default to "CompCor"' ))
336
336
high_pass_filter = traits .Bool (
337
- False , usedefault = True ,
337
+ False , xor = [ 'use_regress_poly' ] ,
338
338
desc = 'Use cosine basis to remove low-frequency trends pre-component '
339
339
'extraction' )
340
340
high_pass_cutoff = traits .Float (
@@ -437,7 +437,8 @@ def _run_interface(self, runtime):
437
437
438
438
components , hpf_basis = compute_noise_components (
439
439
imgseries .get_data (), mask_images , degree ,
440
- self .inputs .num_components , self .inputs .high_pass_filter , TR )
440
+ self .inputs .num_components , self .inputs .high_pass_filter ,
441
+ self .inputs .high_pass_cutoff , TR )
441
442
442
443
components_file = os .path .join (os .getcwd (), self .inputs .components_file )
443
444
np .savetxt (components_file , components , fmt = b"%.10f" , delimiter = '\t ' ,
@@ -838,7 +839,7 @@ def is_outlier(points, thresh=3.5):
838
839
return timepoints_to_discard
839
840
840
841
841
- def cosine_filter (data , timestep , period_cut , remove_mean = False , axis = - 1 ):
842
+ def cosine_filter (data , timestep , period_cut , remove_mean = True , axis = - 1 ):
842
843
datashape = data .shape
843
844
timepoints = datashape [axis ]
844
845
@@ -952,7 +953,8 @@ def combine_mask_files(mask_files, mask_method=None, mask_index=None):
952
953
953
954
954
955
def compute_noise_components (imgseries , mask_images , degree , num_components ,
955
- high_pass_filter = False , repetition_time = 0 ):
956
+ high_pass_filter = False , period_cut = 128 ,
957
+ repetition_time = 0 ):
956
958
"""Compute the noise components from the imgseries for each mask
957
959
958
960
imgseries: a nibabel img
@@ -966,6 +968,7 @@ def compute_noise_components(imgseries, mask_images, degree, num_components,
966
968
returns:
967
969
968
970
components: a numpy array
971
+ hpf_basis: a numpy array, if high_pass_filter is True, else None
969
972
970
973
"""
971
974
components = None
@@ -983,16 +986,14 @@ def compute_noise_components(imgseries, mask_images, degree, num_components,
983
986
# Zero-out any bad values
984
987
voxel_timecourses [np .isnan (np .sum (voxel_timecourses , axis = 1 )), :] = 0
985
988
989
+ # Use either cosine or Legendre-polynomial detrending
986
990
if high_pass_filter :
987
- # If degree == 0, remove mean in same pass
988
991
voxel_timecourses , hpf_basis = cosine_filter (
989
- voxel_timecourses , repetition_time ,
990
- self .inputs .high_pass_cutoff , remove_mean = (degree == 0 ))
991
-
992
- # from paper:
993
- # "The constant and linear trends of the columns in the matrix M were
994
- # removed [prior to ...]"
995
- if degree > 0 or not high_pass_filter :
992
+ voxel_timecourses , repetition_time , period_cut )
993
+ else :
994
+ # from paper:
995
+ # "The constant and linear trends of the columns in the matrix M were
996
+ # removed [prior to ...]"
996
997
voxel_timecourses = regress_poly (degree , voxel_timecourses )
997
998
998
999
# "Voxel time series from the noise ROI (either anatomical or tSTD) were
0 commit comments