@@ -1224,12 +1224,26 @@ def compute_noise_components(imgseries, mask_images, components_criterion=0.5,
1224
1224
'polynomial' - Legendre polynomial basis
1225
1225
'cosine' - Discrete cosine (DCT) basis
1226
1226
False - None (mean-removal only)
1227
+ failure_mode: str
1228
+ Action to be taken in the event that any decomposition fails to
1229
+ identify any components. `error` indicates that the routine should
1230
+ raise an exception and exit, while any other value indicates that the
1231
+ routine should return a matrix of NaN values equal in size to the
1232
+ requested decomposition matrix.
1233
+ mask_names: list or None
1234
+ List of names for each image in `mask_images`. This should be equal in
1235
+ length to `mask_images`, with the ith element of `mask_names` naming
1236
+ the ith element of `mask_images`.
1227
1237
1228
1238
Filter options:
1229
1239
1230
- degree: order of polynomial used to remove trends from the timeseries
1231
- period_cut: minimum period (in sec) for DCT high-pass filter
1232
- repetition_time: time (in sec) between volume acquisitions
1240
+ degree: int
1241
+ Order of polynomial used to remove trends from the timeseries
1242
+ period_cut: float
1243
+ Minimum period (in sec) for DCT high-pass filter
1244
+ repetition_time: float
1245
+ Time (in sec) between volume acquisitions. This must be defined if
1246
+ the `filter_type` is `cosine`.
1233
1247
1234
1248
Returns
1235
1249
-------
@@ -1262,6 +1276,9 @@ def compute_noise_components(imgseries, mask_images, components_criterion=0.5,
1262
1276
# Currently support Legendre-polynomial or cosine or detrending
1263
1277
# With no filter, the mean is nonetheless removed (poly w/ degree 0)
1264
1278
if filter_type == 'cosine' :
1279
+ if repetition_time is None :
1280
+ raise ValueError (
1281
+ 'Repetition time must be provided for cosine filter' )
1265
1282
voxel_timecourses , basis = cosine_filter (
1266
1283
voxel_timecourses , repetition_time , period_cut )
1267
1284
elif filter_type in ('polynomial' , False ):
@@ -1286,8 +1303,8 @@ def compute_noise_components(imgseries, mask_images, components_criterion=0.5,
1286
1303
if failure_mode == 'error' :
1287
1304
raise
1288
1305
if components_criterion >= 1 :
1289
- u = np .empty ((M .shape [0 ], components_criterion ),
1290
- dtype = np .float32 ) * np . nan
1306
+ u = np .full ((M .shape [0 ], components_criterion ),
1307
+ np . nan , dtype = np .float32 )
1291
1308
else :
1292
1309
continue
1293
1310
@@ -1329,7 +1346,7 @@ def compute_noise_components(imgseries, mask_images, components_criterion=0.5,
1329
1346
if components is None :
1330
1347
if failure_mode == 'error' :
1331
1348
raise ValueError ('No components found' )
1332
- components = np .full ((M .shape [0 ], num_components ), np .NaN )
1349
+ components = np .full ((M .shape [0 ], num_components ), np .nan )
1333
1350
return components , basis , metadata
1334
1351
1335
1352
0 commit comments