* skeleton for dicom-microscopy extension * skeleton for microscopy mode * [feat] ported @radicalimaging/microscopy-dicom to OHIF's default extension * [feat] ported microscopy mode from private repo * added new definitions to the package.json * webpack configuration update for microscopy extension * register new icons for microscopy tools * fixes to the microscopy extension and mode * trivial error fix - typescript type import error * link microscopy extension with default OHIF app plugin config * demo config fix * fix logs * remove unsed imports * [fix] loading of microscopy * [fix] webworker script loading, normalizing denaturalized dataset * found the latest version of dicom-microscopy-viewer that works with current OHIF extension : 0.35.2 * hide thumbnail pane by default, as we have issues with * comments * remove unused code * [feat] microscopy - annotation selection * [feat] microscopy - edit annotation label * wip * [bugfix] dicom-microscopy tool * [bugfix] dicom microscopy annotations * [fix] mixed-content blocking caused by BulkDataURI * [fix] microscopy measurements panel - center button * [fix] microscopy measurements panel - styling * [fix] microscopy - controls * fix local loading of microscopy * fix local loading of dicom microscopy * fix typo - indexof to indexOf * [fix] remove unused icons * remove commented out lines from webpack configuration * platform/viewer/public/config/default.js - revert accidental changes * [refactor] redirecting to microscopy mode on Local mode * attribution to DMV and SLIM viewer * [fix] code review feedbacks * fix thumbnails * [fix] microscopy - fix old publisher.publish() to PubSubService._broadcastEvent() * [fix] interactions, webpack config, roi selection * [feat] microscopy - remove select tool from UI * microscopy author * [fix] saving and loading SR * [bugfix] - missing publish() function in MicroscopyService, replace with _broadcastEvent * remove author section from readme * refactor SR saving feature * fix webpack config after merge * [bugfix] repeated import * fix e2e * webpack configuration * hide "Create report" button for microscopy
144 lines
3.9 KiB
JavaScript
144 lines
3.9 KiB
JavaScript
import OHIF, { DicomMetadataStore } from '@ohif/core';
|
|
import loadSR from './utils/loadSR';
|
|
import toArray from './utils/toArray';
|
|
import DCM_CODE_VALUES from './utils/dcmCodeValues';
|
|
import getSourceDisplaySet from './utils/getSourceDisplaySet';
|
|
|
|
const { utils } = OHIF;
|
|
|
|
const SOP_CLASS_UIDS = {
|
|
COMPREHENSIVE_3D_SR: '1.2.840.10008.5.1.4.1.1.88.34',
|
|
};
|
|
|
|
const SOPClassHandlerId =
|
|
'@ohif/extension-dicom-microscopy.sopClassHandlerModule.DicomMicroscopySRSopClassHandler';
|
|
|
|
function _getReferencedFrameOfReferenceUID(naturalizedDataset) {
|
|
const { ContentSequence } = naturalizedDataset;
|
|
|
|
const imagingMeasurementsContentItem = ContentSequence.find(
|
|
ci =>
|
|
ci.ConceptNameCodeSequence.CodeValue ===
|
|
DCM_CODE_VALUES.IMAGING_MEASUREMENTS
|
|
);
|
|
|
|
const firstMeasurementGroupContentItem = toArray(
|
|
imagingMeasurementsContentItem.ContentSequence
|
|
).find(
|
|
ci =>
|
|
ci.ConceptNameCodeSequence.CodeValue === DCM_CODE_VALUES.MEASUREMENT_GROUP
|
|
);
|
|
|
|
const imageRegionContentItem = toArray(
|
|
firstMeasurementGroupContentItem.ContentSequence
|
|
).find(
|
|
ci => ci.ConceptNameCodeSequence.CodeValue === DCM_CODE_VALUES.IMAGE_REGION
|
|
);
|
|
|
|
return imageRegionContentItem.ReferencedFrameOfReferenceUID;
|
|
}
|
|
|
|
function _getDisplaySetsFromSeries(
|
|
instances,
|
|
servicesManager,
|
|
extensionManager
|
|
) {
|
|
// If the series has no instances, stop here
|
|
if (!instances || !instances.length) {
|
|
throw new Error('No instances were provided');
|
|
}
|
|
|
|
const { displaySetService, microscopyService } = servicesManager.services;
|
|
|
|
const instance = instances[0];
|
|
|
|
// TODO ! Consumption of DICOMMicroscopySRSOPClassHandler to a derived dataset or normal dataset?
|
|
// TOOD -> Easy to swap this to a "non-derived" displaySet, but unfortunately need to put it in a different extension.
|
|
const naturalizedDataset = DicomMetadataStore.getSeries(
|
|
instance.StudyInstanceUID,
|
|
instance.SeriesInstanceUID
|
|
).instances[0];
|
|
const ReferencedFrameOfReferenceUID = _getReferencedFrameOfReferenceUID(
|
|
naturalizedDataset
|
|
);
|
|
|
|
const {
|
|
FrameOfReferenceUID,
|
|
SeriesDescription,
|
|
ContentDate,
|
|
ContentTime,
|
|
SeriesNumber,
|
|
StudyInstanceUID,
|
|
SeriesInstanceUID,
|
|
SOPInstanceUID,
|
|
SOPClassUID,
|
|
} = instance;
|
|
|
|
const displaySet = {
|
|
plugin: 'microscopy',
|
|
Modality: 'SR',
|
|
altImageText: 'Microscopy SR',
|
|
displaySetInstanceUID: utils.guid(),
|
|
SOPInstanceUID,
|
|
SeriesInstanceUID,
|
|
StudyInstanceUID,
|
|
ReferencedFrameOfReferenceUID,
|
|
SOPClassHandlerId,
|
|
SOPClassUID,
|
|
SeriesDescription,
|
|
// Map the content date/time to the series date/time, these are only used for filtering.
|
|
SeriesDate: ContentDate,
|
|
SeriesTime: ContentTime,
|
|
SeriesNumber,
|
|
instance,
|
|
metadata: naturalizedDataset,
|
|
isDerived: true,
|
|
isLoading: false,
|
|
isLoaded: false,
|
|
loadError: false,
|
|
};
|
|
|
|
displaySet.load = function(referencedDisplaySet) {
|
|
return loadSR(microscopyService, displaySet, referencedDisplaySet).catch(
|
|
error => {
|
|
displaySet.isLoaded = false;
|
|
displaySet.loadError = true;
|
|
throw new Error(error);
|
|
}
|
|
);
|
|
};
|
|
|
|
displaySet.getSourceDisplaySet = function() {
|
|
let allDisplaySets = [];
|
|
const studyMetadata = DicomMetadataStore.getStudy(StudyInstanceUID);
|
|
studyMetadata.series.forEach(series => {
|
|
const displaySets = displaySetService.getDisplaySetsForSeries(
|
|
series.SeriesInstanceUID
|
|
);
|
|
allDisplaySets = allDisplaySets.concat(displaySets);
|
|
});
|
|
return getSourceDisplaySet(allDisplaySets, displaySet);
|
|
};
|
|
|
|
return [displaySet];
|
|
}
|
|
|
|
export default function getDicomMicroscopySRSopClassHandler({
|
|
servicesManager,
|
|
extensionManager,
|
|
}) {
|
|
const getDisplaySetsFromSeries = instances => {
|
|
return _getDisplaySetsFromSeries(
|
|
instances,
|
|
servicesManager,
|
|
extensionManager
|
|
);
|
|
};
|
|
|
|
return {
|
|
name: 'DicomMicroscopySRSopClassHandler',
|
|
sopClassUids: [SOP_CLASS_UIDS.COMPREHENSIVE_3D_SR],
|
|
getDisplaySetsFromSeries,
|
|
};
|
|
}
|