@@ -5,6 +5,7 @@ import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
55import { Vector3 } from '@kitware/vtk.js/types' ;
66import { mat3 , vec3 } from 'gl-matrix' ;
77import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray' ;
8+ import { vtkWarningMacro } from '@kitware/vtk.js/macros' ;
89
910const ImagePositionPatientTag = NAME_TO_TAG . get ( 'ImagePositionPatient' ) ! ;
1011const ImageOrientationPatientTag = NAME_TO_TAG . get ( 'ImageOrientationPatient' ) ! ;
@@ -16,6 +17,7 @@ const PixelRepresentationTag = NAME_TO_TAG.get('PixelRepresentation')!;
1617const SamplesPerPixelTag = NAME_TO_TAG . get ( 'SamplesPerPixel' ) ! ;
1718const RescaleIntercept = NAME_TO_TAG . get ( 'RescaleIntercept' ) ! ;
1819const RescaleSlope = NAME_TO_TAG . get ( 'RescaleSlope' ) ! ;
20+ const NumberOfFrames = NAME_TO_TAG . get ( 'NumberOfFrames' ) ! ;
1921
2022function toVec ( s : Maybe < string > ) : number [ ] | null {
2123 if ( ! s ?. length ) return null ;
@@ -84,8 +86,18 @@ export function allocateImageFromChunks(sortedChunks: Chunk[]) {
8486 const samplesPerPixel = Number ( meta . get ( SamplesPerPixelTag ) ?? 1 ) ;
8587 const rescaleIntercept = Number ( meta . get ( RescaleIntercept ) ?? 0 ) ;
8688 const rescaleSlope = Number ( meta . get ( RescaleSlope ) ?? 1 ) ;
89+ const numberOfFrames = meta . has ( NumberOfFrames )
90+ ? Number ( meta . get ( NumberOfFrames ) )
91+ : null ;
92+
93+ // If we have NumberOfFrames, chances are it's a multi-frame DICOM.
94+ if ( numberOfFrames !== null && sortedChunks . length > 1 ) {
95+ vtkWarningMacro (
96+ 'Found a multi-frame chunk in a group of chunks of size > 1'
97+ ) ;
98+ }
8799
88- const slices = sortedChunks . length ;
100+ const slices = numberOfFrames === null ? sortedChunks . length : numberOfFrames ;
89101 const TypedArrayCtor = getTypedArrayConstructor (
90102 bitsStored ,
91103 pixelRepresentation ,
0 commit comments