|
1 | 1 | """ Tests for the parrec2nii exe code
|
2 | 2 | """
|
3 |
| -import imp, numpy |
| 3 | +import imp, numpy, sys, os |
4 | 4 | from numpy.testing import (assert_almost_equal,
|
5 | 5 | assert_array_equal)
|
6 | 6 | from nose.tools import assert_equal
|
|
9 | 9 | from nibabel.tests.test_parrec import EG_PAR, VARY_PAR
|
10 | 10 | from os.path import dirname, join, isfile, basename
|
11 | 11 | from ..tmpdirs import InTemporaryDirectory
|
12 |
| -BINDIR = join(dirname(dirname(dirname(__file__))), 'bin') |
| 12 | +## Possible locations of the parrec2nii executable; |
| 13 | +BINDIRS = [join(dirname(dirname(dirname(__file__))), 'bin'), |
| 14 | + sys.executable, |
| 15 | + join(os.environ['VIRTUALENV'],'bin')] |
13 | 16 |
|
14 | 17 |
|
15 | 18 | AN_OLD_AFFINE = numpy.array(
|
|
24 | 27 | [ 0.86045705, 0. , 7.78655376, -58.25061211],
|
25 | 28 | [ 0. , 0. , 0. , 1. ]])
|
26 | 29 |
|
| 30 | +def find_parrec2nii(): |
| 31 | + for bindir in BINDIRS: |
| 32 | + parrec2niiPath = join(bindir, 'parrec2nii') |
| 33 | + if isfile(parrec2niiPath): |
| 34 | + return parrec2niiPath |
| 35 | + else: |
| 36 | + raise AssertionError('Could not find parrec2nii executable.') |
| 37 | + |
27 | 38 | def test_parrec2nii_sets_qform_with_code2():
|
28 | 39 | """Unit test that ensures that set_qform() is called on the new header.
|
29 | 40 | """
|
30 |
| - parrec2nii = imp.load_source('parrec2nii', join(BINDIR, 'parrec2nii')) |
| 41 | + parrec2nii = imp.load_source('parrec2nii', find_parrec2nii()) |
31 | 42 | parrec2nii.verbose.switch = False
|
32 | 43 |
|
33 | 44 | parrec2nii.io_orientation = Mock()
|
@@ -67,7 +78,7 @@ def test_parrec2nii_save_load_qform_code():
|
67 | 78 | picks up the qform.
|
68 | 79 | """
|
69 | 80 | import nibabel
|
70 |
| - parrec2nii = imp.load_source('parrec2nii', join(BINDIR, 'parrec2nii')) |
| 81 | + parrec2nii = imp.load_source('parrec2nii', find_parrec2nii()) |
71 | 82 | parrec2nii.verbose.switch = False
|
72 | 83 |
|
73 | 84 | opts = Mock()
|
|
0 commit comments