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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | 428x 428x 38445x 38445x 38445x 38445x 38445x 31982x 31982x 31982x 31982x 31982x 31982x 31982x 31982x 262564x 262564x 262564x 255525x 7039x 7039x 576x 6463x 6463x 4083x 2380x 2380x 2380x 2380x 2380x | import type { WADORSMetaData } from '../../types'; import imageIdToURI from '../imageIdToURI'; import { combineFrameInstance } from './combineFrameInstance'; let metadataByImageURI = []; let multiframeMetadataByImageURI = {}; import getValue from './metaData/getValue'; // get metadata information for the first frame function _retrieveMultiframeMetadataImageURI(imageURI) { const lastSlashIdx = imageURI.indexOf('/frames/') + 8; // imageid string without frame number const imageIdFrameless = imageURI.slice(0, lastSlashIdx); // calculating frame number const frame = parseInt(imageURI.slice(lastSlashIdx), 10); // retrieving the frame 1 that contains multiframe information const metadata = metadataByImageURI[`${imageIdFrameless}1`]; return { metadata, frame, }; } function retrieveMultiframeMetadataImageId(imageId) { const imageURI = imageIdToURI(imageId); return _retrieveMultiframeMetadataImageURI(imageURI); } function isMultiframe(metadata) { // test for presence of Shared Functional Groups Sequence or Per-Frame Functional Groups Sequence Iif ( metadata['52009230'] !== undefined || metadata['52009229'] !== undefined ) { return true; } // Checks if dicomTag NumberOf Frames exists and it is greater than one const numberOfFrames = getValue<number>(metadata['00280008']); return numberOfFrames && numberOfFrames > 1; } function add(imageId: string, metadata: WADORSMetaData) { const imageURI = imageIdToURI(imageId); Object.defineProperty(metadata, 'isMultiframe', { value: isMultiframe(metadata), enumerable: false, }); metadataByImageURI[imageURI] = metadata; } // multiframes images will have only one imageId returned by the dicomweb // client and registered in metadataByImageURI for all the n frames. If an // imageId does not have metadata, or it does not have at all, or the imageID // belongs to a frame, not registered in metadataByImageURI function get(imageId: string): WADORSMetaData { const imageURI = imageIdToURI(imageId); // Check if the metadata is already available const metadata = metadataByImageURI[imageURI]; if (metadata && !metadata?.isMultiframe) { // Return the metadata for single-frame images return metadata; } const cachedMetadata = multiframeMetadataByImageURI[imageURI]; if (cachedMetadata) { return cachedMetadata; } // Try to get the metadata for a specific frame of a multiframe image const retrievedMetadata = _retrieveMultiframeMetadataImageURI(imageURI); if (!retrievedMetadata || !retrievedMetadata.metadata) { return; } const { metadata: firstFrameMetadata, frame } = retrievedMetadata; Eif (firstFrameMetadata) { // Combine the metadata from the first frame with the metadata from the specified frame const combined = combineFrameInstance(frame, firstFrameMetadata); multiframeMetadataByImageURI[imageURI] = combined; return combined; } } function remove(imageId) { const imageURI = imageIdToURI(imageId); metadataByImageURI[imageURI] = undefined; multiframeMetadataByImageURI[imageURI] = undefined; } function purge() { metadataByImageURI = []; multiframeMetadataByImageURI = {}; } export { metadataByImageURI, isMultiframe, retrieveMultiframeMetadataImageId }; export default { add, get, remove, purge, }; |