diff --git a/tests/test_dicom.py b/tests/test_dicom.py index 2e214bfa0d1bcea656519028ed6cf9e787492a29..20e933b6bf67a16fd305ee9475be14a2acae1a5d 100644 --- a/tests/test_dicom.py +++ b/tests/test_dicom.py @@ -14,8 +14,6 @@ import pytest import fsl.data.dicom as fsldcm import fsl.utils.tempdir as tempdir -from . import tempdir - datadir = op.join(op.dirname(__file__), 'testdata') @@ -64,7 +62,7 @@ def test_enabled(): def test_scanDir(): - with tempdir() as td: + with tempdir.tempdir() as td: series = fsldcm.scanDir(td) assert len(series) == 0 @@ -78,34 +76,37 @@ def test_scanDir(): assert len(series) == 2 for s in series: - assert s['PatientName'] == 'MCCARTHY_PAUL' + assert (s['PatientName'] == 'MCCARTHY_PAUL' or + s['PatientName'] == 'MCCARTHY_PAUL_2') def test_loadSeries(): - with tempdir() as td: + with tempdir.tempdir() as td: datafile = op.join(datadir, 'example_dicom.tbz2') with tarfile.open(datafile) as f: f.extractall() - series = fsldcm.scanDir(td) - - expShapes = [(512, 512, 25), - (512, 512, 29)] + series = fsldcm.scanDir(td) + expShape = (512, 512, 1) + explens = [1, 2] - for s, expShape in zip(series, expShapes): + for s, explen in zip(series, explens): - img = fsldcm.loadSeries(s) + imgs = fsldcm.loadSeries(s) - assert len(img) == 1 + assert len(imgs) == explen - img = img[0] + for img in imgs: - assert img.shape == expShape - assert img[:].shape == expShape - assert img.get('PatientName') == 'MCCARTHY_PAUL' - assert 'PatientName' in img.keys() - assert 'MCCARTHY_PAUL' in img.values() - assert ('PatientName', 'MCCARTHY_PAUL') in img.items() + assert img.shape == expShape + assert img[:].shape == expShape + assert img.get('PatientName') == 'MCCARTHY_PAUL' or \ + img.get('PatientName') == 'MCCARTHY_PAUL_2' + assert 'PatientName' in img.keys() + assert 'MCCARTHY_PAUL' in img.values() or \ + 'MCCARTHY_PAUL_2' in img.values() + assert ('PatientName', 'MCCARTHY_PAUL') in img.items() or \ + ('PatientName', 'MCCARTHY_PAUL_2') in img.items() diff --git a/tests/testdata/example_dicom.tbz2 b/tests/testdata/example_dicom.tbz2 index eeb6773f06c268e5ced8feed9debf75a4502d22e..341d69b86966fee75d50d9afee705c85dcabc1b4 100644 Binary files a/tests/testdata/example_dicom.tbz2 and b/tests/testdata/example_dicom.tbz2 differ