pylidc.utils.consensus(anns, clevel=0.5, pad=None, ret_masks=True, verbose=True)[source]

Return the boolean-valued consensus volume amongst the provided annotations (anns) at a particular consensus level (clevel).

  • anns (list of pylidc.Annotation objects) – This list should be probably be one of the lists returned by the pylidc.Scan.cluster_annotations routine.
  • clevel (float, default=0.5) – The consensus fraction. For example, if clevel=0.5, then a voxel will have value 1 in the returned boolean volume when >= 50% of the segmentations include that voxel, and 0 otherwise.
  • pad (int, list, or float, default=None) – See Annotation.bbox for description for this argument.
  • ret_masks (bool, default=True) – If True, a list of masks is also returned corresponding to all the annotations. Note that this slightly different than calling boolean_mask on each respective Annotation object because these volumes will be the same shape and in a common reference frame.
  • verbose (bool, default=True) – Turns the DICOM image loading message on/off.

consensus_mask, consensus_bbox[, masks]consensus_mask is the boolean-valued volume of the annotation masks at clevel consensus. consensus_bbox is a 3-tuple of slices that can be used to index into the image volume at the corresponding location of consensus_mask. masks is a list of boolean-valued mask volumes corresponding to each Annotation object. Each mask in the masks list has the same shape and is sampled in the common reference frame provided by consensus_bbox.

Return type:

(ndarray, tuple[, list])

pylidc.utils.volume_viewer(vol, mask=None, **line_kwargs)[source]

Interactive volume viewer utility

  • vol (ndarray, ndim=3) – An image volume.
  • mask (ndarray, ndim=3, dtype=bool) – A boolean mask volume.
  • line_kwargs (args) – Any keyword arguments that can be passed to matplotlib.pyplot.plot.


An example:

import pylidc as pl
from pylidc.utils import volume_viewer

ann = pl.query(pl.Annotation).first()
vol = ann.scan.to_volume()

padding = 70.0

mask = ann.boolean_mask(pad=padding)
bbox = ann.bbox(pad=padding)

volume_viewer(vol[bbox], mask, ls='-', lw=2, c='r')