From 0adc75ab839c7b346e4fc9a57801b96afd787c27 Mon Sep 17 00:00:00 2001 From: Guillaume Theaud Date: Tue, 13 Oct 2020 15:05:32 -0400 Subject: [PATCH] Fix saving for reordering --- scripts/scil_reorder_dwi_philips.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/scil_reorder_dwi_philips.py b/scripts/scil_reorder_dwi_philips.py index da296dca5..5f1fd8f44 100755 --- a/scripts/scil_reorder_dwi_philips.py +++ b/scripts/scil_reorder_dwi_philips.py @@ -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')