Skip to content

Commit 660a0da

Browse files
committed
Fixed error in _rotate_bvec that was adding an extra entry to the output rotated_bvecs file and offsetting the correction by one volume.
Noted that the first two entries in the rotated_bvec files were 0,0,0 when the bvalues of the first two files were 0 and 1000. Plotting the original bvec against the rotated bvec (X component) showed what appeared to be a single volume offset (see black and red traces in attached plot) code issue: _rotate_bvec code initialised its output bvec array with the first entry of the input bvec array and then looped through FLIRT matrices starting at 1st position, but used a 0-based index for selecting the input from the bvec array solution : initialise output array filled with zeros, loop through FLIRT matrices from 0, use 0-based indexing for selecting input from the bvec array, set consecutive elements appropriately testing : nothing, other than plotting the X component for one subject
1 parent 61b46f9 commit 660a0da

File tree

1 file changed

+3
-3
lines changed
  • nipype/workflows/dmri/fsl

1 file changed

+3
-3
lines changed

nipype/workflows/dmri/fsl/dti.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,12 +554,12 @@ def _rotate_bvecs(in_bvec, in_matrix):
554554
name, _ = os.path.splitext(name)
555555
out_file = os.path.abspath('./%s_rotated.bvec' % name)
556556
bvecs = np.loadtxt(in_bvec)
557-
new_bvecs = [bvecs[:, 0]]
557+
new_bvecs = np.zeros(shape=bvecs.T.shape) #pre-initialise array, 3 col format
558558

559-
for i, vol_matrix in enumerate(in_matrix[1::]):
559+
for i, vol_matrix in enumerate(in_matrix[0::]): #start index at 0
560560
bvec = np.matrix(bvecs[:, i])
561561
rot = np.matrix(np.loadtxt(vol_matrix)[0:3, 0:3])
562-
new_bvecs.append((np.array(rot * bvec.T).T)[0])
562+
new_bvecs[i] = (np.array(rot * bvec.T).T)[0] #fill each volume with x,y,z as we go along
563563
np.savetxt(out_file, np.array(new_bvecs).T, fmt='%0.15f')
564564
return out_file
565565

0 commit comments

Comments
 (0)