Skip to content

Commit 80c5a7c

Browse files
committed
TST: add test for parrec2nii CSV output
1 parent 2ec22e3 commit 80c5a7c

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

nibabel/tests/test_scripts.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import os
1010
from os.path import (dirname, join as pjoin, abspath, splitext, basename,
1111
exists)
12-
import re
12+
import csv
1313
from glob import glob
1414

1515
import numpy as np
@@ -18,8 +18,7 @@
1818
from ..loadsave import load
1919
from ..orientations import flip_axis, aff2axcodes, inv_ornt_aff
2020

21-
from nose.tools import (assert_true, assert_false, assert_not_equal,
22-
assert_equal)
21+
from nose.tools import assert_true, assert_false, assert_equal
2322
from nose import SkipTest
2423

2524
from numpy.testing import assert_almost_equal
@@ -333,3 +332,17 @@ def test_parrec2nii_with_data():
333332
data_sorted = img.get_data().copy()
334333
assert_almost_equal(data[..., np.argsort(DTI_PAR_BVALS)], data_sorted)
335334
del img
335+
336+
# Writes .ordering.csv if requested
337+
run_command(['parrec2nii', '--overwrite', '--volume-info', dti_par])
338+
assert_true(exists('DTI.ordering.csv'))
339+
with open('DTI.ordering.csv', 'r') as csvfile:
340+
csvreader = csv.reader(csvfile, delimiter=',')
341+
csv_keys = csvreader.__next__() # header row
342+
nlines = 0 # count number of non-header rows
343+
for line in csvreader:
344+
nlines += 1
345+
346+
assert_equal(sorted(csv_keys), ['diffusion b value number',
347+
'gradient orientation number'])
348+
assert_equal(nlines, 8) # 8 volumes present in DTI.PAR

0 commit comments

Comments
 (0)