|
9 | 9 | import os
|
10 | 10 | from os.path import (dirname, join as pjoin, abspath, splitext, basename,
|
11 | 11 | exists)
|
12 |
| -import re |
| 12 | +import csv |
13 | 13 | from glob import glob
|
14 | 14 |
|
15 | 15 | import numpy as np
|
|
18 | 18 | from ..loadsave import load
|
19 | 19 | from ..orientations import flip_axis, aff2axcodes, inv_ornt_aff
|
20 | 20 |
|
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 |
23 | 22 | from nose import SkipTest
|
24 | 23 |
|
25 | 24 | from numpy.testing import assert_almost_equal
|
@@ -333,3 +332,17 @@ def test_parrec2nii_with_data():
|
333 | 332 | data_sorted = img.get_data().copy()
|
334 | 333 | assert_almost_equal(data[..., np.argsort(DTI_PAR_BVALS)], data_sorted)
|
335 | 334 | 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