Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(MetaDataProvider): Update metadata provider #1165

Merged
merged 9 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions common/reviews/api/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2437,8 +2437,12 @@ enum MetadataModules {
// (undocumented)
CINE = "cineModule",
// (undocumented)
GENERAL_IMAGE = "generalImageModule",
// (undocumented)
GENERAL_SERIES = "generalSeriesModule",
// (undocumented)
GENERAL_STUDY = "generalStudyModule",
// (undocumented)
IMAGE_PIXEL = "imagePixelModule",
// (undocumented)
IMAGE_PLANE = "imagePlaneModule",
Expand All @@ -2451,8 +2455,18 @@ enum MetadataModules {
// (undocumented)
NM_MULTIFRAME_GEOMETRY = "nmMultiframeGeometryModule",
// (undocumented)
OVERLAY_PLANE = "overlayPlaneModule",
// (undocumented)
PATIENT = "patientModule",
// (undocumented)
PATIENT_STUDY = "patientStudyModule",
// (undocumented)
PET_IMAGE = "petImageModule",
// (undocumented)
PET_ISOTOPE = "petIsotopeModule",
// (undocumented)
PET_SERIES = "petSeriesModule",
// (undocumented)
SOP_COMMON = "sopCommonModule",
// (undocumented)
ULTRASOUND_ENHANCED_REGION = "ultrasoundEnhancedRegionModule",
Expand Down
4 changes: 2 additions & 2 deletions packages/adapters/src/adapters/Cornerstone/Segmentation_4X.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,11 @@ async function generateToolState(
// we don't have to call metadataProvider.get() for each imageId over
// and over again.
const sopUIDImageIdIndexMap = imageIds.reduce((acc, imageId) => {
const { sopInstanceUid } = metadataProvider.get(
const { sopInstanceUID } = metadataProvider.get(
jlopes90 marked this conversation as resolved.
Show resolved Hide resolved
"generalImageModule",
imageId
);
acc[sopInstanceUid] = imageId;
acc[sopInstanceUID] = imageId;
return acc;
}, {});

Expand Down
23 changes: 15 additions & 8 deletions packages/core/src/enums/MetadataModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,26 @@
* with existing naming conventions)
*/
enum MetadataModules {
CALIBRATION = 'calibrationModule',
CINE = 'cineModule',
IMAGE_URL = 'imageUrlModule',
SOP_COMMON = 'sopCommonModule',
VOI_LUT = 'voiLutModule',
MODALITY_LUT = 'modalityLutModule',
GENERAL_IMAGE = 'generalImageModule',
GENERAL_SERIES = 'generalSeriesModule',
PATIENT_STUDY = 'patientStudyModule',
NM_MULTIFRAME_GEOMETRY = 'nmMultiframeGeometryModule',
IMAGE_PLANE = 'imagePlaneModule',
GENERAL_STUDY = 'generalStudyModule',
IMAGE_PIXEL = 'imagePixelModule',
IMAGE_PLANE = 'imagePlaneModule',
IMAGE_URL = 'imageUrlModule',
MODALITY_LUT = 'modalityLutModule',
MULTIFRAME = 'multiframeModule',
NM_MULTIFRAME_GEOMETRY = 'nmMultiframeGeometryModule',
OVERLAY_PLANE = 'overlayPlaneModule',
PATIENT = 'patientModule',
PATIENT_STUDY = 'patientStudyModule',
PET_IMAGE = 'petImageModule',
PET_ISOTOPE = 'petIsotopeModule',
PET_SERIES = 'petSeriesModule',
SOP_COMMON = 'sopCommonModule',
ULTRASOUND_ENHANCED_REGION = 'ultrasoundEnhancedRegionModule',
CALIBRATION = 'calibrationModule',
VOI_LUT = 'voiLutModule',
}

export default MetadataModules;
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { getUSEnhancedRegions } from './USHelpers';

function metaDataProvider(type, imageId) {
const { MetadataModules } = external.cornerstone.Enums;
const { dicomParser } = external;

if (type === MetadataModules.MULTIFRAME) {
// the get function removes the PerFrameFunctionalGroupsSequence
const { metadata, frame } =
Expand Down Expand Up @@ -57,14 +59,24 @@ function metaDataProvider(type, imageId) {
//PerFrameFunctionalGroupsSequence,
};
}
const { dicomParser } = external;

const metaData = metaDataManager.get(imageId);

if (!metaData) {
return;
}

if (type === MetadataModules.GENERAL_STUDY) {
return {
studyDescription: getValue<string>(metaData['00081030']),
studyDate: dicomParser.parseDA(getValue<string>(metaData['00080020'])),
studyTime: dicomParser.parseTM(
getValue<string>(metaData['00080030'], 0, '')
),
accessionNumber: getValue<string>(metaData['00080050']),
};
}

if (type === MetadataModules.GENERAL_SERIES) {
return {
modality: getValue<string>(metaData['00080060']),
Expand All @@ -76,15 +88,31 @@ function metaDataProvider(type, imageId) {
getValue<string>(metaData['00080031'], 0, '')
),
acquisitionDate: dicomParser.parseDA(
getValue<string>(metaData['00080022']),
''
getValue<string>(metaData['00080022'])
),
acquisitionTime: dicomParser.parseTM(
getValue<string>(metaData['00080032'], 0, '')
),
};
}

if (type === MetadataModules.GENERAL_IMAGE) {
return {
sopInstanceUID: getValue<string>(metaData['00080018']),
instanceNumber: getNumberValue(metaData['00200013']),
lossyImageCompression: getValue<string>(metaData['00282110']),
lossyImageCompressionRatio: getNumberValue(metaData['00282112']),
lossyImageCompressionMethod: getValue<string>(metaData['00282114']),
};
}

if (type === MetadataModules.PATIENT) {
return {
patientID: getValue<string>(metaData['00100020']),
patientName: getValue<string>(metaData['00100010']),
};
}

if (type === MetadataModules.PATIENT_STUDY) {
return {
patientAge: getNumberValue(metaData['00101010']),
Expand Down Expand Up @@ -165,6 +193,7 @@ function metaDataProvider(type, imageId) {
columnPixelSpacing,
};
}

if (type === MetadataModules.ULTRASOUND_ENHANCED_REGION) {
return getUSEnhancedRegions(metaData);
}
Expand All @@ -188,7 +217,7 @@ function metaDataProvider(type, imageId) {
return getCineModule(imageId, metaData);
}

if (type === 'imagePixelModule') {
if (type === MetadataModules.IMAGE_PIXEL) {
return {
samplesPerPixel: getNumberValue(metaData['00280002']),
photometricInterpretation: getValue(metaData['00280004']),
Expand Down Expand Up @@ -217,15 +246,15 @@ function metaDataProvider(type, imageId) {
};
}

if (type === 'voiLutModule') {
if (type === MetadataModules.VOI_LUT) {
return {
// TODO VOT LUT Sequence
windowCenter: getNumberValues(metaData['00281050'], 1),
windowWidth: getNumberValues(metaData['00281051'], 1),
};
}

if (type === 'modalityLutModule') {
if (type === MetadataModules.MODALITY_LUT) {
return {
// TODO VOT LUT Sequence
rescaleIntercept: getNumberValue(metaData['00281052']),
Expand All @@ -234,14 +263,14 @@ function metaDataProvider(type, imageId) {
};
}

if (type === 'sopCommonModule') {
if (type === MetadataModules.SOP_COMMON) {
return {
sopClassUID: getValue<string>(metaData['00080016']),
sopInstanceUID: getValue<string>(metaData['00080018']),
};
}

if (type === 'petIsotopeModule') {
if (type === MetadataModules.PET_ISOTOPE) {
const radiopharmaceuticalInfo = getValue(metaData['00540016']);

if (radiopharmaceuticalInfo === undefined) {
Expand All @@ -268,7 +297,7 @@ function metaDataProvider(type, imageId) {
};
}

if (type === 'overlayPlaneModule') {
if (type === MetadataModules.OVERLAY_PLANE) {
return getOverlayPlaneModule(metaData);
}

Expand All @@ -278,22 +307,22 @@ function metaDataProvider(type, imageId) {
return getTransferSyntax(imageId, metaData);
}

if (type === 'petSeriesModule') {
if (type === MetadataModules.PET_SERIES) {
return {
correctedImage: getValue(metaData['00280051']),
units: getValue(metaData['00541001']),
decayCorrection: getValue(metaData['00541102']),
};
}

if (type === 'petImageModule') {
if (type === MetadataModules.PET_IMAGE) {
return {
frameReferenceTime: getNumberValue(metaData['00541300']),
actualFrameDuration: getNumberValue(metaData['00181242']),
};
}

// This is used for gathering all the metadata for export
// Note: this is not a DICOM module, but rather an aggregation on all others
if (type === 'instance') {
return getInstanceModule(imageId, metaDataProvider, instanceModuleNames);
}
Expand Down Expand Up @@ -334,4 +363,5 @@ export function getTransferSyntax(imageId, metaData) {
getValue<string>(metaData['00083002']),
};
}

export default metaDataProvider;
Loading