JoHof / lungmask

Automated lung segmentation in CT
Apache License 2.0
646 stars 149 forks source link

Error reading .dcm files #62

Closed isglobal-brge closed 1 year ago

isglobal-brge commented 2 years ago

Hi,

first of all, thank you very much for making publicy available this amazing software.

I am interested in segmenting lots of lung in dicom format (I have 228 .dcm files for each individual) - I executed this for the first individual which is in the folder INPUT (in this folder I have 228 slices: 1.dcm, 2.dcm, ... 228.dcm)

input_image = sitk.ReadImage(INPUT)

and I get this error message - Any idea about how to fix this will be wellcome!

HDF5-DIAG: Error detected in HDF5 (1.10.6) thread 0:

000: /tmp/SimpleITK-build/ITK/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5F.c line 370 in itk_H5Fis_hdf5(): unable open file

major: File accessibilty
minor: Not an HDF5 file

001: /tmp/SimpleITK-build/ITK/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5Fint.c line 830 in itk_H5F__is_hdf5(): unable to locate file signature

major: File accessibilty
minor: Not an HDF5 file

002: /tmp/SimpleITK-build/ITK/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5FDint.c line 126 in itk_H5FD_locate_signature(): unable to read file signature

major: Low-level I/O
minor: Unable to initialize object

003: /tmp/SimpleITK-build/ITK/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5FDint.c line 205 in itk_H5FD_read(): driver read request failed

major: Virtual File Layer
minor: Read failed

004: /tmp/SimpleITK-build/ITK/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5FDsec2.c line 725 in H5FD_sec2_read(): file read failed: time = Wed Dec 15 20:45:17 2021

, filename = '/home/jr/radiomics/eclipse/', file descriptor = 17, errno = 21, error message = 'Is a directory', buf = 0x7ffed2a058e8, total read size = 8, bytes this sub-read = 8, bytes actually read = 18446744073709551615, offset = 0 major: Low-level I/O minor: Read failed RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:105: sitk::ERROR: Unable to determine ImageIO reader for "/home/jr/radiomics/eclipse/"

JoHof commented 2 years ago

Hi,

to read a dicom series with sitk would need to do it like that: https://simpleitk.readthedocs.io/en/master/link_DicomSeriesReader_docs.html

isglobal-brge commented 2 years ago

Thank you for the feedback @ahmed1996said. Do you think this can be fixed? I have 3000 CT scans and converting the images to .nii would duplicate the information and disk space requirements

isglobal-brge commented 2 years ago

Thank you very much!

JoHof commented 2 years ago

The error above is not caused by missing slices but the result of providing a folder to sitk.ReadImage which can only take files. You can also use the lungmask.utils.read_dicoms function to read a dicom series

isglobal-brge commented 2 years ago

Yes, but this is Phython and another package, isn't it? I wanted to use "lungct" R library to make everything in R (I know that I can use reticulate)