Skip to content

Commit

Permalink
RF: use nipy save to save image
Browse files Browse the repository at this point in the history
Avoid hacking with affine by saving with `nipy.save_image`.
  • Loading branch information
matthew-brett committed Sep 25, 2015
1 parent 046085f commit 7c696a5
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions nipy/algorithms/registration/scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from .groupwise_registration import SpaceTimeRealign
import nipy.algorithms.slicetiming as st
from nipy.io.api import save_image

timefuncs = st.timefuncs.SLICETIME_FUNCTIONS

Expand Down Expand Up @@ -159,12 +160,6 @@ def space_time_realign(input, tr, slice_order='descending', slice_dim=2,
if apply:
new_reggy = reggy.resample(align_runs=True)
for run_idx, new_im in enumerate(new_reggy):
new_data = new_im.get_data()
# We use the top 4 by 4 as the affine for the new file we will
# create:
new_aff = new_im.affine[:4, :4]
new_aff[:, 3] = new_im.affine[:4, 4]
new_ni = nib.Nifti1Image(new_data, new_aff)
# Save it out to a '.nii.gz' file:
old_fname_split = op.split(fnames[run_idx])
# We retain the file-name adding '_mc' regardless of where it's
Expand All @@ -174,7 +169,7 @@ def space_time_realign(input, tr, slice_order='descending', slice_dim=2,
new_path = old_fname_split[0]
else:
new_path = out_name
new_ni.to_filename(op.join(new_path, new_fname))
save_image(new_im, op.join(new_path, new_fname))

if make_figure:
figure, ax = plt.subplots(2)
Expand Down

0 comments on commit 7c696a5

Please sign in to comment.