mrsiprep.workflows.anatomical
Anatomical preparation workflow.
Functions
|
Re-add the CSF compartment to a skull-stripped T1w for the |
|
Resolve which T1w image/mask registration should target. |
Classes
|
T1w images/masks selected for registration, from |
- class mrsiprep.workflows.anatomical.AnatomicalResult(t1w, raw_t1w, brain_mask, registration_t1w, registration_mask, target_kind)[source]
Bases:
objectT1w images/masks selected for registration, from
prepare_anatomical().- Variables:
t1w -- The skull-stripped T1w passed in as
t1_path(SynthSeg or CAT12 brain extraction output, depending onconfig.tissue_backend).raw_t1w -- The original, non-skull-stripped T1w acquisition, if found in the BIDS layout;
Noneif the dataset only provides a pre-skull-stripped image.brain_mask -- Brain-only mask corresponding to
t1w, if available.registration_t1w -- The T1w image registration should actually target -- equal to
t1wfor thebraintarget,raw_t1wforraw, or a freshly built brain+CSF composite forbrain-csf.registration_mask -- Mask matching
registration_t1w(Nonefor therawtarget, which registers without a fixed mask).target_kind -- The resolved
config.registration_t1_targetvalue ("brain","brain-csf", or"raw").
- Parameters:
t1w (Path)
raw_t1w (Path | None)
brain_mask (Path | None)
registration_t1w (Path)
registration_mask (Path | None)
target_kind (str)
- brain_mask: Path | None
- raw_t1w: Path | None
- registration_mask: Path | None
- registration_t1w: Path
- t1w: Path
- target_kind: str
- mrsiprep.workflows.anatomical.create_brain_csf_t1(skull_t1, raw_t1, p3, out_t1, out_mask, threshold=0.95, overwrite=False)[source]
Re-add the CSF compartment to a skull-stripped T1w for the
brain-csfregistration target.Combines the
skull_t1brain mask with voxels where the CAT12 CSF probability map (p3) exceedsthreshold, then masksraw_t1with the union -- so CSF-adjacent MRSI signal isn't clipped at the brain-only boundary.skull_t1,raw_t1, andp3must share the same shape and affine.- Parameters:
skull_t1 (Path) -- Skull-stripped T1w (defines the brain-only mask via
> 0).raw_t1 (Path) -- Original, non-skull-stripped T1w acquisition -- only its CSF-region voxels are used.
p3 (Path) -- CAT12 CSF tissue-probability map, same grid as
skull_t1.out_t1 (Path) -- Output path for the brain+CSF composite T1w.
out_mask (Path) -- Output path for the corresponding brain+CSF binary mask.
threshold (float) -- Minimum CSF probability (in
p3) for a voxel outside the brain mask to be classified as CSF and included.overwrite (bool) -- Recompute even if
out_t1/out_maskalready exist.
- Returns:
(out_t1, out_mask).- Raises:
ValueError -- If the three input images don't share a shape or affine.
- Return type:
tuple[Path, Path]
- mrsiprep.workflows.anatomical.prepare_anatomical(config, subject, session, t1_path, p3_override=None, brain_mask_override=None)[source]
Resolve which T1w image/mask registration should target.
Dispatches on
config.registration_t1_target:"brain"-- register directly to the skull-strippedt1_path(the common case)."brain-csf"-- build a fresh T1w with the CSF compartment re-added to the skull-stripped image (viacreate_brain_csf_t1(), using the CAT12 p3 CSF probability map), so CSF-adjacent MRSI signal isn't clipped at the brain-only boundary. Requires both a raw T1w acquisition and a p3 map to be found in the BIDS layout."raw"-- register to the original, non-skull-stripped T1w with no fixed mask.
- 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) -- Skull-stripped T1w image (SynthSeg/CAT12 brain extraction output).
p3_override (Path | None) -- Explicit CAT12 p3 CSF probseg path, bypassing BIDS-layout lookup; used by
brain-csfwhen set.brain_mask_override (Path | None) -- Explicit brain mask path, bypassing BIDS-layout lookup.
- Returns:
AnatomicalResultdescribing which image/mask pair downstream registration should use.- Raises:
FileNotFoundError -- If
target_kindis"brain-csf"or"raw"and the required raw T1w / p3 map isn't found.ValueError -- If
config.registration_t1_targetisn't one of the three supported values.
- Return type: