Skip to content

Commit ff84658

Browse files
committed
Assert specific DICOM pixel array shape
1 parent 4cde694 commit ff84658

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

python/main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,12 @@ async def get_files(files: list[UploadFile]) -> UploadFilesResponse:
464464
with fp.open("wb") as f:
465465
f.write(contents)
466466
try:
467-
pydicom.dcmread(fp)
468-
proper_dicom_paths.append(fp)
469-
total_uploaded_file_bytes += len(contents)
467+
dcm = pydicom.dcmread(fp)
468+
if len(dcm.pixel_array.shape) == 2: # noqa: PLR2004
469+
proper_dicom_paths.append(fp)
470+
total_uploaded_file_bytes += len(contents)
470471
except InvalidDicomError:
471-
inv_fp = Path(fp)
472-
inv_fp.unlink()
472+
pass
473473
total_uploaded_file_megabytes = "%.1f" % (total_uploaded_file_bytes / (10**3) ** 2)
474474
return UploadFilesResponse(
475475
n_uploaded_files=len(proper_dicom_paths),

0 commit comments

Comments
 (0)