@@ -356,9 +356,16 @@ function viewerSetup() {
356356 * @param {string } loadType The load type.
357357 */
358358function logMetaData ( dataId , loadType ) {
359- // log meta data
359+ // meta data
360360 const meta = _app . getMetaData ( dataId ) ;
361- console . log ( 'metadata' , getMetaDataWithNames ( meta ) ) ;
361+
362+ // log tags for data with transfer syntax (dicom)
363+ if ( typeof meta [ '00020010' ] !== 'undefined' ) {
364+ console . log ( 'metadata' , dwv . getAsSimpleElements ( meta ) ) ;
365+ } else {
366+ console . log ( 'metadata' , meta ) ;
367+ }
368+
362369 // get modality
363370 let modality ;
364371 if ( loadType === 'image' &&
@@ -1079,60 +1086,6 @@ function logFramePosPats(elements) {
10791086 console . log ( 'DICOM SEG Segments' , sortByPosPatKey ( perPos ) ) ;
10801087}
10811088
1082- /**
1083- * Get an array reducer to reduce an array of tag keys taken from
1084- * the input dataElements and return theses dataElements indexed by tag names.
1085- *
1086- * @param {Object<string, DataElement> } dataElements The meta data
1087- * index by tag keys.
1088- * @returns {Function } An array reducer.
1089- */
1090- function getTagKeysReducer ( dataElements ) {
1091- return function ( accumulator , currentValue ) {
1092- // get the tag name
1093- const tag = dwv . getTagFromKey ( currentValue ) ;
1094- let tagName = tag . getNameFromDictionary ( ) ;
1095- if ( typeof tagName === 'undefined' ) {
1096- // add 'x' to list private at end
1097- tagName = 'x' + tag . getKey ( ) ;
1098- }
1099- const currentMeta = dataElements [ currentValue ] ;
1100- // remove undefined properties
1101- for ( const property in currentMeta ) {
1102- if ( typeof currentMeta [ property ] === 'undefined' ) {
1103- delete currentMeta [ property ] ;
1104- }
1105- }
1106- // recurse for sequences
1107- if ( currentMeta . vr === 'SQ' ) {
1108- // valid for 1D array, not for merged data elements
1109- for ( let i = 0 ; i < currentMeta . value . length ; ++ i ) {
1110- const item = currentMeta . value [ i ] ;
1111- currentMeta . value [ i ] = Object . keys ( item ) . reduce (
1112- getTagKeysReducer ( item ) , { } ) ;
1113- }
1114- }
1115- accumulator [ tagName ] = currentMeta ;
1116- return accumulator ;
1117- } ;
1118- }
1119-
1120- /**
1121- * Get the meta data indexed by tag names instead of tag keys.
1122- *
1123- * @param {Object<string, DataElement> } metaData The meta data
1124- * index by tag keys.
1125- * @returns {Object<string, DataElement> } The meta data indexed by tag names.
1126- */
1127- function getMetaDataWithNames ( metaData ) {
1128- let meta = structuredClone ( metaData ) ;
1129- if ( typeof meta [ '00020010' ] !== 'undefined' ) {
1130- // replace tag key with tag name for dicom
1131- meta = Object . keys ( meta ) . reduce ( getTagKeysReducer ( meta ) , { } ) ;
1132- }
1133- return meta ;
1134- }
1135-
11361089/**
11371090 * Setup about line.
11381091 */
0 commit comments