Skip to content

Commit 14d1793

Browse files
committed
Changed the total argument from hard coded value to dynamic value which is gotten from the image itself
1 parent f75534d commit 14d1793

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

WrapImage/nifti_wrapper.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def loop_over_first_n_minus_1_dimensions(arr):
8383
parser.add_argument("bvec_file", type=str, help="Path to the b-vector file.")
8484
parser.add_argument("bval_file", type=str, help="Path to the b-value file.")
8585
parser.add_argument("--affine", type=float, nargs="+", help="Affine matrix for NIfTI image.")
86-
parser.add_argument("--algorithm", type=str, choices=["algorithm1", "algorithm2"], default="OJ_GU_seg", help="Select the algorithm to use.")
86+
parser.add_argument("--algorithm", type=str, default="OJ_GU_seg", help="Select the algorithm to use.")
8787
parser.add_argument("algorithm_args", nargs=argparse.REMAINDER, help="Additional arguments for the algorithm.")
8888

8989
args = parser.parse_args()
@@ -103,7 +103,10 @@ def loop_over_first_n_minus_1_dimensions(arr):
103103
Dp_image = []
104104
D_image = []
105105

106-
for idx, view in tqdm(loop_over_first_n_minus_1_dimensions(data), desc=f"{args.algorithm} is fitting", dynamic_ncols=True, total=702464):
106+
# This is necessary for the tqdm to display progress bar.
107+
n = data.ndim
108+
total_iteration = np.prod(data.shape[:n-1])
109+
for idx, view in tqdm(loop_over_first_n_minus_1_dimensions(data), desc=f"{args.algorithm} is fitting", dynamic_ncols=True, total=total_iteration):
107110
[f_fit, Dp_fit, D_fit] = fit.osipi_fit(view, bvals)
108111
f_image.append(f_fit)
109112
Dp_image.append(Dp_fit)

0 commit comments

Comments
 (0)