Skip to content

Commit 4442f9e

Browse files
committed
fix: more robust bvec loading
1 parent 5af5f21 commit 4442f9e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/nifreeze/data/dmri.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,12 @@ def load(
280280
)
281281
elif bvec_file and bval_file:
282282
bvecs = np.loadtxt(bvec_file, dtype="float32") # shape (3, N)
283+
if bvecs.shape[0] != 3 and bvecs.shape[1] == 3:
284+
bvecs = bvecs.T
285+
283286
bvals = np.loadtxt(bval_file, dtype="float32") # shape (N,)
284287
# Stack to shape (4, N)
285-
grad = np.vstack((bvecs, bvals)).T
288+
grad = np.vstack((bvecs, bvals))
286289
else:
287290
raise RuntimeError(
288291
"No gradient data provided. "

0 commit comments

Comments
 (0)