-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding support for multiframe metadata in wadors and wadouri (#494
) * adding suppoort for multiframe in cswil * Refactoring code and add comments * Refactor and comment code * Apply changes to wadouri side * Refactoring multiframe functions * Applying PR reviewer suggestions * adding suppoort for multiframe in cswil * Refactoring code and add comments * Refactor and comment code * Apply changes to wadouri side * Refactoring multiframe functions * Applying refactoring changes from PR review * Resolving rebase issues * Refactoring code for wado and wadouri code * Minor typo fix from last commit * Applying camel name for multiframe function names * Adding multifrmae support for wadouri * Minor typo changes * rename file
- Loading branch information
1 parent
16e0130
commit 95b886f
Showing
11 changed files
with
464 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
"proseWrap": "always", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true | ||
"singleQuote": true, | ||
"endOfLine":"auto" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import getTagValue from './getTagValue.js'; | ||
|
||
function getFrameInformation( | ||
PerFrameFunctionalGroupsSequence, | ||
SharedFunctionalGroupsSequence, | ||
frameNumber | ||
) { | ||
const shared = ( | ||
SharedFunctionalGroupsSequence | ||
? Object.values(SharedFunctionalGroupsSequence[0]) | ||
: [] | ||
) | ||
.map((it) => it[0]) | ||
.filter((it) => it !== undefined && typeof it === 'object'); | ||
const perFrame = ( | ||
PerFrameFunctionalGroupsSequence | ||
? Object.values(PerFrameFunctionalGroupsSequence[frameNumber - 1]) | ||
: [] | ||
) | ||
.map((it) => it.Value[0]) | ||
.filter((it) => it !== undefined && typeof it === 'object'); | ||
|
||
return { | ||
shared, | ||
perFrame, | ||
}; | ||
} | ||
|
||
function getMultiframeInformation(metaData) { | ||
let { | ||
52009230: PerFrameFunctionalGroupsSequence, | ||
52009229: SharedFunctionalGroupsSequence, | ||
'00280008': NumberOfFrames, | ||
// eslint-disable-next-line prefer-const | ||
...rest | ||
} = metaData; | ||
|
||
PerFrameFunctionalGroupsSequence = getTagValue( | ||
PerFrameFunctionalGroupsSequence, | ||
false | ||
); | ||
SharedFunctionalGroupsSequence = getTagValue( | ||
SharedFunctionalGroupsSequence, | ||
false | ||
); | ||
NumberOfFrames = getTagValue(NumberOfFrames); | ||
|
||
return { | ||
PerFrameFunctionalGroupsSequence, | ||
SharedFunctionalGroupsSequence, | ||
NumberOfFrames, | ||
rest, | ||
}; | ||
} | ||
// function that retrieves specific frame metadata information from multiframe | ||
// metadata | ||
function combineFrameInstance(frameNumber, instance) { | ||
const { | ||
PerFrameFunctionalGroupsSequence, | ||
SharedFunctionalGroupsSequence, | ||
NumberOfFrames, | ||
rest, | ||
} = getMultiframeInformation(instance); | ||
|
||
if (PerFrameFunctionalGroupsSequence || NumberOfFrames > 1) { | ||
const { shared, perFrame } = getFrameInformation( | ||
PerFrameFunctionalGroupsSequence, | ||
SharedFunctionalGroupsSequence, | ||
frameNumber | ||
); | ||
|
||
return Object.assign( | ||
rest, | ||
{ '00280008': NumberOfFrames }, | ||
...Object.values(shared), | ||
...Object.values(perFrame) | ||
); | ||
} | ||
|
||
return instance; | ||
} | ||
|
||
export { combineFrameInstance, getMultiframeInformation, getFrameInformation }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default function getTagValue(tag, justElement = true) { | ||
if (tag && tag.Value) { | ||
if (tag.Value[0] && justElement) { | ||
return tag.Value[0]; | ||
} | ||
|
||
return tag.Value; | ||
} | ||
|
||
return tag; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import getTagValue from '../getTagValue.js'; | ||
|
||
export default function fixNMMetadata(metaData) { | ||
if (!metaData['00200032'] || metaData['00200037']) { | ||
// adjust metadata in case of multiframe NM data, as the dicom tags | ||
// 00200032 and 00200037 could be found only in the dicom tag 00540022 | ||
const detectorInformationSequence = getTagValue(metaData['00540022']); | ||
|
||
if (detectorInformationSequence) { | ||
metaData['00200032'] = detectorInformationSequence['00200032']; | ||
metaData['00200037'] = detectorInformationSequence['00200037']; | ||
} | ||
} | ||
|
||
return metaData; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import getValue from './metaData/getValue.js'; | ||
import imageIdToURI from '../imageIdToURI.js'; | ||
import { metadataByImageURI } from './metaDataManager.js'; | ||
|
||
// get metadata information for the first frame | ||
function _retrieveMultiframeMetadata(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 retrieveMultiframeMetadata(imageId) { | ||
const imageURI = imageIdToURI(imageId); | ||
|
||
return _retrieveMultiframeMetadata(imageURI); | ||
} | ||
|
||
function isMultiframe(metadata) { | ||
// Checks if dicomTag NumberOf Frames exists and it is greater than one | ||
const numberOfFrames = getValue(metadata['00280008']); | ||
|
||
return numberOfFrames && numberOfFrames > 1; | ||
} | ||
|
||
export default { | ||
_retrieveMultiframeMetadata, | ||
retrieveMultiframeMetadata, | ||
isMultiframe, | ||
}; |
Oops, something went wrong.