@@ -1099,23 +1099,21 @@ def convert_single_frame_dicom_series_to_multiframe(
10991099 setattr (output_ds , attr , default )
11001100 logger .warning (f" ⚠️ Added missing { attr } = { default } " )
11011101
1102- # CRITICAL: Do NOT add top-level ImagePositionPatient or ImageOrientationPatient!
1103- # These tags interfere with OHIF/Cornerstone3D multi-frame parsing
1104- # OHIF will read the top-level value for ALL frames instead of per-frame values
1105- # Result: spacing[2] = 0 and "1/Infinity" display in MPR views
1106-
1107- # Remove them if they exist (from template dataset)
1102+ # CRITICAL FIX #1: Remove top-level ImagePositionPatient
1103+ # OHIF reads this for ALL frames instead of per-frame values → spacing[2] = 0
11081104 if hasattr (output_ds , "ImagePositionPatient" ):
11091105 delattr (output_ds , "ImagePositionPatient" )
11101106 logger .info (f" ✓ Removed top-level ImagePositionPatient (use per-frame only)" )
11111107
1112- if hasattr (output_ds , "ImageOrientationPatient" ):
1113- delattr (output_ds , "ImageOrientationPatient" )
1114- logger .info (f" ✓ Removed top-level ImageOrientationPatient (use SharedFunctionalGroupsSequence only)" )
1108+ # CRITICAL FIX #2: Keep ImageOrientationPatient at top level
1109+ # OHIF needs this to recognize file as MPR-capable
1110+ # Safe to keep since orientation is the same for all frames
1111+ if hasattr (datasets [0 ], "ImageOrientationPatient" ):
1112+ output_ds .ImageOrientationPatient = datasets [0 ].ImageOrientationPatient
1113+ logger .info (f" ✓ Kept top-level ImageOrientationPatient: { output_ds .ImageOrientationPatient } " )
11151114
1116- # CRITICAL: Set correct SOPClassUID for Enhanced multi-frame CT
1115+ # CRITICAL FIX #3 : Set correct SOPClassUID for Enhanced multi-frame CT
11171116 # Use Enhanced CT Image Storage (not legacy CT Image Storage)
1118- # This tells DICOM viewers to use Enhanced multi-frame parsing logic
11191117 output_ds .SOPClassUID = "1.2.840.10008.5.1.4.1.1.2.1" # Enhanced CT Image Storage
11201118 logger .info (f" ✓ Set SOPClassUID to Enhanced CT Image Storage" )
11211119
0 commit comments