Skip to content

Commit 8ee9d69

Browse files
authored
Add openjpeg as requirement for forge templates that have DICOM (#4563)
While debugging an algorithm, I found that we also require `pylibjpeg-openjpeg` for decompression of: `'High-Throughput JPEG 2000 with RPCL Options Image Compression (Lossless Only)'`. At the same time, I found out the `slice.decompress()` is actually in-place. Cleaned that up as well.
1 parent 56ed7f9 commit 8ee9d69

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

app/grandchallenge/forge/templates/forge/partials/example_algorithm/requirements.txt.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ pydicom
1010
# Required to decompress some DICOM transfer syntaxes
1111
pylibjpeg
1212
pylibjpeg-libjpeg
13+
pylibjpeg-openjpeg
1314
{% endif %}

app/grandchallenge/forge/templates/forge/partials/example_evaluation_method/requirements.txt.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ pydicom
1111
# Required to decompress some DICOM transfer syntaxes
1212
pylibjpeg
1313
pylibjpeg-libjpeg
14+
pylibjpeg-openjpeg
1415
{% endif %}

app/grandchallenge/forge/templates/forge/partials/functions/load_dicom_image.py.template

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ def load_dicom_image_set_as_array(*, location):
1111

1212
# Read all slices
1313
slices = [pydicom.dcmread(f, force=True) for f in dicom_files]
14-
decompressed_slices = [slice.decompress() for slice in slices]
14+
15+
for idx, slice in enumerate(slices): # Decompress the pixel data in-place.
16+
slice.decompress()
17+
print(f"Slice {idx} shape:", slice.pixel_array.shape)
1518

1619
# Extracting pixel-data is non-trivial:
1720
# - Slices need to be sorted in case of a 3D volume or 4D volume

0 commit comments

Comments
 (0)