11import { keywordToTag , tagToKeyword } from './dictionary' ;
22
33function getFrameMapping ( metadata ) {
4- const rows = metadata [ '00280010' ] [ 'Value' ] [ 0 ] ;
5- const columns = metadata [ '00280011' ] [ 'Value' ] [ 0 ] ;
6- const totalPixelMatrixColumns = metadata [ '00480006' ] [ 'Value' ] [ 0 ] ;
7- const totalPixelMatrixRows = metadata [ '00480007' ] [ 'Value' ] [ 0 ] ;
8- const sopInstanceUID = metadata [ '00080018' ] [ 'Value' ] [ 0 ] ;
9- let numberOfFrames = 1 ;
10- if ( '00280008' in metadata ) {
11- numberOfFrames = Number ( metadata [ '00280008' ] [ 'Value' ] [ 0 ] ) ;
12- }
13- let frameOffsetNumber = 0 ;
14- if ( '00209161' in metadata ) {
15- frameOffsetNumber = Number ( metadata [ '00209228' ] [ 'Value' ] [ 0 ] ) ;
16- }
4+ const rows = metadata . Rows ;
5+ const columns = metadata . Columns ;
6+ const totalPixelMatrixColumns = metadata . TotalPixelMatrixColumns ;
7+ const totalPixelMatrixRows = metadata . TotalPixelMatrixRows ;
8+ const sopInstanceUID = metadata . SOPInstanceUID ;
9+ let numberOfFrames = metadata . NumberOfFrames || 1 ;
10+ numberOfFrames = Number ( numberOfFrames ) ;
11+ let frameOffsetNumber = metadata . ConcatenationFrameOffsetNumber || 0 ;
12+ frameOffsetNumber = Number ( frameOffsetNumber ) ;
1713 /*
1814 * The values "TILED_SPARSE" and "TILED_FULL" were introduced in the 2018
1915 * of the standard. Older datasets are equivalent to "TILED_SPARSE"
2016 * even though they may not have a value or a different value.
2117 */
22- try {
23- var dimensionOrganizationType = metadata [ '00209311' ] [ 'Value' ] [ 0 ] ;
24- } catch ( error ) {
25- var dimensionOrganizationType = 'TILED_SPARSE' ;
26- }
18+ const dimensionOrganizationType = metadata . DimensionOrganizationType || 'TILED_SPARSE' ;
2719 const tilesPerRow = Math . ceil ( totalPixelMatrixColumns / columns ) ;
2820 const tilesPerColumn = Math . ceil ( totalPixelMatrixRows / rows ) ;
2921 const frameMapping = { } ;
@@ -39,13 +31,13 @@ function getFrameMapping(metadata) {
3931 frameMapping [ index ] = `${ sopInstanceUID } /frames/${ frameNumber } ` ;
4032 }
4133 } else {
42- const perFrameFunctionalGroupsSequence = metadata [ '52009230' ] [ 'Value' ] ;
34+ const functionalGroups = metadata . PerFrameFunctionalGroupsSequence ;
4335 for ( let j = 0 ; j < numberOfFrames ; j ++ ) {
44- let planePositionSlideSequence = perFrameFunctionalGroupsSequence [ j ] [ '0048021A' ] [ 'Value' ] [ 0 ] ;
45- let rowPositionInTotalPixelMatrix = planePositionSlideSequence [ '0048021F' ] [ 'Value' ] [ 0 ] ;
46- let columnPositionInTotalPixelMatrix = planePositionSlideSequence [ '0048021E' ] [ 'Value' ] [ 0 ] ;
47- let rowIndex = Math . ceil ( rowPositionInTotalPixelMatrix / columns ) ;
48- let colIndex = Math . ceil ( columnPositionInTotalPixelMatrix / rows ) ;
36+ let planePositions = functionalGroups [ j ] . PlanePositionSlideSequence [ 0 ] ;
37+ let rowPosition = planePositions . RowPositionInTotalImagePixelMatrix ;
38+ let columnPosition = planePositions . ColumnPositionInTotalImagePixelMatrix ;
39+ let rowIndex = Math . ceil ( rowPosition / columns ) ;
40+ let colIndex = Math . ceil ( columnPosition / rows ) ;
4941 let index = rowIndex + '-' + colIndex ;
5042 let frameNumber = j + 1 ;
5143 frameMapping [ index ] = `${ sopInstanceUID } /frames/${ frameNumber } ` ;
0 commit comments