miblab.totseg#

miblab.totseg(vol, cutoff=None, **kwargs)[source]#

Run totalsegmentator on one or more volumes.

Source: totalsegmentator.

Parameters:
  • vol (vreg.Volume3D or list) – Either a single volume, or a list of volumes to be segmented.

  • cutoff (float, optional) – Pixels with a probability higher than cutoff will be included in the mask. If cutoff is not provided, probabilities will be returned directly. Defaults to None.

  • kwargs – Any keyword arguments accepted by the totalsegmentor python API.

Returns:

dictionary with keys the mask names (ROI labels) and values the corresponding vreg.Volume3D objects.

Return type:

dict

Example

Use a machine with a cpu to run the task ‘total_mr’ on a single volume saved as a nifti file:

>>> import miblab
>>> import vreg
>>> vol = vreg.read_nifti('path/to/volume.nii.gz')
>>> mask = miblab.totseg(vol, cutoff=0.01, task='total_mr', device='cpu')
>>> print(mask['liver'].values)
[0 1 1 ... 0 0 0]