fix(RT) : Make ContourImageSequence check under ROIContourSequence->ContourImageSequence optional (#3476)

This commit is contained in:
dxlin 2023-06-19 09:01:23 -04:00 committed by GitHub
parent 652e61a417
commit e6f73a2025
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 41 deletions

View File

@ -181,12 +181,6 @@ export default async function loadRTStruct(
ContourGeometricType, ContourGeometricType,
} = ContourSequenceArray[c]; } = ContourSequenceArray[c];
const sopInstanceUID = ContourImageSequence.ReferencedSOPInstanceUID;
const imageId = _getImageId(imageIdSopInstanceUidPairs, sopInstanceUID);
if (!imageId) {
continue;
}
let isSupported = false; let isSupported = false;
const points = []; const points = [];

View File

@ -816,45 +816,54 @@ class SegmentationService extends PubSubService {
const segmentsCachedStats = {}; const segmentsCachedStats = {};
const initializeContour = async rtStructData => { const initializeContour = async rtStructData => {
const { data, id, color, segmentIndex, geometryId } = rtStructData; const { data, id, color, segmentIndex, geometryId } = rtStructData;
const geometry = await geometryLoader.createAndCacheGeometry(geometryId, {
geometryData: { // catch error instead of failing to allow loading to continue
data, try {
id, const geometry = await geometryLoader.createAndCacheGeometry(
color, geometryId,
frameOfReferenceUID: structureSet.frameOfReferenceUID, {
geometryData: {
data,
id,
color,
frameOfReferenceUID: structureSet.frameOfReferenceUID,
segmentIndex,
},
type: csEnums.GeometryType.CONTOUR,
}
);
const contourSet = geometry.data;
const centroid = contourSet.getCentroid();
segmentsCachedStats[segmentIndex] = {
center: { world: centroid },
modifiedTime: rtDisplaySet.SeriesDate, // we use the SeriesDate as the modifiedTime since this is the first time we are creating the segmentation
};
segmentation.segments[segmentIndex] = {
label: id,
segmentIndex, segmentIndex,
}, color,
type: csEnums.GeometryType.CONTOUR, ...SEGMENT_CONSTANT,
}); };
const contourSet = geometry.data; const numInitialized = Object.keys(segmentsCachedStats).length;
const centroid = contourSet.getCentroid();
segmentsCachedStats[segmentIndex] = { // Calculate percentage completed
center: { world: centroid }, const percentComplete = Math.round(
modifiedTime: rtDisplaySet.SeriesDate, // we use the SeriesDate as the modifiedTime since this is the first time we are creating the segmentation (numInitialized / allRTStructData.length) * 100
}; );
segmentation.segments[segmentIndex] = { this._broadcastEvent(EVENTS.SEGMENT_LOADING_COMPLETE, {
label: id, percentComplete,
segmentIndex, // Note: this is not the geometryIds length since there might be
color, // some missing ROINumbers
...SEGMENT_CONSTANT, numSegments: allRTStructData.length,
}; });
} catch (e) {
const numInitialized = Object.keys(segmentsCachedStats).length; console.warn(e);
}
// Calculate percentage completed
const percentComplete = Math.round(
(numInitialized / allRTStructData.length) * 100
);
this._broadcastEvent(EVENTS.SEGMENT_LOADING_COMPLETE, {
percentComplete,
// Note: this is not the geometryIds length since there might be
// some missing ROINumbers
numSegments: allRTStructData.length,
});
}; };
const promiseArray = []; const promiseArray = [];