Skip to content

Commit

Permalink
fix(combineFrameInstance): integrate dicomSplit for ImageType process…
Browse files Browse the repository at this point in the history
…ing and streamline frame instance handling
  • Loading branch information
sedghi committed Jan 16, 2025
1 parent 44f5b03 commit 4bc0626
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions platform/core/src/utils/combineFrameInstance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { vec3 } from 'gl-matrix';
import { dicomSplit } from './dicomSplit';

/**
* Combine the Per instance frame data, the shared frame data
Expand All @@ -15,24 +16,13 @@ const combineFrameInstance = (frame, instance) => {
PerFrameFunctionalGroupsSequence,
SharedFunctionalGroupsSequence,
NumberOfFrames,
SpacingBetweenSlices,
ImageType,
} = instance;

instance.ImageType = dicomSplit(ImageType);

if (PerFrameFunctionalGroupsSequence || NumberOfFrames > 1) {
const frameNumber = Number.parseInt(frame || 1);
const shared = SharedFunctionalGroupsSequence
? Object.values(SharedFunctionalGroupsSequence[0])
.filter(Boolean)
.map(it => it[0])
.filter(it => typeof it === 'object')
: [];

const perFrame = PerFrameFunctionalGroupsSequence
? Object.values(PerFrameFunctionalGroupsSequence[frameNumber - 1])
.filter(Boolean)
.map(it => it[0])
.filter(it => typeof it === 'object')
: [];

// this is to fix NM multiframe datasets with position and orientation
// information inside DetectorInformationSequence
Expand All @@ -44,8 +34,12 @@ const combineFrameInstance = (frame, instance) => {
let ImagePositionPatientToUse = instance.ImagePositionPatient;

if (!instance.ImagePositionPatient && instance.DetectorInformationSequence) {
const imagePositionPatient = instance.DetectorInformationSequence[0].ImagePositionPatient;
const imageOrientationPatient = instance.ImageOrientationPatient;
let imagePositionPatient = instance.DetectorInformationSequence[0].ImagePositionPatient;
let imageOrientationPatient = instance.ImageOrientationPatient;

imagePositionPatient = imagePositionPatient.map(it => Number(it));
imageOrientationPatient = imageOrientationPatient.map(it => Number(it));
const SpacingBetweenSlices = Number(instance.SpacingBetweenSlices);

// Calculate the position for the current frame
if (imageOrientationPatient && SpacingBetweenSlices) {
Expand Down

0 comments on commit 4bc0626

Please sign in to comment.