Skip to content

Commit

Permalink
Merge pull request #690 from arnaudbore/fix_messages_during_tests
Browse files Browse the repository at this point in the history
Fix some deprecated import and fix some tests
  • Loading branch information
arnaudbore authored Mar 9, 2023
2 parents bfe2b08 + 007514e commit cdbccac
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 80 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pipeline {
pullRequest.createReviewRequests(['arnaudbore'])
}
else{
pullRequest.createReviewRequests(['GuillaumeTh'])
pullRequest.createReviewRequests(['frheault'])
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion scilpy/gradientsampling/multiple_shell_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def grad_equality_constraints(bvecs, *args):
Returns
-------
array shape (N, N * 3). grad[i, j] contains
$\partial f_i / \partial x_j$
$\\partial f_i / \\partial x_j$
"""
N = bvecs.shape[0] / 3
bvecs = bvecs.reshape((N, 3))
Expand Down
4 changes: 2 additions & 2 deletions scilpy/image/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

import nibabel as nib
import numpy as np
from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage import (binary_closing, binary_dilation,
binary_erosion, binary_opening)
binary_erosion, binary_opening,
gaussian_filter)

from scilpy.utils.util import is_float

Expand Down
2 changes: 1 addition & 1 deletion scilpy/tractanalysis/todi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dipy.data import get_sphere
from dipy.reconst.shm import sf_to_sh
import numpy as np
from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage import gaussian_filter

import scilpy.tractanalysis.todi_util as todi_u

Expand Down
2 changes: 1 addition & 1 deletion scilpy/viz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ def get_colormap(name):
colors_list)
return cmap

return plt.cm.get_cmap(name)
return plt.colormaps.get_cmap(name)
5 changes: 2 additions & 3 deletions scripts/scil_compute_bundle_voxel_label_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
from scilpy.tractanalysis.streamlines_metrics import compute_tract_counts_map
from scilpy.tractanalysis.tools import cut_outside_of_mask_streamlines
from scilpy.tractanalysis.distance_to_centroid import min_dist_to_centroid
from scipy.ndimage import map_coordinates
from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage import gaussian_filter, map_coordinates
from scilpy.utils.streamlines import uniformize_bundle_sft
from scilpy.viz.utils import get_colormap

Expand Down Expand Up @@ -331,7 +330,7 @@ def main():
tmp_corr = ndi.map_coordinates(corr_map,
sft.streamlines._data.T-0.5,
order=0)
cmap = plt.get_cmap(args.colormap)
cmap = plt.colormaps[args.colormap]
new_sft.data_per_point['color'] = ArraySequence(
new_sft.streamlines)

Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_compute_kurtosis_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
from dipy.io.gradients import read_bvals_bvecs
from dipy.core.gradients import gradient_table

from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage import gaussian_filter

from scilpy.io.image import get_data_as_mask
from scilpy.io.utils import (add_overwrite_arg, assert_inputs_exist,
Expand Down
3 changes: 1 addition & 2 deletions scripts/scil_estimate_bundles_diameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
import nibabel as nib
import numpy as np
from scipy.linalg import svd
from scipy.ndimage import map_coordinates
from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage import map_coordinates, gaussian_filter

from scilpy.io.streamlines import load_tractogram_with_reference
from scilpy.io.utils import (add_overwrite_arg,
Expand Down
107 changes: 55 additions & 52 deletions scripts/tests/test_compute_MT_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,37 @@ def test_execution_MT_no_option(script_runner):
in_mask = os.path.join(get_home(), 'MT', 'mask.nii.gz')

in_e1_mtoff = os.path.join(get_home(),
'MT', 'echo-1_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-1_acq-mtoff_mtsat.nii.gz')
in_e2_mtoff = os.path.join(get_home(),
'MT', 'echo-2_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-2_acq-mtoff_mtsat.nii.gz')
in_e3_mtoff = os.path.join(get_home(),
'MT', 'echo-3_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-3_acq-mtoff_mtsat.nii.gz')
in_e4_mtoff = os.path.join(get_home(),
'MT', 'echo-4_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-4_acq-mtoff_mtsat.nii.gz')
in_e5_mtoff = os.path.join(get_home(),
'MT', 'echo-5_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-5_acq-mtoff_mtsat.nii.gz')

in_e1_mton = os.path.join(get_home(),
'MT', 'echo-1_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-1_acq-mton_mtsat.nii.gz')
in_e2_mton = os.path.join(get_home(),
'MT', 'echo-2_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-2_acq-mton_mtsat.nii.gz')
in_e3_mton = os.path.join(get_home(),
'MT', 'echo-3_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-3_acq-mton_mtsat.nii.gz')
in_e4_mton = os.path.join(get_home(),
'MT', 'echo-4_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-4_acq-mton_mtsat.nii.gz')
in_e5_mton = os.path.join(get_home(),
'MT', 'echo-5_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-5_acq-mton_mtsat.nii.gz')

in_e1_t1w = os.path.join(get_home(),
'MT', 'echo-1_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-1_acq-t1w_mtsat.nii.gz')
in_e2_t1w = os.path.join(get_home(),
'MT', 'echo-2_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-2_acq-t1w_mtsat.nii.gz')
in_e3_t1w = os.path.join(get_home(),
'MT', 'echo-3_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-3_acq-t1w_mtsat.nii.gz')
in_e4_t1w = os.path.join(get_home(),
'MT', 'echo-4_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-4_acq-t1w_mtsat.nii.gz')
in_e5_t1w = os.path.join(get_home(),
'MT', 'echo-5_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-5_acq-t1w_mtsat.nii.gz')

# no option
ret = script_runner.run('scil_compute_MT_maps.py', tmp_dir.name,
Expand All @@ -62,8 +62,9 @@ def test_execution_MT_no_option(script_runner):
'--in_mton', in_e1_mton, in_e2_mton, in_e3_mton,
in_e4_mton, in_e5_mton,
'--in_t1w', in_e1_t1w, in_e2_t1w, in_e3_t1w,
in_e4_t1w, in_e5_t1w)
return ret.success
in_e4_t1w, in_e5_t1w,
'-f')
assert ret.success


def test_execution_MT_prefix(script_runner):
Expand All @@ -72,37 +73,37 @@ def test_execution_MT_prefix(script_runner):
in_mask = os.path.join(get_home(), 'MT', 'mask.nii.gz')

in_e1_mtoff = os.path.join(get_home(),
'MT', 'echo-1_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-1_acq-mtoff_mtsat.nii.gz')
in_e2_mtoff = os.path.join(get_home(),
'MT', 'echo-2_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-2_acq-mtoff_mtsat.nii.gz')
in_e3_mtoff = os.path.join(get_home(),
'MT', 'echo-3_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-3_acq-mtoff_mtsat.nii.gz')
in_e4_mtoff = os.path.join(get_home(),
'MT', 'echo-4_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-4_acq-mtoff_mtsat.nii.gz')
in_e5_mtoff = os.path.join(get_home(),
'MT', 'echo-5_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-5_acq-mtoff_mtsat.nii.gz')

in_e1_mton = os.path.join(get_home(),
'MT', 'echo-1_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-1_acq-mton_mtsat.nii.gz')
in_e2_mton = os.path.join(get_home(),
'MT', 'echo-2_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-2_acq-mton_mtsat.nii.gz')
in_e3_mton = os.path.join(get_home(),
'MT', 'echo-3_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-3_acq-mton_mtsat.nii.gz')
in_e4_mton = os.path.join(get_home(),
'MT', 'echo-4_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-4_acq-mton_mtsat.nii.gz')
in_e5_mton = os.path.join(get_home(),
'MT', 'echo-5_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-5_acq-mton_mtsat.nii.gz')

in_e1_t1w = os.path.join(get_home(),
'MT', 'echo-1_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-1_acq-t1w_mtsat.nii.gz')
in_e2_t1w = os.path.join(get_home(),
'MT', 'echo-2_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-2_acq-t1w_mtsat.nii.gz')
in_e3_t1w = os.path.join(get_home(),
'MT', 'echo-3_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-3_acq-t1w_mtsat.nii.gz')
in_e4_t1w = os.path.join(get_home(),
'MT', 'echo-4_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-4_acq-t1w_mtsat.nii.gz')
in_e5_t1w = os.path.join(get_home(),
'MT', 'echo-5_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-5_acq-t1w_mtsat.nii.gz')

# --out_prefix
ret = script_runner.run('scil_compute_MT_maps.py', tmp_dir.name,
Expand All @@ -113,8 +114,9 @@ def test_execution_MT_prefix(script_runner):
in_e4_mton, in_e5_mton,
'--in_t1w', in_e1_t1w, in_e2_t1w, in_e3_t1w,
in_e4_t1w, in_e5_t1w,
'--out_prefix', 'sub_01')
return ret.success
'--out_prefix', 'sub_01',
'-f')
assert ret.success


def test_execution_MT_B1_map(script_runner):
Expand All @@ -123,39 +125,39 @@ def test_execution_MT_B1_map(script_runner):
in_mask = os.path.join(get_home(), 'MT', 'mask.nii.gz')

in_e1_mtoff = os.path.join(get_home(),
'MT', 'echo-1_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-1_acq-mtoff_mtsat.nii.gz')
in_e2_mtoff = os.path.join(get_home(),
'MT', 'echo-2_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-2_acq-mtoff_mtsat.nii.gz')
in_e3_mtoff = os.path.join(get_home(),
'MT', 'echo-3_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-3_acq-mtoff_mtsat.nii.gz')
in_e4_mtoff = os.path.join(get_home(),
'MT', 'echo-4_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-4_acq-mtoff_mtsat.nii.gz')
in_e5_mtoff = os.path.join(get_home(),
'MT', 'echo-5_acq-mtoff_mtsat.nii.gz')
'MT', 'sub-001_echo-5_acq-mtoff_mtsat.nii.gz')

in_e1_mton = os.path.join(get_home(),
'MT', 'echo-1_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-1_acq-mton_mtsat.nii.gz')
in_e2_mton = os.path.join(get_home(),
'MT', 'echo-2_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-2_acq-mton_mtsat.nii.gz')
in_e3_mton = os.path.join(get_home(),
'MT', 'echo-3_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-3_acq-mton_mtsat.nii.gz')
in_e4_mton = os.path.join(get_home(),
'MT', 'echo-4_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-4_acq-mton_mtsat.nii.gz')
in_e5_mton = os.path.join(get_home(),
'MT', 'echo-5_acq-mton_mtsat.nii.gz')
'MT', 'sub-001_echo-5_acq-mton_mtsat.nii.gz')

in_e1_t1w = os.path.join(get_home(),
'MT', 'echo-1_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-1_acq-t1w_mtsat.nii.gz')
in_e2_t1w = os.path.join(get_home(),
'MT', 'echo-2_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-2_acq-t1w_mtsat.nii.gz')
in_e3_t1w = os.path.join(get_home(),
'MT', 'echo-3_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-3_acq-t1w_mtsat.nii.gz')
in_e4_t1w = os.path.join(get_home(),
'MT', 'echo-4_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-4_acq-t1w_mtsat.nii.gz')
in_e5_t1w = os.path.join(get_home(),
'MT', 'echo-5_acq-t1w_mtsat.nii.gz')
'MT', 'sub-001_echo-5_acq-t1w_mtsat.nii.gz')
in_b1_map = os.path.join(get_home(),
'MT', 'run-01_B1map.nii.gz')
'MT', 'sub-001_run-01_B1map.nii.gz')

# --in_B1_map
ret = script_runner.run('scil_compute_MT_maps.py', tmp_dir.name,
Expand All @@ -167,5 +169,6 @@ def test_execution_MT_B1_map(script_runner):
'--in_t1w', in_e1_t1w, in_e2_t1w, in_e3_t1w,
in_e4_t1w, in_e5_t1w,
'--in_B1_map', in_b1_map,
'--out_prefix', 'sub-01')
return ret.success
'--out_prefix', 'sub-01',
'-f')
assert ret.success
36 changes: 20 additions & 16 deletions scripts/tests/test_compute_ihMT_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_help_option(script_runner):
def test_execution_ihMT_no_option(script_runner):
os.chdir(os.path.expanduser(tmp_dir.name))

in_mask = os.path.join(get_home(), 'ihMT', 'mask.nii.gz')
in_mask = os.path.join(get_home(), 'ihMT', 'mask_resample.nii.gz')

in_e1_altnp = os.path.join(get_home(),
'ihMT', 'echo-1_acq-altnp_ihmt.nii.gz')
Expand Down Expand Up @@ -74,14 +74,15 @@ def test_execution_ihMT_no_option(script_runner):
in_e3_mtoff,
'--in_negative', in_e1_neg, in_e2_neg, in_e3_neg,
'--in_positive', in_e1_pos, in_e2_pos, in_e3_pos,
'--in_t1w', in_e1_t1w, in_e2_t1w, in_e3_t1w)
return ret.success
'--in_t1w', in_e1_t1w, in_e2_t1w, in_e3_t1w,
'-f')
assert ret.success


def test_execution_ihMT_prefix(script_runner):
os.chdir(os.path.expanduser(tmp_dir.name))

in_mask = os.path.join(get_home(), 'ihMT', 'mask.nii.gz')
in_mask = os.path.join(get_home(), 'ihMT', 'mask_resample.nii.gz')

in_e1_altnp = os.path.join(get_home(),
'ihMT', 'echo-1_acq-altnp_ihmt.nii.gz')
Expand Down Expand Up @@ -139,14 +140,15 @@ def test_execution_ihMT_prefix(script_runner):
'--in_positive', in_e1_pos, in_e2_pos,
in_e3_pos,
'--in_t1w', in_e1_t1w, in_e2_t1w, in_e3_t1w,
'--out_prefix', 'sub_01')
return ret.success
'--out_prefix', 'sub_01',
'-f')
assert ret.success


def test_execution_ihMT_filtering(script_runner):
os.chdir(os.path.expanduser(tmp_dir.name))

in_mask = os.path.join(get_home(), 'ihMT', 'mask.nii.gz')
in_mask = os.path.join(get_home(), 'ihMT', 'mask_resample.nii.gz')

in_e1_altnp = os.path.join(get_home(),
'ihMT', 'echo-1_acq-altnp_ihmt.nii.gz')
Expand Down Expand Up @@ -203,14 +205,15 @@ def test_execution_ihMT_filtering(script_runner):
'--in_positive', in_e1_pos, in_e2_pos, in_e3_pos,
'--in_t1w', in_e1_t1w, in_e2_t1w, in_e3_t1w,
'--out_prefix', 'sub-01',
'--filtering')
return ret.success
'--filtering',
'-f')
assert ret.success


def test_execution_ihMT_B1_map(script_runner):
os.chdir(os.path.expanduser(tmp_dir.name))

in_mask = os.path.join(get_home(), 'ihMT', 'mask.nii.gz')
in_mask = os.path.join(get_home(), 'ihMT', 'mask_resample.nii.gz')

in_e1_altnp = os.path.join(get_home(),
'ihMT', 'echo-1_acq-altnp_ihmt.nii.gz')
Expand Down Expand Up @@ -254,7 +257,7 @@ def test_execution_ihMT_B1_map(script_runner):
in_e3_t1w = os.path.join(get_home(),
'ihMT', 'echo-3_acq-T1w_ihmt.nii.gz')
in_b1_map = os.path.join(get_home(),
'ihMT', 'run-03_B1map.nii.gz')
'ihMT', 'B1map.nii.gz')

# --filtering
ret = script_runner.run('scil_compute_ihMT_maps.py', tmp_dir.name,
Expand All @@ -269,14 +272,15 @@ def test_execution_ihMT_B1_map(script_runner):
'--in_positive', in_e1_pos, in_e2_pos, in_e3_pos,
'--in_t1w', in_e1_t1w, in_e2_t1w, in_e3_t1w,
'--out_prefix', 'sub-01',
'--in_B1_map', in_b1_map)
return ret.success
'--in_B1_map', in_b1_map,
'-f')
assert ret.success


def test_execution_ihMT_single_echo(script_runner):
os.chdir(os.path.expanduser(tmp_dir.name))

in_mask = os.path.join(get_home(), 'ihMT', 'mask.nii.gz')
in_mask = os.path.join(get_home(), 'ihMT', 'mask_resample.nii.gz')

in_e1_altnp = os.path.join(get_home(),
'ihMT', 'echo-1_acq-altnp_ihmt.nii.gz')
Expand Down Expand Up @@ -335,5 +339,5 @@ def test_execution_ihMT_single_echo(script_runner):
in_e3_pos,
'--in_t1w', in_e1_t1w, in_e2_t1w, in_e3_t1w,
'--out_prefix', 'sub_01',
'--single_echo')
return ret.success
'--single_echo', '-f')
assert ret.success

0 comments on commit cdbccac

Please sign in to comment.