Skip to content

Commit

Permalink
Merge pull request #338 from GuillaumeTh/Fix_reorder
Browse files Browse the repository at this point in the history
Fix saving for reordering
  • Loading branch information
jchoude authored Oct 14, 2020
2 parents 46be1ad + 0adc75a commit cf9faab
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 cf9faab

Please sign in to comment.