New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleITK: "Unable to determine ImageIO reader for ..." during local pytest #126

Closed
WGierke opened this Issue Sep 19, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@WGierke
Copy link
Contributor

WGierke commented Sep 19, 2017

When running the tests locally, I'm getting 4 failed tests due to a RuntimeError in SimpleITK (on the current master).

Expected Behavior

The tests should pass.

Current Behavior

4 tests fail due to SimpleITK:

(venv3.5) ➜  concept-to-clinic git:(master) ✗ sudo bash tests/test_docker.sh 
+ docker-compose -f local.yml run prediction pytest
======================================== test session starts ========================================
platform linux -- Python 3.6.2, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: /app, inifile:
collected 26 items 

src/tests/test_calculate_volume.py ...
src/tests/test_classify_trained_model_predict.py ..
src/tests/test_crop_dicom.py .
src/tests/test_endpoints.py ........
src/tests/test_load_ct.py FFFF
src/tests/test_load_dicom.py ....
src/tests/test_preprocess_dicom.py ....

============================================= FAILURES ==============================================
________________________________________ test_load_metaimage ________________________________________

metaimage_path = '../images/LUNA-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797'
dicom_path = '../images/LIDC-IDRI-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.298806137288633453246975630178/1.3.6.1.4.1.14519.5.2.1.6279.6001.179049373636438705059720603192'

    def test_load_metaimage(metaimage_path, dicom_path):
        path = glob(os.path.join(metaimage_path, '*.mhd'))[0]
>       ct_array, meta = load_ct.load_metaimage(path)

src/tests/test_load_ct.py:25: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/preprocess/load_ct.py:72: in load_metaimage
    meta = SimpleITK.ReadImage(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = ('../images/LUNA-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797.mhd',)

    def ReadImage(*args):
        """
        ReadImage(VectorString fileNames, itk::simple::PixelIDValueEnum outputPixelType) -> Image
        ReadImage(std::string const & filename, itk::simple::PixelIDValueEnum outputPixelType) -> Image
    
    
    
        ReadImage is a procedural interface to the ImageSeriesReader class which is convenient for most image reading tasks.
    
    
        Note that when reading a series of images that have meta-data
        associated with them (e.g. a DICOM series) the resulting image will
        have an empty meta-data dictionary. It is possible to programmatically
        add a meta-data dictionary to the compounded image by reading in one
        or more images from the series using the ImageFileReader class,
        analyzing the meta-dictionary associated with each of those images and
        creating one that is relevant for the compounded image.
    
    
        See:
         itk::simple::ImageFileReader for reading a single file
    
    
    
        """
>       return _SimpleITK.ReadImage(*args)
E       RuntimeError: Exception thrown in SimpleITK ReadImage: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:82:
E       sitk::ERROR: Unable to determine ImageIO reader for "../images/LUNA-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797.mhd"

/usr/local/lib/python3.6/site-packages/SimpleITK/SimpleITK.py:8332: RuntimeError
___________________________________________ test_load_ct ____________________________________________

metaimage_path = '../images/LUNA-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797'
dicom_path = '../images/LIDC-IDRI-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.298806137288633453246975630178/1.3.6.1.4.1.14519.5.2.1.6279.6001.179049373636438705059720603192'

    def test_load_ct(metaimage_path, dicom_path):
        ct_array, meta = load_ct.load_ct(dicom_path)
        assert isinstance(ct_array, np.ndarray)
        assert ct_array.shape[2] == len(meta)
    
>       ct_array, meta = load_ct.load_ct(metaimage_path)

src/tests/test_load_ct.py:47: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/preprocess/load_ct.py:103: in load_ct
    meta = load_metaimage(mhd_pattern, voxel=voxel)
src/preprocess/load_ct.py:72: in load_metaimage
    meta = SimpleITK.ReadImage(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = ('../images/LUNA-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797.mhd',)

    def ReadImage(*args):
        """
        ReadImage(VectorString fileNames, itk::simple::PixelIDValueEnum outputPixelType) -> Image
        ReadImage(std::string const & filename, itk::simple::PixelIDValueEnum outputPixelType) -> Image
    
    
    
        ReadImage is a procedural interface to the ImageSeriesReader class which is convenient for most image reading tasks.
    
    
        Note that when reading a series of images that have meta-data
        associated with them (e.g. a DICOM series) the resulting image will
        have an empty meta-data dictionary. It is possible to programmatically
        add a meta-data dictionary to the compounded image by reading in one
        or more images from the series using the ImageFileReader class,
        analyzing the meta-dictionary associated with each of those images and
        creating one that is relevant for the compounded image.
    
    
        See:
         itk::simple::ImageFileReader for reading a single file
    
    
    
        """
>       return _SimpleITK.ReadImage(*args)
E       RuntimeError: Exception thrown in SimpleITK ReadImage: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:82:
E       sitk::ERROR: Unable to determine ImageIO reader for "../images/LUNA-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797.mhd"

/usr/local/lib/python3.6/site-packages/SimpleITK/SimpleITK.py:8332: RuntimeError
__________________________________________ test_load_meta ___________________________________________

metaimage_path = '../images/LUNA-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797'
dicom_path = '../images/LIDC-IDRI-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.298806137288633453246975630178/1.3.6.1.4.1.14519.5.2.1.6279.6001.179049373636438705059720603192'

    def test_load_meta(metaimage_path, dicom_path):
        meta = load_ct.load_ct(dicom_path, voxel=False)
        assert isinstance(meta, list)
        assert len(meta) > 0
        assert all([isinstance(_slice, dicom.dataset.FileDataset)
                    for _slice in meta])
    
>       meta = load_ct.load_ct(metaimage_path, voxel=False)

src/tests/test_load_ct.py:64: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/preprocess/load_ct.py:103: in load_ct
    meta = load_metaimage(mhd_pattern, voxel=voxel)
src/preprocess/load_ct.py:72: in load_metaimage
    meta = SimpleITK.ReadImage(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = ('../images/LUNA-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797.mhd',)

    def ReadImage(*args):
        """
        ReadImage(VectorString fileNames, itk::simple::PixelIDValueEnum outputPixelType) -> Image
        ReadImage(std::string const & filename, itk::simple::PixelIDValueEnum outputPixelType) -> Image
    
    
    
        ReadImage is a procedural interface to the ImageSeriesReader class which is convenient for most image reading tasks.
    
    
        Note that when reading a series of images that have meta-data
        associated with them (e.g. a DICOM series) the resulting image will
        have an empty meta-data dictionary. It is possible to programmatically
        add a meta-data dictionary to the compounded image by reading in one
        or more images from the series using the ImageFileReader class,
        analyzing the meta-dictionary associated with each of those images and
        creating one that is relevant for the compounded image.
    
    
        See:
         itk::simple::ImageFileReader for reading a single file
    
    
    
        """
>       return _SimpleITK.ReadImage(*args)
E       RuntimeError: Exception thrown in SimpleITK ReadImage: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:82:
E       sitk::ERROR: Unable to determine ImageIO reader for "../images/LUNA-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797.mhd"

/usr/local/lib/python3.6/site-packages/SimpleITK/SimpleITK.py:8332: RuntimeError
___________________________________________ test_metadata ___________________________________________

metaimage_path = '../images/LUNA-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797'
dicom_path = '../images/LIDC-IDRI-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.298806137288633453246975630178/1.3.6.1.4.1.14519.5.2.1.6279.6001.179049373636438705059720603192'

    def test_metadata(metaimage_path, dicom_path):
        meta = load_ct.load_ct(dicom_path, voxel=False)
        meta = load_ct.MetaData(meta)
        zipped = zip(meta.spacing, (0.703125, 0.703125, 2.5))
        assert all([m_axis == o_axis for m_axis, o_axis in zipped])
    
>       meta = load_ct.load_ct(metaimage_path, voxel=False)

src/tests/test_load_ct.py:74: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/preprocess/load_ct.py:103: in load_ct
    meta = load_metaimage(mhd_pattern, voxel=voxel)
src/preprocess/load_ct.py:72: in load_metaimage
    meta = SimpleITK.ReadImage(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = ('../images/LUNA-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797.mhd',)

    def ReadImage(*args):
        """
        ReadImage(VectorString fileNames, itk::simple::PixelIDValueEnum outputPixelType) -> Image
        ReadImage(std::string const & filename, itk::simple::PixelIDValueEnum outputPixelType) -> Image
    
    
    
        ReadImage is a procedural interface to the ImageSeriesReader class which is convenient for most image reading tasks.
    
    
        Note that when reading a series of images that have meta-data
        associated with them (e.g. a DICOM series) the resulting image will
        have an empty meta-data dictionary. It is possible to programmatically
        add a meta-data dictionary to the compounded image by reading in one
        or more images from the series using the ImageFileReader class,
        analyzing the meta-dictionary associated with each of those images and
        creating one that is relevant for the compounded image.
    
    
        See:
         itk::simple::ImageFileReader for reading a single file
    
    
    
        """
>       return _SimpleITK.ReadImage(*args)
E       RuntimeError: Exception thrown in SimpleITK ReadImage: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:82:
E       sitk::ERROR: Unable to determine ImageIO reader for "../images/LUNA-0001/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797/1.3.6.1.4.1.14519.5.2.1.6279.6001.102133688497886810253331438797.mhd"

/usr/local/lib/python3.6/site-packages/SimpleITK/SimpleITK.py:8332: RuntimeError
=============================== 4 failed, 22 passed in 28.94 seconds ================================

Steps to Reproduce

  1. git fetch --all
  2. git reset --hard origin/master
  3. sudo git clean -x -i -d
  4. sudo docker-compose -f local.yml build && sudo bash tests/test_docker.sh
    The tests fail with the aforementioned error.

I'm running Ubuntu 16.04 and docker-compose version 1.15.0, build e12f3b9.

Is anyone else experiencing this issue? I'm really confused since the tests pass on Travis...

Checklist before submitting

  • I have confirmed this using the officially supported Docker Compose setup using the local.py configuration and ensured that I built the containers again and they reflect the most recent version of the project at the HEAD commit on the master branch
  • I have searched through the other currently open issues and am confident this is not a duplicate of an existing bug
  • I provided a minimal code snippet or list of steps that reproduces the bug.
  • I filled out all the relevant sections of this template
@vessemer

This comment has been minimized.

Copy link
Contributor

vessemer commented Sep 19, 2017

This bug has been occured because SimpleITK can't read the file (obviously), and my initial thought was that the problem is related to the broken .mhd file, but since it runs well on both my computers with the different environments and on Travis as well, then I've become confused. Probably it's because you didn't rerun dockerd and it tries to preserve its previous paths even after docker-compose -f local.yml build?

@WGierke

This comment has been minimized.

Copy link
Contributor

WGierke commented Sep 20, 2017

Thanks for trying to reproduce it @vessemer . The tests work at another computer of mine, but my main tower is still having troubles. I chowned everything to my user, restarted dockerd and deleted all images and containers. No success so far :/ I'm currently cloning the repository to a new location so I can test it there again. If the tests still fail, I'll re-install docker.

@WGierke

This comment has been minimized.

Copy link
Contributor

WGierke commented Sep 20, 2017

Re-cloning the repository "solved" it. What the heck. But thanks for your input @vessemer !

@WGierke WGierke closed this Sep 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment