kwneuro.masks ============= .. py:module:: kwneuro.masks Functions --------- .. autoapisummary:: kwneuro.masks.brain_extract kwneuro.masks.brain_extract_dwi_batch kwneuro.masks.brain_extract_structural_batch Module Contents --------------- .. py:function:: 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. :param volume: Input volume to extract a brain mask from. :param output_path: Output path for the brain mask. Returns the computed brain mask. .. py:function:: 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. :param cases: A list of pairs each consisting of an input Dwi and desired output path for the mask. :param sequential: Pass through to :func:`_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. 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`. .. py:function:: 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. :param cases: A list of pairs each consisting of an input StructuralImage and desired output path for the mask. :param sequential: Pass through to :func:`_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`.