class pylidc.Contour(**kwargs)[source]

The Contour class holds the nodule boundary coordinate data of a pylidc.Annotation object for a single slice in the CT volume.


bool – If True, the area inside the contour is included as part of the nodule. If False, the area inside the contour is excluded from the nodule.


float – This is the imageZposition defined via the xml annnotations for this contour. It is the z-coordinate of DICOM attribute (0020,0032).


string – This is the name of the corresponding DICOM file for the scan to which this contour belongs, having the same image_z_position.


string – These are the sequential (x,y) coordinates of the curve, stored as a string. It is better to access these coordinates using the to_matrix method, which returns a numpy array rather than a string.


Plotting a contour on top of the image volume:

import pylidc as pl
import matplotlib.pyplot as plt

ann = pl.query(pl.Annotation).first()
vol = ann.scan.to_volume()
con = ann.contours[3]

k = con.image_k_position
ii,jj = ann.contours[3].to_matrix(include_k=False).T

plt.plot(jj, ii, '-r', lw=1, label="Nodule Boundary")

Similar to Contour.image_z_position, but returns the index instead of the z coordinate value.


This index may not be unique if the slice_zvals of the respective scan are not unique.


Return the contour-annotation coordinates as a matrix where each row contains an (i,j,k) index coordinate into the image volume.

Parameters:include_k (bool, default=True) – Set include_k=False to omit the k axis coordinate.