From fae8e14661532c4114cfa7abb179203467d20190 Mon Sep 17 00:00:00 2001 From: "arnaud.bore" Date: Wed, 8 Mar 2023 20:31:15 -0500 Subject: [PATCH 1/3] first round --- scilpy/image/operations.py | 4 +- scilpy/viz/utils.py | 2 +- .../scil_compute_bundle_voxel_label_map.py | 2 +- scripts/scil_estimate_bundles_diameter.py | 3 +- scripts/tests/test_compute_MT_maps.py | 107 +++++++++--------- scripts/tests/test_compute_ihMT_maps.py | 36 +++--- 6 files changed, 80 insertions(+), 74 deletions(-) diff --git a/scilpy/image/operations.py b/scilpy/image/operations.py index 89140aec7..a5c9c3cf5 100644 --- a/scilpy/image/operations.py +++ b/scilpy/image/operations.py @@ -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 diff --git a/scilpy/viz/utils.py b/scilpy/viz/utils.py index ef9db6b02..2ade2fb67 100644 --- a/scilpy/viz/utils.py +++ b/scilpy/viz/utils.py @@ -25,4 +25,4 @@ def get_colormap(name): colors_list) return cmap - return plt.cm.get_cmap(name) + return plt.colormaps.get_cmap(name) diff --git a/scripts/scil_compute_bundle_voxel_label_map.py b/scripts/scil_compute_bundle_voxel_label_map.py index 685ba9a84..16569e2fa 100755 --- a/scripts/scil_compute_bundle_voxel_label_map.py +++ b/scripts/scil_compute_bundle_voxel_label_map.py @@ -331,7 +331,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) diff --git a/scripts/scil_estimate_bundles_diameter.py b/scripts/scil_estimate_bundles_diameter.py index dd48f5980..05d7b7630 100755 --- a/scripts/scil_estimate_bundles_diameter.py +++ b/scripts/scil_estimate_bundles_diameter.py @@ -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, diff --git a/scripts/tests/test_compute_MT_maps.py b/scripts/tests/test_compute_MT_maps.py index 4f5fa12b7..03ea39525 100644 --- a/scripts/tests/test_compute_MT_maps.py +++ b/scripts/tests/test_compute_MT_maps.py @@ -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, @@ -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): @@ -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, @@ -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): @@ -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, @@ -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 diff --git a/scripts/tests/test_compute_ihMT_maps.py b/scripts/tests/test_compute_ihMT_maps.py index a89778614..be74317b2 100644 --- a/scripts/tests/test_compute_ihMT_maps.py +++ b/scripts/tests/test_compute_ihMT_maps.py @@ -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') @@ -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') @@ -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') @@ -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') @@ -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, @@ -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') @@ -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 From a368957b99d82d1ece237674399797e53258d612 Mon Sep 17 00:00:00 2001 From: "arnaud.bore" Date: Wed, 8 Mar 2023 21:51:23 -0500 Subject: [PATCH 2/3] second round --- scilpy/gradientsampling/multiple_shell_energy.py | 2 +- scilpy/tractanalysis/todi.py | 2 +- scripts/scil_compute_bundle_voxel_label_map.py | 3 +-- scripts/scil_compute_kurtosis_metrics.py | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scilpy/gradientsampling/multiple_shell_energy.py b/scilpy/gradientsampling/multiple_shell_energy.py index ca87f1da0..478d5bc8f 100644 --- a/scilpy/gradientsampling/multiple_shell_energy.py +++ b/scilpy/gradientsampling/multiple_shell_energy.py @@ -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)) diff --git a/scilpy/tractanalysis/todi.py b/scilpy/tractanalysis/todi.py index 1dd600bf8..d8f2597b3 100644 --- a/scilpy/tractanalysis/todi.py +++ b/scilpy/tractanalysis/todi.py @@ -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 diff --git a/scripts/scil_compute_bundle_voxel_label_map.py b/scripts/scil_compute_bundle_voxel_label_map.py index 16569e2fa..ace1f58fa 100755 --- a/scripts/scil_compute_bundle_voxel_label_map.py +++ b/scripts/scil_compute_bundle_voxel_label_map.py @@ -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 diff --git a/scripts/scil_compute_kurtosis_metrics.py b/scripts/scil_compute_kurtosis_metrics.py index 5139464d3..592be9bd3 100755 --- a/scripts/scil_compute_kurtosis_metrics.py +++ b/scripts/scil_compute_kurtosis_metrics.py @@ -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, From 007514e37b6563a569f62de9ad22d777c130ad70 Mon Sep 17 00:00:00 2001 From: "arnaud.bore" Date: Thu, 9 Mar 2023 09:52:22 -0500 Subject: [PATCH 3/3] put frhreault as default reviewer if not arnaudbore doing the PR --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4341b6e8f..ba92ab55d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,7 +51,7 @@ pipeline { pullRequest.createReviewRequests(['arnaudbore']) } else{ - pullRequest.createReviewRequests(['GuillaumeTh']) + pullRequest.createReviewRequests(['frheault']) } } }