cerr.dataclasses package
Submodules
cerr.dataclasses.beams module
beams module.
The beams module defines metadata for RT Plan (RTPLAN). The metadata are attributes of the Beams class.
- class cerr.dataclasses.beams.Beams(PatientName: str = '', PatientID: str = '', PatientBirthDate: str = '', PatientSex: str = '', Manufacturer: str = '', ManufacturerModelName: str = '', RelationshipGroupLength: int = 0, ImagePresentationGroupLength: int = 0, PixelPaddingValue: float = 0, PlanGroupLength: int = 0, RTPlanLabel: str = '', RTPlanDate: str = '', RTPlanTime: str = '', RTPlanGeometry: str = '', TreatmentSites: ~numpy.array = <factory>, PrescriptionDescription: str = '', DoseReferenceSequence: ~numpy.array = <factory>, FractionGroupSequence: ~numpy.array = <factory>, BeamSequence: ~numpy.array = <factory>, PatientSetupSequence: ~numpy.array = <factory>, ReferencedRTGroupLength: int = 0, ReferencedStructureSetSequence: ~numpy.array = <factory>, ReferencedDoseSequence: ~numpy.array = <factory>, ReviewGroupLength: int = 0, ApprovalStatus: str = '', ReviewDate: str = '', ReviewTime: str = '', ReviewerName: str = '', SOPInstanceUID: str = '', BeamUID: str = '')[source]
Bases:
objectThis class defines data object for Beams in an RTPlan. The metadata is populated from DICOM. .. attribute:: PatientName
Patient’s name
- type:
str
- PatientID
Patient’s ID
- Type:
str
- PatientBirthDate
Patient’s birth date
- Type:
str
- PatientSex
Patient’s gender
- Type:
str
- Manufacturer
Equipment manufacturer
- Type:
str
- ManufacturerModelName
Equipment model
- Type:
str
- PixelPaddingValue
Pixel padding value as defined in (0028,0120) DICOM tag
- Type:
float
- RTPlanLabel
User-defined label for treatment plan as defined by (300A,0002) DICOM tag
- Type:
str
- RTPlanDate
Date treatment plan was last modified as defined by (300A,0006) DICOM tag
- Type:
str
- RTPlanTime
Time treatment plan was last modified as defined by (300A,0007) DICOM tag
- Type:
str
- RTPlanGeometry
Describes whether RT Plan is based on patient or treatment device geometry (300A,000C) tag
- Type:
str
- TreatmentSites
A free-text label describing the anatomical treatment site. (3010,0077) tag
- Type:
np.array
- PrescriptionDescription
User-defined description of treatment prescription as defined in (300A,000E)
- Type:
str
- FractionGroupSequence
Sequence of Fraction Groups as per (300A,0070) DICOM tag
- Type:
np.array
- BeamSequence
Sequence of treatment beams for current RT Plan as per (300A,00B0) DICOM tag
- Type:
np.array
- PatientSetupSequence
Sequence of patient setup data for current plan as per (300A,0180) DICOM tag
- Type:
np.array
- ReferencedStructureSetSequence
The RT Structure Set on which the RT Plan is based as per (300C,0060) DICOM tag
- Type:
np.array
- ReferencedDoseSequence
Sequence of Dose References.
- Type:
np.array
- ApprovalStatus
Approval status at the time the SOP Instance was created as per (300E,0002) DICOM tag.
- Type:
str
- ReviewDate
Date plan was reviewed
- Type:
str
- ReviewTime
Time plan was reviewed
- Type:
str
- ReviewerName
Reviewer name
- Type:
str
- SOPInstanceUID
SOP Instance UID of the Plan
- Type:
str
- BeamUID
pyCERR’s UID of RTPLAN
- Type:
str
- class cerr.dataclasses.beams.ReferenceSeq(ReferencedSOPClassUID: str = '', ReferencedSOPInstanceUID: str = '')[source]
Bases:
objectThis class defines referenced sequence. .. attribute:: ReferencedSOPClassUID
Referenced SOP class UID
- type:
str
- ReferencedSOPInstanceUID
Referenced SOP instance UID
- Type:
str
- class cerr.dataclasses.beams.PatientSetupSeq(PatientSetupNumber: int = 0, PatientPosition: str = '')[source]
Bases:
objectThis class defines patient setup sequence. .. attribute:: PatientSetupNumber
Identification number of the Patient Setup as per (300A,0182) DICOM tag
- type:
int
- PatientPosition
Patient position descriptor relative to the equipment as per (0018,5100) DICOM tag
- Type:
str
- class cerr.dataclasses.beams.BeamLimitingDevicePositionSeq(RTBeamLimitingDeviceType: str = '', LeafJawPositions: ~numpy.array = <factory>)[source]
Bases:
objectThis class defines data model for Sequence of beam limiting device (collimator) jaw or leaf (element) positions. .. attribute:: RTBeamLimitingDeviceType
Type of beam limiting device (collimator) as per (300A,00B8) DICOM tag
- type:
str
- LeafJawPositions
Positions of beam limiting device (collimator) leaf (element) or jaw pairs (in mm) in IEC BEAM LIMITING DEVICE coordinate axis appropriate to RT Beam Limiting Device Type as defined in (300A,011C) DICOM tag
- Type:
np.array
- class cerr.dataclasses.beams.ControlPointSequence(BeamLimitingDevicePositionSequence: ~numpy.array = <factory>, ControlPointIndex: int = 0, NominalBeamEnergy: float = 0, GantryAngle: float = 0, GantryRotationDirection: str = '', BeamLimitingDeviceAngle: float = 0, BeamLimitingDeviceRotationDirection: str = '', PatientSupportAngle: float = 0, TableTopEccentricAngle: float = 0, TableTopEccentricRotationDirection: str = '', IsocenterPosition: ~numpy.array = <factory>, SourceToSurfaceDistance: float = 0, CumulativeMetersetWeight: float = 0)[source]
Bases:
objectThis class defines data model for the Sequence of machine configurations describing treatment beam. .. attribute:: BeamLimitingDevicePositionSequence
Sequence of beam limiting device (collimator) jaw or leaf (element) positions as per (300A,011A) DICOM tag.
- type:
np.array
- ControlPointIndex
Index of current Control Point, starting at 0 for first Control Point as per (300A,0112) DICOM tag.
- Type:
int
- NominalBeamEnergy
Nominal Beam Energy at control point (MV/MeV) as per (300A,0114) DICOM tag
- Type:
float
- GantryAngle
Gantry angle of radiation source, i.e., orientation of IEC GANTRY coordinate system with respect to IEC FIXED REFERENCE coordinate system (degrees) as per (300A,011E) DICOM tag.
- Type:
float
- GantryRotationDirection
Direction of Gantry Rotation when viewing gantry from isocenter, for segment following Control Point as per (300A,011F) DICOM tag.
- Type:
str
- BeamLimitingDeviceAngle
Beam Limiting Device angle, i.e., orientation of IEC BEAM LIMITING DEVICE coordinate system with respect to IEC GANTRY coordinate system (degrees) as per (300A,0120) DICOM tag.
- Type:
float
- BeamLimitingDeviceRotationDirection
Direction of Beam Limiting Device Rotation when viewing beam limiting device (collimator) from radiation source, for segment following Control Point as per (300A,0121) DICOM tag
- Type:
str
- PatientSupportAngle
Patient Support angle, i.e., orientation of IEC PATIENT SUPPORT (turntable) coordinate system with respect to IEC FIXED REFERENCE coordinate system (degrees) as per (300A,0122) DICOM tag
- Type:
float
- TableTopEccentricAngle
Table Top (non-isocentric) angle, i.e., orientation of IEC TABLE TOP ECCENTRIC coordinate system with respect to IEC PATIENT SUPPORT coordinate system (degrees) as per (300A,0125) DICOM tag.
- Type:
float
- TableTopEccentricRotationDirection
- Type:
str
- IsocenterPosition
Direction of Table Top Eccentric Rotation when viewing table from above, for segment following Control Point as per (300A,0126) DICOM tag
- Type:
np.array
- SourceToSurfaceDistance
Source to Patient Surface (skin) distance (mm) as per (300A,0130) DICOM tag
- Type:
float
- CumulativeMetersetWeight
Cumulative weight to current control point as per (300A,0134) DICOM tag
- Type:
float
- class cerr.dataclasses.beams.RefBeamSeq(ReferencedBeamNumber: int = 0, BeamMeterset: float = 0)[source]
Bases:
objectThis class defies data model for the sequence of Beams in current Fraction Group contributing to dose as per (300C,0004) DICOM tag. .. attribute:: ReferencedBeamNumber
Uniquely identifies Beam specified by Beam Number as per (300C,0006) DICOM tag
- type:
int
- BeamMeterset
Meterset duration over which image is to be acquired, specified in Monitor units (MU) as per (3002,0032) DICOM tag
- Type:
float
- class cerr.dataclasses.beams.FractionGroupSeq(FractionGroupNumber: int = 0, NumberOfFractionsPlanned: int = 0, NumberOfBeams: int = 0, NumberOfBrachyApplicationSetups: int = 0, RadiationType: str = '', RefBeamSeq: ~numpy.array = <factory>)[source]
Bases:
objectThis class defines data model for Sequence of Fraction Groups in current Fraction Scheme as per (300A,0070) DICOM tag. .. attribute:: FractionGroupNumber
Identification number of the Fraction Group as per (300A,0071)
- type:
int
- NumberOfFractionsPlanned
Total number of treatments (Fractions) prescribed for current Fraction Group as per (300A,0078)
- Type:
int
- NumberOfBeams
Number of Beams in current Fraction Group as per (300A,0080)
- Type:
int
- NumberOfBrachyApplicationSetups
Number of Brachy Application Setups in current Fraction Group as per (300A,00A0)
- Type:
int
- RadiationType
Particle type of Beam as per (300A,00C6)
- Type:
str
- RefBeamSeq
Sequence of Beams in current Fraction Group contributing to dose as per (300C,0004)
- Type:
np.array
- class cerr.dataclasses.beams.BeamSeq(Manufacturer: str = '', BeamName: str = '', BeamType: str = '', BeamDescription: str = '', BeamNumber: int = 0, SourceAxisDistance: float = 0, BeamLimitingDevicePositionSeq: ~numpy.array = <factory>, RadiationType: str = '', TreatmentDeliveryType: str = '', NumberOfWedges: float = 0, NumberOfBoli: float = 0, NumberOfCompensators: float = 0, NumberOfBlocks: float = 0, NumberOfControlPoints: float = 0, ControlPointSequence: ~numpy.array = <factory>)[source]
Bases:
objectThis class defines data model for Sequence of treatment beams for current RT Plan as per (300A,00B0) DICOM tag. .. attribute:: Manufacturer
Manufacturer of the equipment to be used for beam delivery as per (0008,0070)
- type:
str
- BeamName
primary beam identifier (often referred to as “field identifier”) as per (300A,00C2)
- Type:
str
- BeamType
Motion characteristic of Beam as per (300A,00C4)
- Type:
str
- BeamDescription
User-defined description for Beam as per (300A,00C3)
- Type:
str
- BeamNumber
Identification number of the Beam as per (300A,00C0)
- Type:
int
- SourceAxisDistance
Radiation source to Gantry rotation axis distance of the equipment that is to be used for beam delivery (mm) as per (300A,00B4)
- Type:
float
- BeamLimitingDevicePositionSeq
Sequence of beam limiting device (collimator) jaw or leaf (element) sets as per (300A,00B6)
- Type:
np.array
- RadiationType
Particle type of Beam as per (300A,00C6)
- Type:
str
- TreatmentDeliveryType
Delivery Type of treatment as per (300A,00CE)
- Type:
str
- NumberOfWedges
Number of wedges associated with current Beam as per (300A,00D0)
- Type:
float
- NumberOfBoli
Number of boli associated with current Beam as per (300A,00ED)
- Type:
float
- NumberOfCompensators
Number of compensators associated with current Beam as per (300A,00E0)
- Type:
float
- NumberOfBlocks
Number of shielding blocks associated with Beam as per (300A,00F0)
- Type:
float
- NumberOfControlPoints
Number of control points in Beam as per (300A,0110)
- Type:
float
- ControlPointSequence
Sequence of machine configurations describing treatment beam as per (300A,0111)
- Type:
np.array
cerr.dataclasses.deform module
structure module.
Ths deform module defines metadata for deformation (REG). The metadata are attributes of the Deform class. This module also defines routines for transforming and accessing the Deformation Vector Field metadata in CERR coordinate system.
- class cerr.dataclasses.deform.Deform(baseScanUID: str = '', movScanUID: str = '', algorithm: str = '', algorithmParams: dict = <factory>, deformParams: dict = <factory>, deformUID: str = '', registrationTool: str = '', deformOutFileType: str = '', deformOutFilePath: str = '', dvfMatrix: numpy.ndarray = <factory>, xOffset: float = 0.0, yOffset: float = 0.0, dx: float = 0.0, dy: float = 0.0, imageOrientationPatient: <built-in function array> = <factory>, imagePositionPatientV: <built-in function array> = <factory>, zValuesV: numpy.ndarray = <factory>, Image2PhysicalTransM: numpy.ndarray = <factory>, Image2VirtualPhysicalTransM: numpy.ndarray = <factory>, cerrToDcmTransM: numpy.ndarray = <factory>)[source]
Bases:
object- baseScanUID: str = ''
- movScanUID: str = ''
- algorithm: str = ''
- algorithmParams: dict
- deformParams: dict
- deformUID: str = ''
- registrationTool: str = ''
- deformOutFileType: str = ''
- deformOutFilePath: str = ''
- dvfMatrix: ndarray
- xOffset: float = 0.0
- yOffset: float = 0.0
- dx: float = 0.0
- dy: float = 0.0
- imageOrientationPatient: array
- imagePositionPatientV: array
- zValuesV: ndarray
- Image2PhysicalTransM: ndarray
- Image2VirtualPhysicalTransM: ndarray
- cerrToDcmTransM: ndarray
cerr.dataclasses.dose module
dose module.
The dose module defines metadata for an RTDOSE object. The metadata are attributes of the Dose class. This module also defines routines for transforming and accessing the Dose metadata in CERR coordinate system.
- class cerr.dataclasses.dose.Dose(caseNumber: int = 0, patientName: str = '', doseNumber: int = 0, doseType: str = '', doseSummationType: str = '', refBeamNumber: int = 0, refFractionGroupNumber: int = 0, numberMultiFrameImages: int = 0, doseUnits: str = '', doseScale: float = 1, fractionGroupID: str = '', numberOfTx: int = 0, orientationOfDose: str = '', imagePositionPatient: ~numpy.array = <factory>, imageOrientationPatient: ~numpy.array = <factory>, numberRepresentation: int = 0, numberOfDimensions: int = 0, sizeOfDimension1: int = 0, sizeOfDimension2: int = 0, sizeOfDimension3: int = 0, coord1OFFirstPoint: float = 0, coord2OFFirstPoint: float = 0, horizontalGridInterval: float = 0, verticalGridInterval: float = 0, doseDescription: str = '', doseEdition: str = '', unitNumber: int = 0, writer: str = '', dateWritten: str = '', planNumberOfOrigin: int = 0, planEditionOfOrigin: str = '', studyNumberOfOrigin: int = 0, studyInstanceUID: str = '', versionNumberOfProgram: str = '', xcoordOfNormaliznPoint: float = nan, ycoordOfNormaliznPoint: float = nan, zcoordOfNormaliznPoint: float = nan, doseAtNormaliznPoint: float = nan, doseError: float = nan, coord3OfFirstPoint: float = nan, depthGridInterval: float = nan, planIDOfOrigin: str = '', doseArray: ~numpy.array = <factory>, zValues: ~numpy.array = <factory>, delivered: str = '', cachedColor: str = '', cachedTime: str = '', numCachedSlices: int = 0, transferProtocol: str = '', associatedScan: int = nan, transM: ~numpy.array = <factory>, doseUID: str = '', assocScanUID: str = '', assocBeamUID: str = '', frameOfReferenceUID: str = '', refRTPlanSopInstanceUID: str = '', refStructSetSopInstanceUID: str = '', prescriptionDose: float = 0, doseOffset: float = 0, Image2PhysicalTransM: ~numpy.array = <factory>, cerrDcmSliceDirMatch: bool = False)[source]
Bases:
objectThis class defines data object for RTDose. The metadata is populated from DICOM.
- patientName
Patient’s name
- Type:
str
- doseType
Type of dose as per (3004,0004). Values can be PHYSICAL, EFFECTIVE or ERROR
- Type:
str
- doseSummationType
Type of dose summation as per (3004,000A)
- Type:
str
- refBeamNumber
Referenced beam number from ReferencedRTPlanSequence
- Type:
int
- refFractionGroupNumber
Referenced Fraction Group number from ReferencedRTPlanSequence
- Type:
int
- numberMultiFrameImages
Number of image frames
- Type:
int
- doseUnits
Units used to describe dose. GY or RELATIVE
- Type:
str
- doseScale
Scaling factor that when multiplied by the dose grid data found in Pixel Data (7FE0,0010) Attribute of the Image Pixel Module, yields grid doses in the dose units as specified by Dose Units (3004,0002).
- Type:
float
- fractionGroupID
Fraction Group ID from Referenced RTPLAN
- Type:
str
- imagePositionPatient
x,y,z coordinate of the top left voxel of the dose volume.
- Type:
np.array
- imageOrientationPatient
Direction cosine of dose row and column with patient coordinate system.
- Type:
np.array
- sizeOfDimension1
Number of columns of doseArray
- Type:
int
- sizeOfDimension2
Number of rows of doseArray
- Type:
int
- sizeOfDimension3
Number of slices of doseArray
- Type:
int
- coord1OFFirstPoint
x-coordinate of dose in CERR virtual coordinates
- Type:
float
- coord2OFFirstPoint
y-coordinate of dose in CERR virtual coordinates
- Type:
float
- horizontalGridInterval
delta x of dose in CERR virtual coordinates
- Type:
float
- verticalGridInterval
delta y of dose in CERR virtual coordinates
- Type:
float
- writer
Equipment Manufacturer for RTDOSE delivery.
- Type:
str
- dateWritten
Study Date.
- Type:
str
- studyInstanceUID
Study Instance UID of dose.
- Type:
str
- xcoordOfNormaliznPoint
x-ccordinate of normalization point
- Type:
float
- ycoordOfNormaliznPoint
y-ccordinate of normalization point
- Type:
float
- zcoordOfNormaliznPoint
z-ccordinate of normalization point
- Type:
float
- doseAtNormaliznPoint
dose at normalization point
- Type:
float
- coord3OfFirstPoint
z-coordinate of dose in CERR virtual coordinates
- Type:
float
- doseArray
3D volume for RTODSE in doseUnits
- Type:
np.array
- zValues
z-coordinates of doseArray in CERR virtual coordinate system.
- Type:
np.array
- delivered
whether the dose was delivered.
- Type:
str
- transM
transformation matrix to transform dose.
- Type:
np.array
- doseUID
unique identifier of dose.
- Type:
str
- assocScanUID
associated scan’s unique identifier
- Type:
str
- assocBeamUID
associated RTPLAN’s unique identifier
- Type:
str
- frameOfReferenceUID
Frame of Reference UID
- Type:
str
- refRTPlanSopInstanceUID
SOP Instance UID of associated RTPLAN
- Type:
str
- refStructSetSopInstanceUID
SOP Instance UID of referenced RTSTRUCT
- Type:
str
- prescriptionDose
Prescription dose
- Type:
float
- doseOffset
offset value to add to doseArray
- Type:
float
- Image2PhysicalTransM
Transformation matrix to convert pyCERR’s dose row,col,slc to DICOM physical coordinates.
- Type:
np.ndarray
- cerrDcmSliceDirMatch
Flag whether pyCERR slice order matches DICOM.
- Type:
bool
- getNiiAffine()[source]
Routine for affine transformation of pyCERR dose object for storing in NifTi format
- Returns:
3x3 affine matrix
- Return type:
np.ndarray
- saveNii(niiFileName)[source]
Routine to save pyCERR Dose object to NifTi file
- Parameters:
niiFileName (str) – File name including the full path to save the pyCERR dose object to NifTi file.
- Returns:
0 when NifTi file is written successfully.
- Return type:
int
- convertDcmToCerrVirtualCoords(planC)[source]
Routine to get scan from DICOM to pyCERR virtual coordinates. More information about virtual coordinates is on the Wiki https://github.com/cerr/pyCERR/wiki/Coordinate-system
- getDoseXYZVals()[source]
Routine to obtain pyCERR dose object’s x,y,z grid coordinates. The coordinates are in pyCERR’s virtual coordinate system.
- Returns:
x, y, z coordinates corresponding to the columns, rows, slices of scan voxels
- Return type:
tuple
- getDoseAt(xV, yV, zV)[source]
Routine to obtain dose at input x,y,z grid coordinates. The coordinates are in pyCERR’s virtual coordinate system.
- Returns:
An array of dose values.
- Return type:
tuple (np.array)
- getAssociatedBeamNum(planC)[source]
Routine to obtain index of planC.beams that generated this RTDOSE
- Parameters:
planC (cerr.plan_container.PlanC) – pyCERR’s plan container object
- Returns:
index of planC.beams
- Return type:
int
- cerr.dataclasses.dose.loadDose(file_list)[source]
- Parameters:
file_list (list) – list of files to read into pyCERR’s Dose object
- Returns:
List whose elements are pyCERR Dose objects containing metadata from file_list.
- Return type:
List[cerr.daatclasses.dose.Dose]
- cerr.dataclasses.dose.getDoseNumFromUID(assocDoseUID, planC) int[source]
- Parameters:
assocDoseUID (str) – doseUID
planC (cerr.plan_container.PlanC) – pyCERR’s plan container object
- Returns:
index of planC.dose matching input assocDoseUID
- Return type:
int
cerr.dataclasses.header module
header module.
The header module defines metadata for header. The header metadata are useful to keep track of pyCERR version used in creation of plan container object as well as date stamp when it is saved.
cerr.dataclasses.scan module
scan module.
This module defines pyCERR data object for images (CT, MR, PT, US). Metadata can be imported from various file formats such as DICOM, NifTi. It also provides methods to transform the Scan object to other formats such NifTi, SimpleITK and for converting images to real world units and SUV calculation.
- class cerr.dataclasses.scan.Scan(scanArray: ~numpy.ndarray = <factory>, scanType: str = '', scanInfo: ~cerr.dataclasses.scan_info.ScanInfo = <factory>, uniformScanInfo: ~cerr.dataclasses.scan_info.UniformScanInfo = <factory>, scanArraySuperior: ~numpy.ndarray = <factory>, scanArrayInferior: ~numpy.ndarray = <factory>, thumbnails: ~numpy.ndarray = <factory>, transM: ~numpy.ndarray = <factory>, scanUID: str = '', assocDeformUID: str = '', assocTextureUID: str = '', assocBaseScanUID: str = '', assocMovingScanUID: str = '', Image2PhysicalTransM: ~numpy.ndarray = <factory>, Image2VirtualPhysicalTransM: ~numpy.ndarray = <factory>, cerrToDcmTransM: ~numpy.ndarray = <factory>)[source]
Bases:
objectThis class defines data object for volumetric images such as CT, MR, PET or derived image type.
- scanArray
numpy array for the image.
- Type:
np.ndarray
- scanType
Type of scan. e.g. ‘CT SCAN’
- Type:
str
- scanInfo
scan_info object containing metadata for each scan slice
- scanUID
unique identifier for each scan.
- Type:
str
- assocDeformUID
optional, UID of associated deformation object that was used to generate this scan.
- Type:
str
- assocTextureUID
optional, UID of associated texture object that was used to generate this scan.
- Type:
str
- assocBaseScanUID
optional, UID of associated base scan in the deformation that was used to generate this scan.
- Type:
str
- assocMovingScanUID
optional, UID of associated moving scan in the deformation that was used to generate this scan.
- Type:
str
- Image2PhysicalTransM
Transformation matrix to convert pyCERR row,col,slc to DICOM physical coordinates.
- Type:
np.ndarray
- Image2VirtualPhysicalTransM
Transformation matrix to convert pyCERR’s scan row,col,slc to pyCERR virtual coordinates.
- Type:
np.ndarray
- cerrToDcmTransM
Transformation matrix to convert pyCERR virtual x,y,z coordinates to DICOM physical coordinates.
- Type:
np.ndarray
- getScanArray()[source]
Routine to obtain image in the units defined in planC.scan[scanNum].scanInfo[slcNum].imageUnits :returns:
- CTOffset is added to to scanArray such that the resulting array is in
real world units such as HU, SUV
- Return type:
np.ndarray
- getNiiAffine()[source]
Routine for affine transformation of pyCERR scan object for storing in NifTi format
- Returns:
3x3 affine matrix
- Return type:
np.ndarray
- saveNii(niiFileName)[source]
Routine to save pyCERR Scan object to NifTi file
- Parameters:
niiFileName (str) – File name including the full path to save the pyCERR scan object to NifTi file.
- Returns:
0 when NifTi file is written successfully.
- Return type:
int
- getSitkImage()[source]
Routine to convert pyCERR Scan object to SimpleITK Image object
- Returns:
SimpleITK Image
- Return type:
sitk.Image
- getScanXYZVals()[source]
Routine to obtain pyCERR scan object’s x,y,z grid coordinates. The coordinates are in pyCERR’s virtual coordinate system.
- Returns:
x, y, z coordinates corresponding to the columns, rows, slices of scan voxels
- Return type:
tuple
- getScanSize()[source]
Routine to get scan dimensions.
- Returns:
numRows, numCols, numSlcs of pyCERR scan object
- Return type:
np.array
- getScanOrientation()[source]
Routine to get orientation of sacn w.r.t. patient.
- Returns:
3-character String representing the orientation of Scans’s row, column and slice.
- Return type:
str
- getScanSpacing()[source]
Routine to get voxel spacing in cm.
- Returns:
3-element array containing dx, dy, dz of scan
- Return type:
np.array
- convertDcmToCerrVirtualCoords()[source]
Routine to get scan from DICOM to pyCERR virtual coordinates. More information about virtual coordinates is on the Wiki https://github.com/cerr/pyCERR/wiki/Coordinate-system
- convertDcmToRealWorldUnits(opts={})[source]
Routine to convert pixel array from DICOM storage units to real world units.
- Parameters:
opts (dict) –
Dictionary of options to convert to real world units. Currrently, only one option if supported - importMRPreciseValueFlag (yes or no) to specify whether to convert MR image from
Philips scanner to precise values.
- convertToSUV(suvType='BW')[source]
Routine to convert pixel array for PET scan from DICOM storage to SUV
- Parameters:
suvType (str) – optional, type of SUV. When not specified, the suvType is read from DICOM if available. When not specified and not available in DIOCM, a default value of ‘BW’ is used. Currently supported options are ‘BW’, ‘BSA’, ‘LBM’, ‘LBMJANMA’
- cerr.dataclasses.scan.flipSliceOrderFlag(scan)[source]
Routine to determine slice order for determining the origin for conversion to NifTi and SimpleITK formats.
- Parameters:
scan (cerr.dataclasses.scan.Scan) – pyCERR scan object
- Returns:
True when dot product of slice normal and imagePositionPatient increases with slice order
- Return type:
bool
- cerr.dataclasses.scan.getITKDirection(scan)[source]
- Parameters:
scan (cerr.dataclasses.scan.Scan) – pyCERR scan object
- Returns:
9-element array of direction cosines of row, column and slice w.r.t. patient.
- Return type:
np.ndarray
- cerr.dataclasses.scan.populateScanInfoFields(s_info, ds)[source]
- Parameters:
s_info (cerr.dataclasses.scan_info.ScanInfo) – pyCERR’s scanInfo object for storing metadata per slice.
ds (pydicom.dataset.Dataset) – pydicom dataset object
- Returns:
scanInfo object with attributes populated from metadata from input ds.
- Return type:
- cerr.dataclasses.scan.populateRealWorldFields(s_info, perFrameSeq)[source]
- Parameters:
s_info (cerr.dataclasses.scan_info.ScanInfo) – pyCERR’s scanInfo object for storing metadata per slice.
perFrameSeq (pydicom.dataset.Dataset) – pydicom dataset object or ds.PerFrameFunctionalGroupsSequence
images. (for multiFrameFlg)
- Returns:
scanInfo object with attributes populated from metadata from input ds.
- Return type:
- cerr.dataclasses.scan.populateRadiopharmaFields(s_info, seq)[source]
- Parameters:
s_info (cerr.dataclasses.scan_info.ScanInfo) – pyCERR’s scanInfo object for storing metadata per slice.
seq (pydicom.dataset.Dataset) – dataset containing radiopharma metadata for PET scan.
- Returns:
scanInfo object with attributes populated from metadata from input ds.
- Return type:
- cerr.dataclasses.scan.parseScanInfoFields(ds, multiFrameFlg=False) -> (<class 'cerr.dataclasses.scan_info.ScanInfo'>, <property object at 0x7fceefce1cb0>, <class 'str'>)[source]
- Parameters:
ds (pydicom.dataset.Dataset) – Dataset object read from DICOM file
multiFrameFlg (bool) – True when dataset is multiFrame image, otherwise False.
- Returns:
scanInfo object with attributes populated from metadata from input ds.
- Return type:
- cerr.dataclasses.scan.loadSortedScanInfo(file_list)[source]
- Parameters:
file_list (list) – list of files to read into pyCERR’s Scan object
- Returns:
pyCERR scan object containing metadata from the file_list.
- Return type:
cerr.daatclasses.scan.Scan
- cerr.dataclasses.scan.getScanNumFromUID(assocScanUID, planC) int[source]
- Parameters:
assocScanUID (str) – UID of scan.
planC (cerr.plan_container.planC) – pyCERR’s plan container object.
- Returns:
index within planC.scan that matches input assocScanUID.
- Return type:
int
- cerr.dataclasses.scan.getCERRScanArrayFromITK(itkImage, assocScanNum, planC)[source]
This routine returns a numpy array in pyCERR coordinate system (orientation) from a SimpleITK Image.
- Parameters:
itkImage (SimpleITK.Image) – SimpleITK’s Image object
assocScanNum (int) – Scan index to associate orientation of itkImage in pyCERR.
planC (cerr.planC_container.planC) – pyCERR’s plan container object.
- Returns:
array in CERR virtual coordinates.
- Return type:
np.ndarray
cerr.dataclasses.scan_info module
scan_info module.
The scan_info module defines metadata for images (CT, PT, MR, US). The metadata are attributes of the ScanInfo class. This metadata is used to generate physical grid coordinates and for conversion of raw image to real world units.
- class cerr.dataclasses.scan_info.ScanInfo(imageNumber: float = 0.0, imageType: str = '', caseNumber: int = 0, patientName: str = '', patientID: str = '', patientBirthDate: str = '', scanType: str = '', CTOffset: float = 0.0, rescaleSlope: float = 1.0, rescaleIntercept: float = 0.0, rescaleType: str = '', scaleSlope: float = nan, scaleIntercept: float = nan, realWorldValueSlope: float = nan, realWorldValueIntercept: float = nan, realWorldMeasurCodeMeaning: str = '', philipsImageUnits: str = '', philipsRescaleSlope: float = nan, philipsRescaleIntercept: float = nan, grid1Units: float = 0.0, grid2Units: float = 0.0, numberRepresentation: int = 0, bitsAllocated: int = nan, bitsStored: int = nan, pixelRepresentation: int = nan, numberOfDimensions: int = 3, sizeOfDimension1: int = 512, sizeOfDimension2: int = 512, zValue: float = 0.0, xOffset: float = 0.0, yOffset: float = 0.0, CTAir: float = 0.0, CTWater: float = 0.0, sliceThickness: float = 0.0, voxelThickness: float = 1.0, siteOfInterest: str = '', unitNumber: int = 0, seriesDescription: str = '', studyDescription: str = '', scannerType: str = '', manufacturer: str = '', scanFileName: str = '', headInOut: str = '', positionInScan: float = '', patientAttitude: str = '', bValue: float = 0.0, acquisitionDate: str = '', acquisitionTime: str = '', patientWeight: float = '', patientSize: float = '', patientBmi: float = '', patientSex: str = '', radiopharmaInfoS: float = 0.0, injectionTime: str = '', injectionDate: str = '', injectedDose: float = '', halfLife: float = '', imageUnits: str = '', suvType: str = '', petCountSource: str = '', petSeriesType: str = '', petActivityConctrScaleFactor: float = '', petNumSlices: int = '', petPrimarySourceOfCounts: str = '', petDecayCorrectionDateTime: str = '', decayCorrection: float = '', correctedImage: float = '', seriesDate: str = '', seriesTime: str = '', studyDate: str = '', studyTime: str = '', tapeOfOrigin: str = '', studyNumberOfOrigin: int = 0, scanID: str = '', scanNumber: int = 0, scanDate: str = '', CTScale: float = 0.0, distrustAbove: float = '', imageSource: str = '', transferProtocol: str = '', studyInstanceUID: str = '', seriesInstanceUID: str = '', sopInstanceUID: str = '', sopClassUID: str = '', frameOfReferenceUID: str = '', patientPosition: str = '', imageOrientationPatient: ~numpy.array = <factory>, imagePositionPatient: ~numpy.array = <factory>, windowCenter: float = '', windowWidth: float = '', temporalPositionIndex: float = '', frameAcquisitionDuration: float = '', frameReferenceDateTime: str = '')[source]
Bases:
objectThis class defines data object for a scan slice.
- imageType
Type of scan. MR SCAN, CT SCAN, PT SCAN.
- Type:
str
- patientName
Patient’s name
- Type:
str
- patientID
Patieint’s ID
- Type:
str
- patientBirthDate
Patient’s date of birth
- Type:
str
- CTOffset
Offset to add to scanArray to get image in scanUnits (e.g. HU). This is required so as to store only (+)ve values in scanArray.
- Type:
float
- rescaleSlope
m in the equation Output units = m*SV + b. Slope to transform image from storage to real world units as per (0028,1053) tag.
- Type:
float
- rescaleIntercept
b in the equation Output units = m*SV + b. Read from (0028,1052) tag
- Type:
float
- rescaleType
Specifies the output units of Rescale Slope (0028,1053) and Rescale Intercept (0028,1052)
- Type:
str
- scaleSlope
Private tag (2005,100E) used for conversion to MR precise values
- Type:
float
- scaleIntercept
Private tag (2005,100D)
- Type:
float
- realWorldValueSlope
The Slope value in relationship between stored values (SV) and the Real World Values as per (0040,9225) tag.
- Type:
float
- realWorldValueIntercept
The Intercept value in relationship between stored values (SV) and the Real World values as per (0040,9224) tag.
- Type:
float
- realWorldMeasurCodeMeaning
Real World code value as per (0008,0100) tag
- Type:
str
- philipsImageUnits
Private tag containing image units as per (2005,140B)
- Type:
str
- philipsRescaleSlope
Private tag containing rescale slope as per (2005,140A)
- Type:
float
- philipsRescaleIntercept
Private tag containing rescale intercept as per (2005,1409)
- Type:
float
- grid1Units
delta y of the scan grid in CERR virtual coordinates
- Type:
float
- grid2Units
delta x of the scan grid in CERR virtual coordinates
- Type:
float
- bitsAllocated
Number of bits allocated for each pixel sample as per (0028,0100)
- Type:
int
- bitsStored
Number of bits stored for each pixel sample as per (0028,0101)
- Type:
int
- pixelRepresentation
Data representation of the pixel samples as per (0028,0103) 0000H - unsigned integer, 0001H - 2’s complement
- Type:
int
- numberOfDimensions
Number of scan dimensions
- Type:
int
- sizeOfDimension1
Number of rows of scanArray
- Type:
int
- sizeOfDimension2
Number of columns of scanArray
- Type:
int
- zValue
z-coordinate of the slice in CERR virtual coordinate system
- Type:
float
- xOffset
x-offset of the center of scanArray in CERR virtual coordinates
- Type:
float
- yOffset
y-offset of the center of scanArray in CERR virtual coordinates
- Type:
float
- sliceThickness
Nominal slice thickness as per (0018,0050).
- Type:
float
- voxelThickness
Physical spacing between the next and the previous slice in CERR virtual coordinates.
- Type:
float
- seriesDescription
Series description as per (0008,103E)
- Type:
str
- studyDescription
Study description as per (0008,1030)
- Type:
str
- scannerType
Manufacturer model name
- Type:
str
- manufacturer
Scanner Mmanufacturer
- Type:
str
- scanFileName
Location of DICOM file from which metadata was read
- Type:
str
- bValue
b-value of MR scan
- Type:
float
- acquisitionDate
Acquisition date
- Type:
str
- acquisitionTime
Acquisition time
- Type:
str
- patientWeight
Patient’s weight
- Type:
float
- patientSize
Patient’s size
- Type:
float
- patientBmi
Patient’s BMI
- Type:
float
- patientSex
Patient’s gender
- Type:
str
- injectionTime
The actual time of radiopharmaceutical administration to the patient for imaging purposes.
- Type:
str
- injectionDate
The actual date of radiopharmaceutical administration to the patient for imaging purposes.
- Type:
str
- injectedDose
The radiopharmaceutical dose administered to the patient measured in MegaBecquerels (MBq) at the Radiopharmaceutical Start DateTime (0018,1078).
- Type:
float
- halfLife
The radionuclide half life, in seconds, that was used in the correction of this image.
- Type:
float
- imageUnits
realWorldMeasurCodeMeaning when available or rescaleType.
- Type:
str
- suvType
The type of SUV stored in scanArray as per (0054,1006) tag.
- Type:
str
- petCountSource
The primary source of counts as per (0054,1002). EMISSION or TRANSMISSION
- Type:
str
- petSeriesType
A multi-valued indicator of the type of Series as per (0054,1000).
- Type:
str
- petActivityConctrScaleFactor
Used to convert the pixel data from counts to Activity Concentration (in Bq/ml) as per (7053, 1009 tag
- Type:
float
- petNumSlices
The number of slices in each separate volume as per (0054,0081)
- Type:
int
- petDecayCorrectionDateTime
The date and time to which all frames in this Image were decay corrected as per (0018,9701)
- Type:
str
- decayCorrection
Whether Decay (DECY) correction has been applied to image. YES or NO.
- Type:
float
- correctedImage
One or more values that indicate which, if any, corrections have been applied to the image as per (0028,0051)
- Type:
float
- seriesDate
Series date
- Type:
str
- seriesTime
Series yime
- Type:
str
- studyDate
Study date
- Type:
str
- studyTime
Study time
- Type:
str
- studyInstanceUID
Study Instance UID
- Type:
str
- seriesInstanceUID
Series Instance UID of image volume
- Type:
str
- sopInstanceUID
SOP Instance UID of image frame
- Type:
str
- sopClassUID
SOP Class UID of image frame
- Type:
str
- frameOfReferenceUID
Frame of Reference UID
- Type:
str
- imageOrientationPatient
Direction cosine of dose row and column with patient coordinate system.
- Type:
np.array
- imagePositionPatient
x,y,z coordinate of the top left voxel of the scan volume.
- Type:
np.array
- windowCenter
Window center used for visualization
- Type:
float
- windowWidth
Window width used for visualization
- Type:
float
- temporalPositionIndex
Temporal position in the dynamic sequence from the FrameContentSequence.
- Type:
float
- frameAcquisitionDuration
Duration of Frame acquisition from the FrameContentSequence.
- Type:
float
- frameReferenceDateTime
FrameReferenceDateTime from the FrameContentSequence
- Type:
str
cerr.dataclasses.structure module
structure module.
Ths structure module defines metadata for segmentation (RTSTRUCT, SEG). The metadata are attributes of the Structre class. This module also defines routines for transforming and accessing the Structure metadata in CERR coordinate system and to convert images to real world units.
- class cerr.dataclasses.structure.Structure(roiNumber: int = 0, patientName: str = '', structureName: str = '', ROIInterpretedType: str = '', structureFormat: str = '', numberOfScans: int = 0, maximumNumberScans: int = 0, maximumPointsPerSegment: int = 0, maximumSegmentsPerScan: int = 0, structureEdition: str = '', writer: str = '', dateWritten: str = '', structureColor: ~typing.List = <factory>, structureDescription: str = '', roiGenerationAlgorithm: str = '', roiGenerationDescription: str = '', studyNumberOfOrigin: str = '', contour: ~typing.List = <factory>, rasterSegments: ~numpy.ndarray = <factory>, DSHPoints: ~numpy.ndarray = <factory>, orientationOfStructure: str = '', transferProtocol: str = '', visible: bool = True, strUID: str = '', assocScanUID: str = '', structSetSopInstanceUID: str = '', rasterized: bool = False, referencedFrameOfReferenceUID: str = '', referencedSeriesUID: str = '', structureFileFormat: str = '')[source]
Bases:
objectThis class defines data object for volumetric segmentation. The metadata can be populated from DICOM, NifTi and numpy arrays.
- patientName
Patient’s name.
- Type:
str
- structureName
Structure’s name.
- Type:
str
- ROIInterpretedType
maps to DICOM tag (3006,00A4).
- Type:
str
- numberOfScans
Number of scan slices containing segmentation.
- Type:
int
- dateWritten
Date structure was created. Corresponds to DICOM tag (3006,0008) StructureSetDate.
- Type:
str
- structureColor
rgb triplet representing the color for this structure
- Type:
List
- structureDescription
Description of the structure. DICOM SeriesDescription.
- Type:
str
- roiGenerationAlgorithm
Permitted values are AUTOMATIC, SEMIAUTOMATIC and MANUAL
- Type:
str) = Type of algorithm used to generate ROI. DICOM tag (3006,0036
- roiGenerationDescription
User-defined description of technique used to generate ROI. DICOM tag (3006,0038).
- Type:
str
- contour
List of contours including segmentation x,y,z CERR virtual coordinates per scan slice. The ith entry in the list corresponds to the ith slice of the associated scanArray.
- Type:
List
- rasterSegments
Numpy array of size numSegments x 10. The columns of this array are z-value, y-value, x segment start, x segment stop, x increment, slice, row, column start, column stop, voxel thickness for that slice. Each row represents a scan segment.
- Type:
np.ndarray
- strUID
unique identifier for structure object
- Type:
str
- assocScanUID
unique identifier for the scan associated with the structure object.
- Type:
str
- structSetSopInstanceUID
str = “”
- Type:
str
- referencedFrameOfReferenceUID
UID for frame of reference
- Type:
str
- referencedSeriesUID
UID of structure series i.e. DICOM SeriesInstanceUID
- Type:
str
- structureFileFormat
File format from which structure’s metadata was populated. Permitted values are “RTSTRUCT”, “NPARRAY”, “NIFTI”.
- Type:
str
- saveNii(niiFileName, planC)[source]
Routine to save pyCERR Structure object to NifTi file
- Parameters:
niiFileName (str) – File name including the full path to save the pyCERR scan object to NifTi file.
planC (cerr.plan_container.PlanC) – pyCERR plan container object.
- Returns:
0 when NifTi file is written successfully.
- Return type:
int
- convertDcmToCerrVirtualCoords(planC)[source]
Routine to convert x,y,z coordinates of segmentation from DICOM to pyCERR virtual coordinates. More information about virtual coordinates is on the Wiki https://github.com/cerr/pyCERR/wiki/Coordinate-system
- getStructureAssociatedScan(planC)[source]
- Parameters:
planC (cerr.plan_container.PlanC) – pyCERR’s plan container object
- Returns:
- associated scan index for structure object based on the scan UID associated with
the structure.
- Return type:
int
- class cerr.dataclasses.structure.Contour(referencedSopInstanceUID: str = '', referencedSopClassUID: str = '', segments: ~numpy.array = <factory>)[source]
Bases:
objectThis class defines data object for storing segmented contours. The metadata can be populated from DICOM, NifTi and numpy arrays.
- referencedSopInstanceUID
Instance UID of associated image slice.
- Type:
str
- referencedSopClassUID
Class UID of associated image slice.
- Type:
str
- segments
array of segments.
- Type:
np.array
- class cerr.dataclasses.structure.Segment(points: ~numpy.ndarray = <factory>)[source]
Bases:
objectThis class defines data object for storing contour segments.
- points
(n X 3) array containing x,y,z coordinates of the segment in pyCERR virtual coordinate system.
- Type:
numpy.ndarray
- cerr.dataclasses.structure.saveJson(structNumV, jsonFileName, planC)[source]
- Parameters:
structNumV (List) – List of structure indices to export to JSON format.
jsonFileName (str) – JSON file name.
planC (cerr.plan_container.PlanC) – pyCERR’s plan container object
- Returns:
None
- cerr.dataclasses.structure.importJson(planC, strList=None, jsonFileName=None)[source]
- Parameters:
planC (cerr.plan_container.PlanC) – pyCERR’s plan container object.
strList (list of structures) – (optional) list of structure metadata imported from json. Required when jsonFileName is None.
jsonFileName – (optional) JSON file name containing structure metadata. Required when strList is None.
- Returns:
pyCERR’s plan container object.
- Return type:
- cerr.dataclasses.structure.parseContours(contour_seq)[source]
This routine parses the ContourSequence metadata from DICOM and returns a list of pyCERR Contour objects.
- Parameters:
contour_seq (pydicom.dataset.Dataset) – Pydicom Dataset object for ContourSequence, DICOM tag (3006,0040).
- Returns:
list of pyCERR Contour objects
- Return type:
- cerr.dataclasses.structure.loadStructure(file_list)[source]
This routine parses a list of DICOM files and imports metadata from RTSTRUCT and SEG modalities to a list of pyCERR’s Structure objects .
- Parameters:
file_list (List[str]) – List of DICOM file paths.
- Returns:
List of pyCERR’s Structure objects.
- Return type:
- cerr.dataclasses.structure.importNii(file_list, assocScanNum, planC, labels_dict={})[source]
This routine imports segmentation from a list of nii files into planC.
- Parameters:
file_list (List or str) – List of nii file paths or a string containing path for a single file.
assocScanNum (int) – index of scan in planC to associate the segmentation.
planC (cerr.plan_container.PlanC) – pyCERR’s plan container object.
labels_dict (dict) – dictionary of index to structure name mapping. e.g. {1: ‘GTV’, 2: ‘Lung_total’}
- Returns:
pyCERR’s plan container object
- Return type:
- cerr.dataclasses.structure.importStructureMask(mask3M, assocScanNum, structName, planC, structNum=None)[source]
- Parameters:
mask3M (np.ndarray) – binary mask for segmentation which is of the same shape as the associated scan
assocScanNum (int) – index of scan object within planC.scan to associate the structure
structName (str) – Name of the structure
planC (cerr.plan_container.PlanC) – pyCERR’s container object
structNum (int or None) – optional, index of structure object within planC.structure to replace
- Returns:
pyCERR’s container object with updated planC.structure attribute
- Return type:
- cerr.dataclasses.structure.getColorForStructNum(structNum)[source]
This routine returns the rgb color triplet to assign to a new structure object.
- Parameters:
structNum (int) – index of structure object in planC.structure
- Returns:
rgb triplet
- Return type:
List
- cerr.dataclasses.structure.copyToScan(structNum, scanNum, planC)[source]
This routine copies structure object at index structNum to scan objact at index scanNum in planC.scan.
- Parameters:
structNum (int) – index of structure object in planC.structure
scanNum (int) – index of scan object in planC.scan
planC (cerr.plan_container.PlanC) – pyCERR’s planc ontainer object
- Returns:
updated planC with new planC.structure element associated with scanNum
- Return type:
- cerr.dataclasses.structure.getStructNumFromUID(assocStrUID, planC) int[source]
This routine returns the index of the planC.structure element corresponding to the input pyCERR’s structure UID
- Parameters:
assocStrUID (str) – UID of the structure object
planC (cerr.plan_container.PlanC) – pyCERR’s plan container object
- Returns:
- Index of the planC.structure element corresponding to the input UID
None when there is no matching element in planC.structure corresponding to the input UID.
- Return type:
int
- cerr.dataclasses.structure.getStructNumFromSOPInstanceUID(assocStrUID, planC) int[source]
This routine returns the index of the planC.structure element corresponding to the input SOP Instance UID
- Parameters:
assocStrUID (str) – SOP Instance UID of the structure object
planC (cerr.plan_container.PlanC) – pyCERR’s plan container object
- Returns:
- Index of the planC.structure element corresponding to the input UID
None when there is no matching element in planC.structure corresponding to the input SOP Instance UID.
- Return type:
int
- cerr.dataclasses.structure.calcIsocenter(strNum, planC)[source]
This routine calculates the isocenter of the input structure index in planC.structure
- Parameters:
strNum (int) – Index of structure object in planC.structure
planC (cerr.plan_container.PlanC) – pyCERR’s plan container
- Returns:
x,y,z coordinates in pyCERR’s virtual coordinate system for the isocenter.
- Return type:
List
- cerr.dataclasses.structure.getMatchingIndex(structName, strList, matchCriteria='exact')[source]
This routine returns the index of element/s from the list of structure names that match the input name.
- Parameters:
structName (str) – Structure name to find a match
strList – List of structure names
matchCriteria – Criteria used to find the match ‘EXACT’ - returns indices of exact matches ‘FIRSTCHARS’ - returns indices where first characters of elements in the list match input structName
- Returns:
list of matching indices from input strList
- Return type:
List
- cerr.dataclasses.structure.getContourPolygons(strNum, planC, rcsFlag=False)[source]
This routine returns the list of polygonal coordinates for all the segments of input structutre.
- Parameters:
strNum (int) – index of structure element in planC.structure
planC (cerr.plan_container.PlanC) – pyCERR’s plan container object
rcsFlag (bool) – optional, flag to return polygonal coordinates in row,col,slc units. By default, the polygonal coordinates are returned in physical units of cm.
- Returns:
- list of nx3 arrays corresponding to polygonal segments, where n is the number of points in that segment,
the columns of each array are x,y,z coordinates in physical units of cm or r,c,s units.
- Return type:
list
- cerr.dataclasses.structure.getClosedMask(structNum, structuringElementSizeCm, planC, saveFlag=False, replaceFlag=None, procSructName=None)[source]
Function for morphological closing and hole-filling for binary masks
- Parameters:
structNum – int for index of structure in planC.
structuringElementSizeCm – float for size of structuring element for closing in cm
planC – pyCERR plan container object.
saveFlag – [optional, default=False] bool flag for saving processed mask to planC.
replaceFlag – [optional, default=False] bool flag for replacing input mask with processed mask in planC.
procSructName – [optional, default=None] string for output structure name. Original structure name is used if None.
- Returns:
np.ndarray(dtype=bool) for filled mask. planC: pyCERR plan container object.
- Return type:
filledMask3M
- cerr.dataclasses.structure.getLargestConnComps(structNum, numConnComponents, planC=None, saveFlag=None, replaceFlag=None, procSructName=None)[source]
Function to retain ‘N’ largest connected components in input binary mask
- Parameters:
structNum – int for index of structure in planC (OR) np.ndarray(dtype=bool) 3D binary mask.
structuringElementSizeCm – float for desired size of structuring element for morphological closing in cm.
planC – [optional, default=None] pyCERR plan container object.
saveFlag – [optional, default=False] bool flag for importing filtered mask to planC if set to True.
replaceFlag – [optional, default=False] bool flag for replacing input mask with processed mask to planC if set to True.
procSructName – [optional, default=None] string for output structure name. Original structure name is used if empty.
- Returns:
np.ndarray(dtype=bool) filtered binary mask. planC: pyCERR plan container object.
- Return type:
maskOut3M
- cerr.dataclasses.structure.getLabelMap(strNumV, planC, labelDict=None, dim=3)[source]
Function to create label map for user-specified structures.
- Parameters:
strNumV (list) – Structure indices to be exported.
planC (plan_container.planC) – pyCERR plan_container object.
labelDict (dict) – [optional, default={}] dictionary mapping indices with structure names.
dim (int) – [optional, default=3] int indicating dimensions of output label map. When set to 3, returns 3D label map np.array(dtype=int). When set to 4, returns 4D array of binary masks (required for overlapping structures).
- Returns:
np.ndarray(dtype=int) for label map.
- Return type:
labelMap3M
- cerr.dataclasses.structure.getMaskList(strNumV, planC, labelDict=None)[source]
Function to create list of binary masks of user-specified structures.
- Parameters:
strNumV – list of structure indices to be exported.
planC – pyCERR plan_container object.
labelDict – [optional, default={}] dictionary mapping indices with structure names.
- Returns:
list(dtype=bool) of binary masks.
- Return type:
maskList