From c0438228b971e5f401c6a59a92b235e3065ac19f Mon Sep 17 00:00:00 2001 From: karp2601 Date: Thu, 12 Dec 2024 13:59:09 -0500 Subject: [PATCH 1/3] Small update of read_bvals_bvecs --- scripts/scil_viz_gradients_screenshot.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/scil_viz_gradients_screenshot.py b/scripts/scil_viz_gradients_screenshot.py index 64d9ac7da..4ed7357ab 100755 --- a/scripts/scil_viz_gradients_screenshot.py +++ b/scripts/scil_viz_gradients_screenshot.py @@ -12,6 +12,7 @@ import os from dipy.data import get_sphere +from dipy.io.gradients import read_bvals_bvecs from scilpy.gradients.bvec_bval_tools import identify_shells from scilpy.io.utils import (add_overwrite_arg, @@ -120,11 +121,8 @@ def main(): if len(args.in_gradient_scheme) == 2: in_gradient_schemes = args.in_gradient_scheme in_gradient_schemes.sort() # [bval, bvec] - # bvecs/bvals (FSL) format, X Y Z AND b (or transpose) - points = np.genfromtxt(in_gradient_schemes[1]) - if points.shape[0] == 3: - points = points.T - bvals = np.genfromtxt(in_gradient_schemes[0]) + bvals, points = read_bvals_bvecs(in_gradient_schemes[0], + in_gradient_schemes[1]) centroids, shell_idx = identify_shells(bvals) else: # MRtrix format X, Y, Z, b From 3d832a511f4ddc9368a06e79483bc3374b6c727a Mon Sep 17 00:00:00 2001 From: karp2601 Date: Mon, 16 Dec 2024 15:13:00 -0500 Subject: [PATCH 2/3] Fixing function bug --- scripts/scil_viz_gradients_screenshot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/scil_viz_gradients_screenshot.py b/scripts/scil_viz_gradients_screenshot.py index 4ed7357ab..128c5bf21 100755 --- a/scripts/scil_viz_gradients_screenshot.py +++ b/scripts/scil_viz_gradients_screenshot.py @@ -89,7 +89,7 @@ def main(): if len(args.in_gradient_scheme) == 2: assert_gradients_filenames_valid(parser, args.in_gradient_scheme, - 'fsl') + True) elif len(args.in_gradient_scheme) == 1: basename, ext = os.path.splitext(args.in_gradient_scheme[0]) if ext in ['.bvec', '.bvecs', '.bvals', '.bval']: @@ -98,7 +98,7 @@ def main(): else: assert_gradients_filenames_valid(parser, args.in_gradient_scheme, - 'mrtrix') + False) else: parser.error('Depending on the gradient format you should have ' 'two files for FSL format and one file for MRtrix') From 92fbb646799162deab66783eb3c17b956aa56f60 Mon Sep 17 00:00:00 2001 From: Philippe Karan Date: Tue, 17 Dec 2024 15:05:04 -0500 Subject: [PATCH 3/3] Points to bvecs --- scripts/scil_viz_gradients_screenshot.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/scil_viz_gradients_screenshot.py b/scripts/scil_viz_gradients_screenshot.py index 128c5bf21..0eed8a728 100755 --- a/scripts/scil_viz_gradients_screenshot.py +++ b/scripts/scil_viz_gradients_screenshot.py @@ -121,14 +121,14 @@ def main(): if len(args.in_gradient_scheme) == 2: in_gradient_schemes = args.in_gradient_scheme in_gradient_schemes.sort() # [bval, bvec] - bvals, points = read_bvals_bvecs(in_gradient_schemes[0], - in_gradient_schemes[1]) + bvals, bvecs = read_bvals_bvecs(in_gradient_schemes[0], + in_gradient_schemes[1]) centroids, shell_idx = identify_shells(bvals) else: # MRtrix format X, Y, Z, b in_gradient_scheme = args.in_gradient_scheme[0] tmp = np.genfromtxt(in_gradient_scheme, delimiter=' ') - points = tmp[:, :3] + bvecs = tmp[:, :3] bvals = tmp[:, 3] centroids, shell_idx = identify_shells(bvals) @@ -159,7 +159,7 @@ def main(): for idx, val in enumerate(shell_idx): if val != 0 and val != -1: shell_idx[idx] -= len(np.where(indexes < val)[0]) - ms = build_ms_from_shell_idx(points, shell_idx) + ms = build_ms_from_shell_idx(bvecs, shell_idx) else: ms = [get_sphere(args.dipy_sphere).vertices]