@@ -69,20 +69,19 @@ class FunctionalOutputs(NamedTuple):
6969 distortion_warp: ANTs/ITK-compatible distortion warp field, or
7070 *None* if no fieldmap data was provided.
7171 stc_bold: Slice-timing corrected BOLD.
72- preproc_bold: Motion-corrected + STC BOLD in native space
73- (exported as desc-preproc_bold, not consumed downstream).
72+ preproc_bold: Motion-corrected + STC BOLD in native space.
7473 motion_params: Six-column motion parameter file.
7574 rms_rel: Frame-to-frame relative RMS displacement.
7675 rms_abs: Volume-to-reference absolute RMS displacement.
7776 mat_dir: Directory of per-volume motion matrices.
7877 bold_mask: Final binary BOLD brain mask.
7978 skull_stripped_bold: Skull-stripped BOLD reference.
80- bold_to_anat_matrix: BOLD-to-T1w affine matrix (BBR) .
81- bold_to_anat_itk: BOLD-to-T1w affine in ITK format (for ANTs warping) .
79+ bold_to_anat_matrix: BOLD-to-T1w affine matrix.
80+ bold_to_anat_itk: BOLD-to-T1w affine in ITK format.
8281 template_bold: BOLD resampled to template space.
83- regressed_bold: Nuisance-regressed ( non-bandpassed) BOLD.
82+ regressed_bold: Nuisance-regressed & non-bandpassed BOLD.
8483 cleaned_bold: Nuisance-regressed & bandpass-filtered BOLD.
85- regressor_file: Nuisance regressor ``.1D`` file.
84+ regressor_file: Bandpass-filtered nuisance regressor ``.1D`` file.
8685 template_brain_mask: Brain mask warped to template space.
8786 """
8887
@@ -154,24 +153,29 @@ def single_session_preprocess(
154153 Pipeline steps:
155154
156155 1. Deoblique & reorient BOLD to RPI.
157- 2. Truncate initial TRs.
156+ 2. Truncate initial TRs (default: first 2 TRs) .
158157 3. Despike BOLD.
159158 4. Extract motion reference from despiked BOLD.
160159 5. Susceptibility distortion correction (optional, requires fieldmaps).
161160 6. Motion correction on despiked BOLD (pre-STC, for .par estimates
162161 and per-volume .mat affines).
163162 7. Slice timing correction on despiked BOLD.
164- 8. Apply motion .mat to STC volumes -> desc-preproc_bold (native-space
165- MC + STC output, exported but not consumed by later steps).
166- 9. BOLD brain masking (on motion reference volume).
167- 10. BBR coregistration (skull-stripped BOLD ref -> T1w).
168- 11. Warp tissue masks T1w -> BOLD space (inverse of bold_to_anat).
163+ 8. Apply motion .mat affines to STC BOLD (native-space MC + STC,
164+ used for nuisance regressor computation).
165+ 9. BOLD brain masking on motion reference volume.
166+ 10. BBR coregistration of skull-stripped BOLD reference to T1w.
167+ 11. Warp tissue masks (brain, CSF, WM) to BOLD space using inverse
168+ of BOLD-to-T1w affine.
169169 12. Compute nuisance regressors from native-space BOLD.
170- 13. Single-step resampling: STC volumes -> template space (motion +
171- BBR + anat2template in one interpolation pass per volume).
170+ 13. Single-step resampling of STC BOLD to template space: motion +
171+ BBR + T1w-to-template composite warp applied in one interpolation pass
172+ per volume to minimize resampling artifacts.
172173 14. Warp brain mask to template space.
173- 15. Nuisance regression without bandpass (for ALFF/fALFF).
174- 16. Simultaneous regression + bandpass (Hallquist 2013).
174+ 15. Nuisance regression without bandpass on template-space BOLD
175+ (full frequency range preserved for ALFF/fALFF computation).
176+ 16. Nuisance regression with simultaneous bandpass filtering
177+ on template-space BOLD (Hallquist 2013).
178+ 17. Export bandpass-filtered regressors.
175179
176180 Args:
177181 in_bold: Raw BOLD timeseries to preprocess.
@@ -180,7 +184,7 @@ def single_session_preprocess(
180184 brain_mask: Binary brain mask from anatomical pipeline.
181185 csf_mask: CSF tissue mask from anatomical pipeline.
182186 wm_mask: WM tissue mask from anatomical pipeline.
183- anat_to_template: T1w -> template composite warp.
187+ anat_to_template: T1w-to- template composite warp.
184188 start_tr: Number of initial TRs to discard.
185189 regressor_set: Nuisance regressor strategy.
186190 fieldmap: Fieldmap inputs for susceptibility distortion correction.
@@ -237,10 +241,10 @@ def single_session_preprocess(
237241 effective_ref = distortion .corrected_ref if distortion else motion_ref
238242 distortion_warp = distortion .warp_field if distortion else None
239243
240- # 6. MC on despiked (pre-STC)
244+ # 6. MC on despiked BOLD (pre-STC)
241245 _logger .info ("Motion correction (MCFLIRT)" )
242- # .par -> motion params for nuisance regression + QC
243- # .mat -> per-volume affines used in steps 8 and 13
246+ # .par motion estimates used for nuisance regression + QC
247+ # .mat per-volume affines used in steps 8 and 13
244248 mc = fsl_motion_correction (in_file = despiked , ref_file = effective_ref )
245249
246250 # 7. Slice timing correction
@@ -251,8 +255,8 @@ def single_session_preprocess(
251255 tpattern = metadata .get ("SliceTiming" ),
252256 )
253257
254- # 8. Apply pre-STC motion transforms to STC BOLD ->
255- # desc-preproc_bold ( native-space MC + STC, exported only)
258+ # 8. Apply pre-STC motion transforms to STC BOLD
259+ # native-space MC + STC BOLD used in step 12
256260 _logger .info ("Applying motion transforms to STC BOLD" )
257261 preproc_bold = apply_motion_transforms (
258262 stc_img = st_corrected ,
@@ -276,7 +280,7 @@ def single_session_preprocess(
276280 wm_seg = wm_bbr_mask ,
277281 )
278282
279- # 11. Warp tissue masks T1w -> BOLD space (inverse of bold_to_anat )
283+ # 11. Warp tissue masks T1w-to- BOLD space (inverse of BOLD-to-T1w affine )
280284 bold2anat_fpath_str = str (generate_exec_folder ("bold2anat" ) / "bold2anat.txt" )
281285 bold_to_anat_itk = mat_to_itk (
282286 bbr .out_matrix_file , t1w_brain , masking .skull_stripped_bold , bold2anat_fpath_str
@@ -298,8 +302,8 @@ def single_session_preprocess(
298302 regressor_set = regressor ,
299303 )
300304
301- # 13. Single-step resampling (STC -> template)
302- # All spatial transforms (motion + BBR + anat2template ) applied in one
305+ # 13. Single-step resampling (STC BOLD to template)
306+ # All spatial transforms (motion + BBR + T1w-to-template ) applied in one
303307 # interpolation pass per volume to minimize resampling artifacts.
304308 _logger .info ("Resampling BOLD to template space (single-step)" )
305309 template_bold = resample_bold_to_template (
@@ -374,13 +378,14 @@ def single_session_preprocess(
374378
375379
376380class FunctionalLongOutputs (NamedTuple ):
377- """Outputs from the functional preprocessing pipeline.
381+ """Outputs from the longitudinal functional preprocessing pipeline.
378382
379383 Attributes:
380- sbref:
381- bold:
382- bold_mask:
383- forward_xfm:
384+ forward_xfm: BOLD-to-longitudinal-template composite warp.
385+ sbref: Motion reference volume warped to longitudinal template space.
386+ bold: Preprocessed BOLD warped to longitudinal template space.
387+ bold_mask: Brain mask warped to longitudinal template space,
388+ or *None* if no mask was provided.
384389 """
385390
386391 forward_xfm : Path
@@ -400,13 +405,14 @@ def longitudinal_process(
400405) -> FunctionalLongOutputs :
401406 """Transform preprocessed functional outputs to longitudinal template space.
402407
403- Assumes a template generated with transforms to anatomical, anatomical data already
404- preprocessed to longitudinal.
408+ Assumes a longitudinal template has been generated, the subject-to-template
409+ composite warp is available, and anatomical data has already been processed
410+ to longitudinal template space.
405411
406412 Args:
407413 template: Longitudinal template image.
408- anat_to_template_xfm: Transform from subject to template space .
409- bold_to_anat_itk: Transformation from bold to preprocessed anatomical space .
414+ anat_to_template_xfm: T1w-to-longitudinal- template composite warp .
415+ bold_to_anat_itk: BOLD-to-T1w affine in ITK format .
410416 sbref: Motion reference (single-band reference) volume.
411417 bold: Preprocessed bold image.
412418 bold_mask: Bold brain mask, if available.
0 commit comments