diff --git a/ev_to_dicom/ev_to_dcm.py b/ev_to_dicom/ev_to_dcm.py index 1b56867..26fe62e 100644 --- a/ev_to_dicom/ev_to_dcm.py +++ b/ev_to_dicom/ev_to_dcm.py @@ -113,8 +113,8 @@ def ev_files_to_dcm_file(study_uid, series_uid, series_number, image_number, inp block.add_new(0x02, 'OB', msgpack.packb(metadata)) if metadata['imageFormat'] == 0: - # JPEG 2000 - For some reason, the end of codestream tag is missing - ds.PixelData = encapsulate([pixel_data + b'\xff\xd9' for pixel_data in pixel_datas]) + # JPEG 2000 - For some reason, the end of codestream marker is (always?) missing + ds.PixelData = encapsulate([pixel_data if pixel_data.endswith(b'\xff\xd9') else pixel_data + b'\xff\xd9' for pixel_data in pixel_datas]) else: ds.PixelData = encapsulate(pixel_datas)