Skip to content
Snippets Groups Projects
Commit ea332776 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

TEST: Work around dcm2niix weirdnesses - an older version appears to have gone

missing from github, even older versions produce different numbers of series
from a dicom dir, and different numbers of images from a series, and the
newest version produces carets instead of underscores.
parent 71e42204
No related branches found
No related tags found
No related merge requests found
...@@ -29,10 +29,10 @@ pytestmark = pytest.mark.dicomtest ...@@ -29,10 +29,10 @@ pytestmark = pytest.mark.dicomtest
@contextlib.contextmanager @contextlib.contextmanager
def install_dcm2niix(version='1.0.20190902'): def install_dcm2niix(version='1.0.20201102'):
filenames = { filenames = {
'1.0.20201102' : 'v1.0.20201102/dcm2niix_lnx.zip',
'1.0.20190902' : 'v1.0.20190902/dcm2niix_lnx.zip', '1.0.20190902' : 'v1.0.20190902/dcm2niix_lnx.zip',
'1.0.20190410' : 'v1.0.20190410/dcm2niix_11-Apr-2019_lnx.zip',
'1.0.20181125' : 'v1.0.20181125/dcm2niix_25-Nov-2018_lnx.zip', '1.0.20181125' : 'v1.0.20181125/dcm2niix_25-Nov-2018_lnx.zip',
'1.0.20171017' : 'v1.0.20171017/dcm2niix_18-Oct-2017_lnx.zip', '1.0.20171017' : 'v1.0.20171017/dcm2niix_18-Oct-2017_lnx.zip',
} }
...@@ -128,8 +128,9 @@ def test_scanDir(): ...@@ -128,8 +128,9 @@ def test_scanDir():
assert len(series) == 2 assert len(series) == 2
for s in series: for s in series:
assert (s['PatientName'] == 'MCCARTHY_PAUL' or assert s['PatientName'] in ('MCCARTHY_PAUL',
s['PatientName'] == 'MCCARTHY_PAUL_2') 'MCCARTHY^PAUL',
'MCCARTHY_PAUL_2')
def test_sersiesCRC(): def test_sersiesCRC():
...@@ -158,7 +159,7 @@ def test_sersiesCRC(): ...@@ -158,7 +159,7 @@ def test_sersiesCRC():
def test_loadSeries(): def test_loadSeries():
# test a pre-CRC and a post-CRC version # test a pre-CRC and a post-CRC version
for version in ('1.0.20190410', '1.0.20190902'): for version in ('1.0.20181125', '1.0.20201102'):
with install_dcm2niix(version): with install_dcm2niix(version):
...@@ -170,23 +171,23 @@ def test_loadSeries(): ...@@ -170,23 +171,23 @@ def test_loadSeries():
dcmdir = os.getcwd() dcmdir = os.getcwd()
series = fsldcm.scanDir(dcmdir) series = fsldcm.scanDir(dcmdir)
expShape = (512, 512, 1) expShape = (512, 512, 1)
explens = [1, 1]
for s, explen in zip(series, explens): for s in series:
imgs = fsldcm.loadSeries(s) imgs = fsldcm.loadSeries(s)
assert len(imgs) == explen
for img in imgs: for img in imgs:
assert img.dicomDir == dcmdir assert img.dicomDir == dcmdir
assert img.shape == expShape assert img.shape == expShape
assert img[:].shape == expShape assert img[:].shape == expShape
assert img.getMeta('PatientName') == 'MCCARTHY_PAUL' or \ assert img.getMeta('PatientName') in ('MCCARTHY_PAUL',
img.getMeta('PatientName') == 'MCCARTHY_PAUL_2' 'MCCARTHY^PAUL',
'MCCARTHY_PAUL_2')
assert 'PatientName' in img.metaKeys() assert 'PatientName' in img.metaKeys()
assert 'MCCARTHY_PAUL' in img.metaValues() or \ assert 'MCCARTHY_PAUL' in img.metaValues() or \
'MCCARTHY^PAUL' in img.metaValues() or \
'MCCARTHY_PAUL_2' in img.metaValues() 'MCCARTHY_PAUL_2' in img.metaValues()
assert ('PatientName', 'MCCARTHY_PAUL') in img.metaItems() or \ assert ('PatientName', 'MCCARTHY_PAUL') in img.metaItems() or \
('PatientName', 'MCCARTHY^PAUL') in img.metaItems() or \
('PatientName', 'MCCARTHY_PAUL_2') in img.metaItems() ('PatientName', 'MCCARTHY_PAUL_2') in img.metaItems()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment