Skip to content

Commit

Permalink
Use gdcm for dicoms only
Browse files Browse the repository at this point in the history
  • Loading branch information
elazarcoh committed Mar 13, 2022
1 parent c020180 commit 568d686
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions medio/backends/itk_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ def read_img(input_path, desired_axcodes=None, header=False, components_axis=Non
if input_path.is_dir():
img = ItkIO.read_dir(str(input_path), pixel_type, fallback_only, series, imageio)
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:
imageio = None
img = ItkIO.read_img_file(str(input_path), pixel_type, fallback_only, imageio)
else:
raise FileNotFoundError(f'No such file or directory: "{input_path}"')
Expand Down

0 comments on commit 568d686

Please sign in to comment.