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 | 128x 128x 16x 16x 16x 386821x 2200x 2200x | import imageIdToURI from './imageIdToURI';
import type { IImageCalibration } from '../types/IImageCalibration';
import { MetadataModules } from '../enums';
import { clearQuery } from '../metaData';
/** Calibrated pixel spacing per imageId */
const state = new Map<string, IImageCalibration>();
/**
* Simple metadataProvider object to store metadata for calibrated spacings.
* This can be added via cornerstone.metaData.addProvider(...) in order to store
* and return calibrated pixel spacings when metaData type is "calibratedPixelSpacing".
*/
const metadataProvider = {
/**
* Adds metadata for an imageId.
* @param imageId - the imageId for the metadata to store
* @param payload - the payload composed of new calibrated pixel spacings
*/
add: (imageId: string, payload: IImageCalibration): void => {
const imageURI = imageIdToURI(imageId);
state.set(imageURI, payload);
clearQuery(MetadataModules.IMAGE_PLANE, imageId);
},
/**
* Returns the metadata for an imageId if it exists.
* @param type - the type of metadata to enquire about
* @param imageId - the imageId to enquire about
* @returns the calibrated pixel spacings for the imageId if it exists, otherwise undefined
*/
get: (type: string, imageId: string): IImageCalibration => {
if (type === 'calibratedPixelSpacing') {
const imageURI = imageIdToURI(imageId);
return state.get(imageURI);
}
},
clear: () => {
state.clear();
},
};
export default metadataProvider;
|