Skip to content

[RTM] ENH: Clear header extensions when making ref image #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions niworkflows/interfaces/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,19 @@ def _run_interface(self, runtime):
global_signal = data_slice.mean(axis=0).mean(
axis=0).mean(axis=0)

# Slicing may induce inconsistencies with shape-dependent values in extensions.
# For now, remove all. If this turns out to be a mistake, we can select extensions
# that don't break pipeline stages.
in_nii.header.extensions.clear()

n_volumes_to_discard = is_outlier(global_signal)

out_ref_fname = os.path.abspath("ref_image.nii.gz")

if n_volumes_to_discard == 0:
if in_nii.shape[-1] > 40:
slice = data_slice[:, :, :, 20:40]
slice_fname = os.path.abspath("slice.nii.gz")
nb.Nifti1Image(slice, in_nii.affine,
nb.Nifti1Image(data_slice[:, :, :, 20:40], in_nii.affine,
in_nii.header).to_filename(slice_fname)
else:
slice_fname = self.inputs.in_file
Expand Down