kwneuro.masks¶
Functions¶
|
Run brain extraction on a single volume using HD-BET. |
Run brain extraction on a batch of DWI cases. |
|
Run brain extraction on a batch of structural image cases. |
Module Contents¶
- kwneuro.masks.brain_extract(volume: kwneuro.resource.VolumeResource, output_path: kwneuro.util.PathLike, *, sequential: bool = False) kwneuro.io.NiftiVolumeResource¶
Run brain extraction on a single volume using HD-BET.
- Parameters:
volume – Input volume to extract a brain mask from.
output_path – Output path for the brain mask.
Returns the computed brain mask.
- kwneuro.masks.brain_extract_dwi_batch(cases: list[tuple[kwneuro.dwi.Dwi, pathlib.Path]], *, sequential: bool = False) list[kwneuro.io.NiftiVolumeResource]¶
Run brain extraction on a batch of DWI cases. HD-BET does not run in parallel, but it does have some initialization time so it helps to run cases in batches.
- Parameters:
cases – A list of pairs each consisting of an input Dwi and desired output path for the mask.
sequential – Pass through to
_run_hd_bet(). Set to True when running inside an embedded Python that can’t safelymultiprocessing.spawn(e.g. 3D Slicer’s bundled Python). Default False preserves the parallelised behaviour. The mean b0 of each DWI is used as the input to HD-BET.
Returns a list of computed brain masks that is in correspondence with the list of input cases.
- kwneuro.masks.brain_extract_structural_batch(cases: list[tuple[kwneuro.structural.StructuralImage, pathlib.Path]], *, sequential: bool = False) list[kwneuro.io.NiftiVolumeResource]¶
Run brain extraction on a batch of structural image cases. HD-BET does not run in parallel, but it does have some initialization time so it helps to run cases in batches.
- Parameters:
cases – A list of pairs each consisting of an input StructuralImage and desired output path for the mask.
sequential – Pass through to
_run_hd_bet(). Set to True
when running inside an embedded Python that can’t safely
multiprocessing.spawn(e.g. 3D Slicer’s bundled Python). Default False preserves the parallelised behaviour.Returns a list of computed brain masks that is in correspondence with the list of input cases.