@@ -1082,10 +1082,11 @@ def is_outlier(points, thresh=3.5):
1082
1082
return timepoints_to_discard
1083
1083
1084
1084
1085
- def cosine_filter (data , timestep , period_cut , remove_mean = True , axis = - 1 ):
1085
+ def cosine_filter (data , timestep , period_cut , remove_mean = True , axis = - 1 ,
1086
+ failure_mode = 'error' ):
1086
1087
datashape = data .shape
1087
1088
timepoints = datashape [axis ]
1088
- if datashape [0 ] == 0 :
1089
+ if datashape [0 ] == 0 and failure_mode != 'error' :
1089
1090
return data , np .array ([])
1090
1091
1091
1092
data = data .reshape ((- 1 , timepoints ))
@@ -1105,7 +1106,8 @@ def cosine_filter(data, timestep, period_cut, remove_mean=True, axis=-1):
1105
1106
return residuals .reshape (datashape ), non_constant_regressors
1106
1107
1107
1108
1108
- def regress_poly (degree , data , remove_mean = True , axis = - 1 ):
1109
+ def regress_poly (degree , data , remove_mean = True , axis = - 1 ,
1110
+ failure_mode = 'error' ):
1109
1111
"""
1110
1112
Returns data with degree polynomial regressed out.
1111
1113
@@ -1118,7 +1120,7 @@ def regress_poly(degree, data, remove_mean=True, axis=-1):
1118
1120
1119
1121
datashape = data .shape
1120
1122
timepoints = datashape [axis ]
1121
- if datashape [0 ] == 0 :
1123
+ if datashape [0 ] == 0 and failure_mode != 'error' :
1122
1124
return data , np .array ([])
1123
1125
1124
1126
# Rearrange all voxel-wise time-series in rows
@@ -1285,12 +1287,14 @@ def compute_noise_components(imgseries, mask_images, components_criterion=0.5,
1285
1287
raise ValueError (
1286
1288
'Repetition time must be provided for cosine filter' )
1287
1289
voxel_timecourses , basis = cosine_filter (
1288
- voxel_timecourses , repetition_time , period_cut )
1290
+ voxel_timecourses , repetition_time , period_cut ,
1291
+ failure_mode = failure_mode )
1289
1292
elif filter_type in ('polynomial' , False ):
1290
1293
# from paper:
1291
1294
# "The constant and linear trends of the columns in the matrix M were
1292
1295
# removed [prior to ...]"
1293
- voxel_timecourses , basis = regress_poly (degree , voxel_timecourses )
1296
+ voxel_timecourses , basis = regress_poly (degree , voxel_timecourses ,
1297
+ failure_mode = failure_mode )
1294
1298
1295
1299
# "Voxel time series from the noise ROI (either anatomical or tSTD) were
1296
1300
# placed in a matrix M of size Nxm, with time along the row dimension
0 commit comments