@@ -73,9 +73,7 @@ def _make_func_outputs(w: Path, regressors: list[str]) -> FunctionalOutputs:
7373 template_bold = _dummy (w , "template_bold.nii.gz" ),
7474 regressed_bold = {r : _dummy (w , f"regressed_{ r } .nii.gz" ) for r in regressors },
7575 cleaned_bold = {r : _dummy (w , f"cleaned_{ r } .nii.gz" ) for r in regressors },
76- cleaned_bold_smooth = {
77- r : _dummy (w , f"cleaned_{ r } _smooth.nii.gz" ) for r in regressors
78- },
76+ cleaned_bold_smooth = None ,
7977 regressor_file = {r : _dummy (w , f"regressors_{ r } .1D" ) for r in regressors },
8078 template_brain_mask = _dummy (w , "template_mask.nii.gz" ),
8179 )
@@ -222,6 +220,31 @@ def test_file_count_two_regressors(
222220 saved = list (pipe_ctx .output_dir .rglob ("*.*" ))
223221 assert len (saved ) == 16
224222
223+ def test_bold_smooth_not_exported_if_none (
224+ self , func_bids : Bids , workdir : Path , pipe_ctx : RunContext
225+ ) -> None :
226+ """No smoothed BOLD files are exported when cleaned_bold_smooth is None."""
227+ outputs = _make_func_outputs (workdir , ["36-parameter" ])
228+ export_functional (func_bids , outputs , regressors = ["36-parameter" ])
229+ saved = [p .name for p in pipe_ctx .output_dir .rglob ("*.nii.gz" )]
230+ assert not any ("desc-sm" in name for name in saved )
231+
232+ def test_cleaned_bold_smooth_exported_with_correct_desc (
233+ self , func_bids : Bids , workdir : Path , pipe_ctx : RunContext
234+ ) -> None :
235+ """Smoothed BOLD is exported with correct fwhm label."""
236+ smooth_outputs = _make_func_outputs (workdir , ["36-parameter" ])._replace (
237+ cleaned_bold_smooth = {
238+ "36-parameter" : _dummy (workdir , "cleaned_smooth.nii.gz" )
239+ }
240+ )
241+ export_functional (
242+ func_bids , smooth_outputs , regressors = ["36-parameter" ], smooth = 8.0
243+ )
244+ saved = [p .name for p in pipe_ctx .output_dir .rglob ("*.nii.gz" )]
245+ sm_files = [n for n in saved if "desc-sm8preproc" in n ]
246+ assert len (sm_files ) == 1
247+
225248
226249# ---------------------------------------------------------------------------
227250# Metrics exports
@@ -238,7 +261,11 @@ def test_sanitizes_atlas_labels(
238261 mni = func_bids .derive (space = "MNI152NLin6Asym" )
239262 outputs = _make_metrics_outputs (workdir , ["schaefer_200" ])
240263 export_metrics (
241- mni , outputs , regressor = "36-parameter" , atlases = ["schaefer_200" ], smooth = 6.0
264+ mni ,
265+ outputs ,
266+ regressor = "36-parameter" ,
267+ atlases = ["schaefer_200" ],
268+ smooth = None ,
242269 )
243270 atlas_files = [
244271 p .name for p in pipe_ctx .output_dir .rglob ("*.*" ) if "atlas-" in p .name
@@ -255,7 +282,7 @@ def test_sanitizes_regressor_labels(
255282 mni = func_bids .derive (space = "MNI152NLin6Asym" )
256283 outputs = _make_metrics_outputs (workdir , ["aal" ])
257284 export_metrics (
258- mni , outputs , regressor = "36-parameter" , atlases = ["aal" ], smooth = 6.0
285+ mni , outputs , regressor = "36-parameter" , atlases = ["aal" ], smooth = None
259286 )
260287 all_names = [p .name for p in pipe_ctx .output_dir .rglob ("*.*" )]
261288 reg_files = [n for n in all_names if "reg-" in n ]
@@ -270,7 +297,7 @@ def test_file_count_single_atlas(
270297 mni = func_bids .derive (space = "MNI152NLin6Asym" )
271298 outputs = _make_metrics_outputs (workdir , ["schaefer_200" ])
272299 export_metrics (
273- mni , outputs , regressor = "aCompCor" , atlases = ["schaefer_200" ], smooth = 6.0
300+ mni , outputs , regressor = "aCompCor" , atlases = ["schaefer_200" ], smooth = None
274301 )
275302 saved = list (pipe_ctx .output_dir .rglob ("*.*" ))
276303 assert len (saved ) == 8
@@ -282,10 +309,59 @@ def test_file_count_multiple_atlases(
282309 atlases = ["schaefer_200" , "aal" ]
283310 mni = func_bids .derive (space = "MNI152NLin6Asym" )
284311 outputs = _make_metrics_outputs (workdir , atlases )
285- export_metrics (mni , outputs , regressor = "aCompCor" , atlases = atlases , smooth = 6.0 )
312+ export_metrics (mni , outputs , regressor = "aCompCor" , atlases = atlases , smooth = None )
286313 saved = list (pipe_ctx .output_dir .rglob ("*.*" ))
287314 assert len (saved ) == 10
288315
316+ def test_file_count_single_atlas_with_smooth (
317+ self , func_bids : Bids , workdir : Path , pipe_ctx : RunContext
318+ ) -> None :
319+ """3 raw + 3 zscored + 3 smooth + 3 smooth zscored + 2 atlas files = 14."""
320+ mni = func_bids .derive (space = "MNI152NLin6Asym" )
321+ smooth_outputs = _make_metrics_outputs (workdir , ["schaefer_200" ])._replace (
322+ alff_smooth = _dummy (workdir , "alff_sm.nii.gz" ),
323+ falff_smooth = _dummy (workdir , "falff_sm.nii.gz" ),
324+ reho_smooth = _dummy (workdir , "reho_sm.nii.gz" ),
325+ alff_smooth_zscored = _dummy (workdir , "alff_sm_z.nii.gz" ),
326+ falff_smooth_zscored = _dummy (workdir , "falff_sm_z.nii.gz" ),
327+ reho_smooth_zscored = _dummy (workdir , "reho_sm_z.nii.gz" ),
328+ )
329+ export_metrics (
330+ mni ,
331+ smooth_outputs ,
332+ regressor = "aCompCor" ,
333+ atlases = ["schaefer_200" ],
334+ smooth = 6.0 ,
335+ )
336+ saved = list (pipe_ctx .output_dir .rglob ("*.*" ))
337+ assert len (saved ) == 14
338+
339+ def test_smooth_maps_have_correct_desc (
340+ self , func_bids : Bids , workdir : Path , pipe_ctx : RunContext
341+ ) -> None :
342+ """Smoothed maps are exported with correct fwhm labels."""
343+ mni = func_bids .derive (space = "MNI152NLin6Asym" )
344+ smooth_outputs = _make_metrics_outputs (workdir , ["schaefer_200" ])._replace (
345+ alff_smooth = _dummy (workdir , "alff_sm.nii.gz" ),
346+ falff_smooth = _dummy (workdir , "falff_sm.nii.gz" ),
347+ reho_smooth = _dummy (workdir , "reho_sm.nii.gz" ),
348+ alff_smooth_zscored = _dummy (workdir , "alff_sm_z.nii.gz" ),
349+ falff_smooth_zscored = _dummy (workdir , "falff_sm_z.nii.gz" ),
350+ reho_smooth_zscored = _dummy (workdir , "reho_sm_z.nii.gz" ),
351+ )
352+ export_metrics (
353+ mni ,
354+ smooth_outputs ,
355+ regressor = "aCompCor" ,
356+ atlases = ["schaefer_200" ],
357+ smooth = 8.0 ,
358+ )
359+ saved = [p .name for p in pipe_ctx .output_dir .rglob ("*.nii.gz" )]
360+ sm_only = [n for n in saved if "desc-sm8" in n and "Zstd" not in n ]
361+ sm_zstd = [n for n in saved if "desc-sm8Zstd" in n ]
362+ assert len (sm_only ) == 3
363+ assert len (sm_zstd ) == 3
364+
289365
290366# ---------------------------------------------------------------------------
291367# QC exports
0 commit comments