miblab.kidney_pc_dixon#
- miblab.kidney_pc_dixon(input_array, model='unetr', overlap=0.3, postproc=True, clear_cache=False, verbose=False)[source]#
Segment individual kidneys on post-contrast Dixon images.
This requires 4-channel input data with out-phase images, in-phase images, water maps, and fat maps.
- Parameters:
input_array (numpy.ndarray) – A 4D numpy array of shape [x, y, z, contrast] representing the input medical image volume. The last index must contain out-phase, in-phase, water and fat images, in that order.
model –
model = ‘unetr’ uses a pretrained UNETR-based model in MONAI, hosted on Zenodo model = ‘nnunet’ uses a pretrained nnUNet-based model, hosted on Zenodo under the hood this runs nnUNetPredictor (for more details MIC-DKFZ Wiki)
overlap (float) – only valid for model = ‘unetr’ defines the amount of overlap between adjacent sliding window patches during inference. A higher value (e.g., 0.5) improves prediction smoothness at patch borders but increases computation time.
postproc (bool) – If True, applies post-processing to select the largest connected component from the UNETR output for each kidney mask
clear_cache – If True, the downloaded pth file is removed again after running the inference.
verbose (bool) – If True, prints logging messages.
- Returns:
A dictionary with the keys ‘leftkidney’ and ‘rightkidney’, each containing a binary NumPy array representing the respective kidney mask.
- Return type:
Example
>>> import numpy as np >>> import miblab >>> data = np.random.rand(128, 128, 30, 4) >>> mask = miblab.kidney_pc_dixon(data) >>> print(mask['kidney_left']) [0 1 1 ... 0 0 0]