Editing Structures - cerr/CERR GitHub Wiki
Editing structures programmatically
Structures are stored in the planC cell array and can be accessed as follows:
global planC
indexS = planC{end};
structureNum = 1;
planC{indexS.structures}(structureNum)
imageNumber: ''
imageType: 'STRUCTURE'
caseNumber: ''
roiNumber: 1
patientName: 'HALLIGAN^LUKE^'
structureName: 'External'
ROIInterpretedType: ''
numberRepresentation: 'CHARACTER'
structureFormat: 'SCAN-BASED'
numberOfScans: 127
maximumNumberScans: ''
maximumPointsPerSegment: ''
maximumSegmentsPerScan: ''
structureEdition: ''
unitNumber: ''
writer: 'Varian Medical Systems'
dateWritten: '20141021'
structureColor: [0.9000 0.6300 0]
structureDescription: ''
studyNumberOfOrigin: ''
contour: [127x1 struct]
rasterSegments: [31006x10 double]
DSHPoints: ''
orientationOfStructure: 'TRANSVERSE'
transferProtocol: 'DICOM'
DICOMHeaders: [1x1 struct]
visible: 0
associatedScan: 1
strUID: 'RS.2252017.132626.903547.2155'
assocScanUID: 'CT.1.2.840.113704.1.111.1696.1413396965.8'
rasterized: 1
- '.contour' -
coordsM = planC{indexS.structures}(structureNum).contour(sliceNum).segments(segNum).points; `
returns a matrix coordsM containing coordinates of the points in the segment segNum on slice number sliceNum , for structure structureNum .
- '.strUID' - stores the unique identifier for structure
structureNum. Note that this field is updated anytime the user changes any data associated with this structure.
Frequently-used functions
1. Extract labels for all available structures in planC
structureListC = {planC{indexS.structures}.structureName};
2. Get index of structure in planC from its label
structureListC = {planC{indexS.strctures}.structureName};
structIdx = getMatchingIndex(lower(structName),lower(structureListC),'exact');
3. Renaming a structure
structIdx = 1; %Changes label of first structure
planC{indexS.strctures}(structIdx).structureName = 'New_name';
4. Extract binary mask (3D) of structure
structNum = 5;
mask3M = getStrMask(strNum , planC);
returns the 3D mask corresponding to structure structNum .
structNum may also be a vector of multiple structures, in which case the union of the masks of those structures is returned.
5. Extract uniformized binary mask (3D) of structure
structNum = 2;
mask3M = getUniformStr(strNum,planC);
6. Get associated scan index
structsV = [1,2,3]; %Vector of structure indices
[assocScansV, relStructNumV] = getStructureAssociatedScan(structsV, planC);
This returns a vector assocScansV with scan indices corersponding to each structure index in structsV. Correspondence is determined based on the scan UID associated with input structure numbers.
This function also returns relStructureNumV, a list of "relative" structure indices for the passed structsV. This is the index of the structure within the list of all structures associated with the same scan.
6. Convert binary mask array to planC structure
global planC
isUniform = 0;
assocScanNum = 1;
strname = 'struct1';
planC = maskToCERRStructure(mask3M, isUniform, assocScanNum, strname, planC);