Skip to content

Commit

Permalink
Fix saving for reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeTh committed Oct 13, 2020
1 parent c668d68 commit 0adc75a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scripts/scil_reorder_dwi_philips.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,18 @@ def main():
dwis = nb.load(args.dwi)

newIndex = valideInputs(oTable, dwis, bvals, bvecs)

bvecs = bvecs[newIndex]
bvals = bvals[newIndex]

data = dwis.get_fdata(dtype=np.float32)
data = dwis.dataobj.get_unscaled()
data = data[:, :, :, newIndex]

nb.save(nb.Nifti1Image(data.astype(dwis.get_data_dtype()), dwis.affine,
header=dwis.header), output_filenames[0])
tmp = nb.Nifti1Image(data, dwis.affine, header=dwis.header)
tmp.header['scl_slope'] = dwis.dataobj.slope
tmp.header['scl_inter'] = dwis.dataobj.inter
tmp.update_header()

nb.save(tmp, output_filenames[0])
np.savetxt(args.baseName + '.bval', bvals.reshape(1, len(bvals)), '%d')
np.savetxt(args.baseName + '.bvec', bvecs.T, '%0.15f')

Expand Down

0 comments on commit 0adc75a

Please sign in to comment.