mask2rs

Submodules

mask

class segmentation_rt.mask2rs.mask.Mask(mask, ct_path=None, ds_cts=None, structures=None)

Bases: object

Class that hold any structures aligned with a reference CT.

Parameters
  • mask (tio.LABEL) – Path to the mask or a tio.Label.

  • ct_path (string) – Path to the CT folder.

  • ds_cts (List[pydicom.dataset.FileDataset]) – CT Dataset.

coordinates(mask)

Give the coordinates of the corresponding structures in the RCS and the SOP Instance UID.

Parameters

mask (torch.Tensor) – mask.

Returns

List of ROI contour sequence.

Return type

list[(str,list[int])]

rtstruct

class segmentation_rt.mask2rs.rtstruct.RTStruct(ct_path, mask, structures=None, output=None)

Bases: object

Class that builds a RT structure pydicom.dataset.Dataset.

Example:
>>> from segmentation_rt.mask2rs import RTStruct
>>> structures = ['Heart', 'Breast L', 'Breast R']
>>> ct_path = os.path.join('prediction/143012/ct/')
>>> mask = os.path.join('prediction/143012/fake_segmentation.nii')
>>> struct = RTStruct(ct_path, mask, structures)
>>> struct.create()
>>> struct.save()
Parameters
  • ct_path (string) – Path to the CT folder.

  • tio.LABEL] mask (Union[str,) – Path to the CT folder.

  • structures (list[str]) – List of structures.

  • output (str) – Export path.

add_referenced_frame_of_reference_sequence()

Fill the frame of reference module.

add_roi_contour_sequence(structure, index, coordinates)

Add a sequence to the ROI Contour Module.

Parameters
  • structure (dict[str, str]) – dict containing structure information.

  • index (int) – index of the structure.

  • coordinates (list[(str,list[int])]) – coordinates of the corresponding structures in theRCS and the SOP Instance UID` associated for each slice.

add_roi_observation_sequence(structure, index)

Add a sequence to the RT ROI Observations Module.

Parameters
  • structure (dict[str, str]) – dict containing structure information.

  • index (int) – index of the structure.

add_structure_set_roi_sequence(structure, index)

Add a sequence to the Structure Set Module.

Parameters
  • structure (dict[str, str]) – dict containing structure information.

  • index (int) – index of the structure.

add_structure_to_dataset(structure, index, coordinates)

Add a structure set to the dataset.

Parameters
  • structure (dict[str, str]) – dict containing structure information.

  • index (int) – index of the structure.

  • coordinates (list[(str,list[int])]) – coordinates of the corresponding structures in theRCS and the SOP Instance UID` associated for each slice.

create()

Convert the masks into structure set.

init_sequence()

Initialize a new sequence.

save(name=None)

Save in dicom format.

Parameters

name (str) – name of the file.