Skip to content

Commit

Permalink
"possibly None" bugfixes in itk io
Browse files Browse the repository at this point in the history
  • Loading branch information
elazarcoh committed Mar 14, 2022
1 parent 68271f8 commit 76722f1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions medio/backends/itk_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def read_img(
elif input_path.is_file():
# If the input is not a dicom, fallback to not use imageio.
# NOTE: this assume imageio is used for dicom files only. If it changed, we need to modify this.
is_dicom = imageio.CanReadFile(str(input_path))
if not is_dicom:
use_dicom_imageio = imageio and imageio.CanReadFile(str(input_path))
if not use_dicom_imageio:
imageio = None
img = ItkIO.read_img_file(
str(input_path), pixel_type, fallback_only, imageio
Expand All @@ -81,7 +81,10 @@ def read_img(
affine=affine, orig_ornt=orig_ornt, coord_sys=ItkIO.coord_sys
)
if header:
metadict = imageio.GetMetaDataDictionary()
if imageio:
metadict = imageio.GetMetaDataDictionary()
else:
metadict = img.GetMetaDataDictionary()
metadata.header = {
key: metadict[key]
for key in metadict.GetKeys()
Expand Down

0 comments on commit 76722f1

Please sign in to comment.