Skip to content

Commit

Permalink
decompress volume file before unpack
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandip117 committed Apr 23, 2024
1 parent 3be640e commit 2c5c1a3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dicom_unpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import sys, traceback
import pudb
from pydicom.uid import ExplicitVRLittleEndian
__version__ = '1.2.4'
__version__ = '1.2.6'

DISPLAY_TITLE = r"""
_ _ _ _
Expand Down Expand Up @@ -94,11 +94,11 @@ def split_dicom_multiframe(dicom_data_set, output_file):
dir_path = str(output_file).replace('.dcm', '')
print(f"Creating o/p directory: {dir_path}")
os.makedirs(dir_path, exist_ok=True)

dicom_data_set.decompress()
for i, slice in enumerate(dicom_data_set.pixel_array):
dicom_data_set.PixelData = slice.tobytes()
dicom_data_set.PhotometricInterpretation = "YBR_FULL"
dicom_data_set.NumberOfFrames = 1
dicom_data_set.file_meta.TransferSyntaxUID = ExplicitVRLittleEndian
op_dcm_path = os.path.join(dir_path, f'slice_{i:03n}.dcm')
print(f"Saving file : -->slice_{i:03n}.dcm<--")
dicom_data_set.save_as(op_dcm_path)
Expand Down

0 comments on commit 2c5c1a3

Please sign in to comment.