File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
monailabel/datastore/utils Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 9393import pydicom
9494from pydicom .uid import generate_uid
9595
96+ import pydicom .config
97+ pydicom .config .assume_implicit_vr_switch = True
98+
9699logger = logging .getLogger (__name__ )
97100
98101# Constants for DICOM modalities
@@ -683,6 +686,21 @@ def convert_to_enhanced_dicom(
683686 # Set transfer syntax
684687 enhanced .file_meta .TransferSyntaxUID = transfer_syntax_uid
685688
689+ # After highdicom creates the enhanced image, ALSO set top-level tags
690+ # for DICOMweb compatibility
691+
692+ # Add top-level Window/Level (from first legacy dataset)
693+ if hasattr (datasets [0 ], "WindowCenter" ):
694+ enhanced .WindowCenter = datasets [0 ].WindowCenter
695+ if hasattr (datasets [0 ], "WindowWidth" ):
696+ enhanced .WindowWidth = datasets [0 ].WindowWidth
697+
698+ # Add top-level Rescale parameters
699+ if hasattr (datasets [0 ], "RescaleSlope" ):
700+ enhanced .RescaleSlope = datasets [0 ].RescaleSlope
701+ if hasattr (datasets [0 ], "RescaleIntercept" ):
702+ enhanced .RescaleIntercept = datasets [0 ].RescaleIntercept
703+
686704 # Save the enhanced DICOM file
687705 enhanced .save_as (str (output_file ), enforce_file_format = False )
688706
You can’t perform that action at this time.
0 commit comments