Skip to content

Commit 2bd3b9e

Browse files
committed
Skip files that don't have PixelData member
Signed-off-by: Joaquin Anton Guirao <janton@nvidia.com>
1 parent f88d03e commit 2bd3b9e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

monailabel/datastore/utils/convert_htj2k.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,14 +504,14 @@ def transcode_dicom_to_htj2k(
504504
ts_str = str(current_ts)
505505

506506
# Check if this transfer syntax should be skipped
507-
if ts_str in skip_transfer_syntaxes:
507+
has_pixel_data = hasattr(ds, "PixelData") and ds.PixelData is not None
508+
if ts_str in skip_transfer_syntaxes or not has_pixel_data:
508509
skip_batch.append(idx)
509-
logger.info(f" Skipping {os.path.basename(batch_in[idx])} (Transfer Syntax: {ts_str})")
510+
logger.info(f" Skipping {os.path.basename(batch_in[idx])} (Transfer Syntax: {ts_str}, has_pixel_data: {has_pixel_data})")
510511
continue
511512

513+
assert has_pixel_data, f"DICOM file {os.path.basename(batch_in[idx])} does not have a PixelData member"
512514
if ts_str in NVIMGCODEC_SYNTAXES:
513-
if not hasattr(ds, "PixelData") or ds.PixelData is None:
514-
raise ValueError(f"DICOM file {os.path.basename(batch_in[idx])} does not have a PixelData member")
515515
nvimgcodec_batch.append(idx)
516516
else:
517517
pydicom_batch.append(idx)

0 commit comments

Comments
 (0)