Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | import getDicomWebClient from './dicomWebClient'; /** * Loads and displays DICOM Microscopy Bulk Simple Annotations. * * This utility function: * 1. Retrieves series metadata from a DICOMweb server using study and series instance UIDs * 2. Converts metadata into MicroscopyBulkSimpleAnnotations objects * 3. Adds annotations to the viewer in groups (identified by AnnotationGroupUID) * 4. Applies a consistent yellow color ([255, 234, 0]) to all annotation groups * 5. Makes the annotation groups visible in the viewer * * @param {Object} params - The parameters object * @param {Object} params.microscopyService - Service for handling microscopy operations * @param {Object} params.displaySet - The display set containing metadata * @param {Object} params.extensionManager - Manager for extensions * @param {Object} params.servicesManager - Manager for services * @returns {Promise} A promise that resolves with the loaded display set */ export default function loadAnnotation({ microscopyService, displaySet, extensionManager, servicesManager, }) { const { uiNotificationService } = servicesManager.services; return new Promise(async (resolve, reject) => { try { displaySet.isLoading = true; const { metadata } = displaySet; const dicomMicroscopyModule = await microscopyService.importDicomMicroscopyViewer(); const client = getDicomWebClient({ extensionManager, servicesManager, }); const viewportId = servicesManager.services.viewportGridService.getActiveViewportId(); const managedViewers = microscopyService.getManagedViewersForViewport(viewportId); const managedViewer = managedViewers[0]; client .retrieveSeriesMetadata({ studyInstanceUID: metadata.StudyInstanceUID, seriesInstanceUID: metadata.SeriesInstanceUID, }) .then(async retrievedMetadata => { const annotations = retrievedMetadata.map( metadata => new dicomMicroscopyModule.metadata.MicroscopyBulkSimpleAnnotations({ metadata }) ); uiNotificationService.show({ message: 'Loading annotations...', type: 'info', }); await Promise.all( annotations.map(async ann => { try { await managedViewer.viewer.addAnnotationGroups(ann); ann.AnnotationGroupSequence.forEach(item => { const annotationGroupUID = item.AnnotationGroupUID; managedViewer.viewer.setAnnotationGroupStyle(annotationGroupUID, { color: [255, 234, 0], }); }); ann.AnnotationGroupSequence.forEach(item => { const annotationGroupUID = item.AnnotationGroupUID; managedViewer.viewer.showAnnotationGroup(annotationGroupUID); }); } catch (error) { console.error('failed to add annotation groups:', error); uiNotificationService.show({ title: 'Error loading annotations', message: error.message, type: 'error', }); } }) ); displaySet.isLoaded = true; displaySet.isLoading = false; resolve(displaySet); }); } catch (error) { console.error('Error loading annotation:', error); reject(error); } }); } |