Skip to content

Commit

Permalink
Provide odd length kernels (#343)
Browse files Browse the repository at this point in the history
* Provide odd length kernels

* Address reviews

* Try debuging Travis...
  • Loading branch information
NicolasGensollen authored Feb 23, 2021
1 parent 53336b6 commit 5502a6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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

0 comments on commit 5502a6e

Please sign in to comment.