mrsiprep.tissue.synthseg_fast
SynthSeg-constrained FSL FAST tissue backend.
Functions
|
Create a SynthSeg-masked T1w and binary mask without running FAST. |
|
Locate a FreeSurfer tool without hardcoding a version. |
|
Return SynthSeg's native-resolution anatomical labels for |
|
Segment GM/WM/CSF with SynthSeg-constrained FAST. |
|
Derivative path for the binary brain mask matching |
|
Derivative path for the SynthSeg-masked (skull-stripped) T1w image. |
|
Derivative path for the SynthSeg+FAST CSF probability-segmentation map. |
|
Derivative path for the SynthSeg-masked T1w image FSL FAST is run on. |
|
Derivative path for SynthSeg's native-resolution anatomical label map ( |
|
Scratch working directory (under |
- mrsiprep.tissue.synthseg_fast.extract_t1_synthseg(config, subject, session, t1_path)[source]
Create a SynthSeg-masked T1w and binary mask without running FAST.
Used by
--mode midas, which needs SynthSeg brain extraction as an input to its own fuzzy c-means tissue segmentation (mrsiprep.tissue.fuzzy_cmeans.fuzzy_cmeans_segment()) instead of FAST.- Parameters:
config -- Run-wide
mrsiprep.config.settings.MRSIPrepConfig.subject (str) -- BIDS subject label, without the
sub-prefix.session (str | None) -- BIDS session label without the
ses-prefix, orNonefor session-less datasets.t1_path (Path) -- Raw (non-skull-stripped) T1w image to segment.
- Returns:
(brain_path, mask_path)-- the skull-stripped T1w and its binary brain mask. Recordings already extracted are skipped (returned as-is) unlessconfig.overwrite_seg/config.overwriteis set.- Return type:
tuple[Path, Path]
- mrsiprep.tissue.synthseg_fast.find_freesurfer_tool(tool)[source]
Locate a FreeSurfer tool without hardcoding a version.
Resolution order: PATH, then
FREESURFER_HOME(direct and one level of version subdir), then any versioned install under the common roots (freesurfer-*/or*/subdirs), newest-looking first.- Parameters:
tool (str)
- Return type:
str
- mrsiprep.tissue.synthseg_fast.run_or_load_synthseg_labels(config, subject, session, t1_path)[source]
Return SynthSeg's native-resolution anatomical labels for
t1_path.Runs
mri_synthsegand caches its output atsynthseg_native_labels_path(), or loads that cached array directly if it already exists (andconfig.overwrite_seg/config.overwriteis not set). Used both bysegment_t1_synthseg_fast()and by callers that only need the raw label volume (e.g. brain-mask derivation) without running FAST.- Parameters:
config -- Run-wide
mrsiprep.config.settings.MRSIPrepConfig.subject (str) -- BIDS subject label, without the
sub-prefix.session (str | None) -- BIDS session label without the
ses-prefix, orNonefor session-less datasets.t1_path (Path) -- Raw (non-skull-stripped) T1w image to segment.
- Returns:
Integer SynthSeg label array, resampled onto
t1_path's grid ifmri_synthseg's own output grid differs.- Return type:
ndarray
- mrsiprep.tissue.synthseg_fast.segment_t1_synthseg_fast(config, subject, session, t1_path)[source]
Segment GM/WM/CSF with SynthSeg-constrained FAST.
SynthSeg supplies the brain/CSF mask and anatomical labels. FAST runs only inside that mask and supplies the partial-volume estimates, which are then corrected for known SynthSeg/FAST disagreement at CSF/ventricle boundaries (see
_apply_synthseg_csf_tissue_correction). This is the default (synthseg-fast)tissue_backend.- Parameters:
config -- Run-wide
mrsiprep.config.settings.MRSIPrepConfig.subject (str) -- BIDS subject label, without the
sub-prefix.session (str | None) -- BIDS session label without the
ses-prefix, orNonefor session-less datasets.t1_path (Path) -- Raw (non-skull-stripped) T1w image to segment.
- Returns:
{"GM": path, "WM": path, "CSF": path}of T1w-space tissue probability-segmentation maps. Recordings already segmented are skipped (returned as-is) unlessconfig.overwrite_seg/config.overwriteis set.- Return type:
dict[str, Path]
- mrsiprep.tissue.synthseg_fast.synthseg_fast_brain_mask_path(config, subject, session)[source]
Derivative path for the binary brain mask matching
synthseg_fast_brain_path().- Parameters:
subject (str)
session (str | None)
- Return type:
Path
- mrsiprep.tissue.synthseg_fast.synthseg_fast_brain_path(config, subject, session)[source]
Derivative path for the SynthSeg-masked (skull-stripped) T1w image.
- Parameters:
subject (str)
session (str | None)
- Return type:
Path
- mrsiprep.tissue.synthseg_fast.synthseg_fast_csf_probseg_path(config, subject, session)[source]
Derivative path for the SynthSeg+FAST CSF probability-segmentation map.
- Parameters:
subject (str)
session (str | None)
- Return type:
Path
- mrsiprep.tissue.synthseg_fast.synthseg_fast_input_path(config, subject, session)[source]
Derivative path for the SynthSeg-masked T1w image FSL FAST is run on.
- Parameters:
subject (str)
session (str | None)
- Return type:
Path
- mrsiprep.tissue.synthseg_fast.synthseg_native_labels_path(config, subject, session)[source]
Derivative path for SynthSeg's native-resolution anatomical label map (
dseg).The filename encodes
config.synthseg_mode(fast/standard/robust), so switching modes doesn't reuse a stale cached segmentation from a different mode.- Parameters:
subject (str)
session (str | None)
- Return type:
Path