All 8 fslmaths calls and 1 3dcalc call in the codebase are simple voxelwise or morphological operations that can be done with nibabel + numpy/scipy, removing container calls entirely.
functional/masking.py (6 calls)
In bold_masking(), the entire mask refinement chain is fslmaths:
- thr + bin — threshold warped probseg at 0.85, binarize
- kernel_sphere + dil_f — dilate binary mask by 3mm sphere
- kernel_sphere + dil_f — dilate BET mask by 6mm sphere
- mas — apply dilated BET mask to bias-corrected BOLD ref
- mul — intersect BET mask with AFNI automask
- mas — apply final mask to unifized image
All of these are one-liners with numpy (>, *, astype) or scipy (binary_dilation with ball). We already use binary_erosion in distortion.py for the same kind of thing.
anatomical/segmentation.py (2 calls)
- thr + bin in
fsl_tissue_masks() — threshold FAST PVE at 0.95, binarize
- thr + uthr + bin in
fsl_wm_bbr_mask() — band-threshold FAST pveseg [2.5, 3.5], binarize
Same story, pure numpy.
functional/initialization.py (1 call)
- 3dcalc in
truncate_trs() — selects a[start_tr..$] with expression a. Just img.slicer[..., start_tr:] in nibabel.
Why bother
All 8
fslmathscalls and 13dcalccall in the codebase are simple voxelwise or morphological operations that can be done with nibabel + numpy/scipy, removing container calls entirely.functional/masking.py(6 calls)In
bold_masking(), the entire mask refinement chain is fslmaths:All of these are one-liners with numpy (
>,*,astype) or scipy (binary_dilationwithball). We already usebinary_erosionindistortion.pyfor the same kind of thing.anatomical/segmentation.py(2 calls)fsl_tissue_masks()— threshold FAST PVE at 0.95, binarizefsl_wm_bbr_mask()— band-threshold FAST pveseg [2.5, 3.5], binarizeSame story, pure numpy.
functional/initialization.py(1 call)truncate_trs()— selectsa[start_tr..$]with expressiona. Justimg.slicer[..., start_tr:]in nibabel.Why bother
.niiwithout fightingFSLOUTPUTTYPE(see Consider disabling gzip compression for certain nifti intermediates #252 / Disable gzip compression for float NIfTI intermediates #285)