Skip to content
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

[ENH] Native to Stereo #224

Merged
merged 4 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
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
80 changes: 80 additions & 0 deletions macapype/nodes/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,3 +714,83 @@ def _list_outputs(self):
outputs['out_file'] = self.new_value
print(outputs['out_file'])
return outputs


def pad_zero_mri(img_file, pad_val=10, const=0):

import os
import nibabel as nib
import numpy as np

from nipype.utils.filemanip import split_filename as split_f

if pad_val:

print("pad_val = {}, running pad_zero_mri".format(pad_val))

img = nib.load(img_file)
img_arr = np.array(img.dataobj)
img_arr_copy = np.copy(img_arr)

img_arr_copy_padded = np.pad(
img_arr_copy,
pad_width=pad_val,
mode='constant',
constant_values=const)

img_padded = nib.Nifti1Image(img_arr_copy_padded,
header=img.header,
affine=img.affine)
path, fname, ext = split_f(img_file)

img_padded_file = os.path.abspath("padded_" + fname + ext)

nib.save(img_padded, img_padded_file)

return img_padded_file

else:
print("pad_val = {}, skipping pad_zero_mri".format(pad_val))
return img_file


"""

def pad_zero_mri(img_file, pad_val=10):

import os
import nibabel as nib
import numpy as np

from nipype.utils.filemanip import split_filename as split_f

img = nib.load(img_file)
img_arr = np.array(img.dataobj)
img_header = img.header
print("Pad_val {}".format(pad_val))

print(img_arr.shape)

img_arr_padded = np.pad(
img_arr,
pad_width=pad_val,
mode='constant',
constant_values=0)

print(img_arr_padded.shape)

img_header.set_data_shape(img_arr_padded.shape)

img_padded = nib.Nifti1Image(img_arr_padded,
header=img_header,
affine=img.affine)

path, fname, ext = split_f(img_file)

img_padded_file = os.path.abspath("padded_" + fname + ext)

nib.save(img_padded, img_padded_file)

return img_padded_file

"""
Loading