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

Provide odd length kernels #343

Merged
merged 3 commits into from
Feb 23, 2021
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
4 changes: 4 additions & 0 deletions pypreprocess/coreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ def compute_similarity_from_jhist(jh, fwhm=None, cost_fun='nmi'):
krn1 = centered_smoothing_kernel(fwhm[0],
np.linspace(-1 * lim[0], lim[0],
num=2 * lim[0]))
# Pad with zero to get odd length
krn1 = np.append(krn1, 0)
krn1 = krn1 / np.sum(krn1)
krn2 = centered_smoothing_kernel(fwhm[1],
np.linspace(-1 * lim[1], lim[1],
num=2 * lim[1]))
# Pad with zero to get odd length
krn2 = np.append(krn2, 0)
krn2 = krn2 / np.sum(krn2)

# smooth the histogram with kern1 x kern2
Expand Down
6 changes: 5 additions & 1 deletion pypreprocess/io_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,11 @@ def is_3D(image):
"""Check whether image is 3D"""

if isinstance(image, str):
image = nibabel.load(image)
if os.path.exists(image):
image = nibabel.load(image)
else:
raise FileNotFoundError("File {} not found.".format(
image))
elif isinstance(image, list):
image = nibabel.concat_images(image,
check_affines=False
Expand Down