Skip to content

Commit d440042

Browse files
authored
Merge pull request #3 from dmoore247/htj2k_support
Fix washout in CT Scans
2 parents a949f23 + 13d2864 commit d440042

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

monailabel/datastore/utils/convert_multiframe.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@
9393
import pydicom
9494
from pydicom.uid import generate_uid
9595

96+
import pydicom.config
97+
pydicom.config.assume_implicit_vr_switch = True
98+
9699
logger = 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

0 commit comments

Comments
 (0)