@@ -1224,12 +1224,26 @@ def compute_noise_components(imgseries, mask_images, components_criterion=0.5,
12241224 'polynomial' - Legendre polynomial basis
12251225 'cosine' - Discrete cosine (DCT) basis
12261226 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`.
12271237
12281238 Filter options:
12291239
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`.
12331247
12341248 Returns
12351249 -------
@@ -1262,6 +1276,9 @@ def compute_noise_components(imgseries, mask_images, components_criterion=0.5,
12621276 # Currently support Legendre-polynomial or cosine or detrending
12631277 # With no filter, the mean is nonetheless removed (poly w/ degree 0)
12641278 if filter_type == 'cosine' :
1279+ if repetition_time is None :
1280+ raise ValueError (
1281+ 'Repetition time must be provided for cosine filter' )
12651282 voxel_timecourses , basis = cosine_filter (
12661283 voxel_timecourses , repetition_time , period_cut )
12671284 elif filter_type in ('polynomial' , False ):
@@ -1286,8 +1303,8 @@ def compute_noise_components(imgseries, mask_images, components_criterion=0.5,
12861303 if failure_mode == 'error' :
12871304 raise
12881305 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 )
12911308 else :
12921309 continue
12931310
@@ -1329,7 +1346,7 @@ def compute_noise_components(imgseries, mask_images, components_criterion=0.5,
13291346 if components is None :
13301347 if failure_mode == 'error' :
13311348 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 )
13331350 return components , basis , metadata
13341351
13351352
0 commit comments