From 89e98aa72f49c65437f11cbd9d30cf8790eb7722 Mon Sep 17 00:00:00 2001 From: NicolasGensollen Date: Tue, 9 Feb 2021 16:06:06 +0100 Subject: [PATCH 1/3] Provide odd length kernels --- pypreprocess/coreg.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pypreprocess/coreg.py b/pypreprocess/coreg.py index f2b781d1..516969c4 100644 --- a/pypreprocess/coreg.py +++ b/pypreprocess/coreg.py @@ -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 From 77d9566d78a0e271b6e51a7abd55634d9a6e9163 Mon Sep 17 00:00:00 2001 From: NicolasGensollen Date: Tue, 9 Feb 2021 18:58:15 +0100 Subject: [PATCH 2/3] Address reviews --- pypreprocess/coreg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pypreprocess/coreg.py b/pypreprocess/coreg.py index 516969c4..c5786e10 100644 --- a/pypreprocess/coreg.py +++ b/pypreprocess/coreg.py @@ -61,13 +61,13 @@ def compute_similarity_from_jhist(jh, fwhm=None, cost_fun='nmi'): np.linspace(-1 * lim[0], lim[0], num=2 * lim[0])) # Pad with zero to get odd length - krn1 = np.append(krn1,0) + 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 = np.append(krn2, 0) krn2 = krn2 / np.sum(krn2) # smooth the histogram with kern1 x kern2 From 7d14cbe5f9d462faa26a557a612a602cd7fd45a2 Mon Sep 17 00:00:00 2001 From: NicolasGensollen Date: Tue, 9 Feb 2021 19:26:58 +0100 Subject: [PATCH 3/3] Try debuging Travis... --- pypreprocess/io_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pypreprocess/io_utils.py b/pypreprocess/io_utils.py index 2b1d9cc2..b081f663 100644 --- a/pypreprocess/io_utils.py +++ b/pypreprocess/io_utils.py @@ -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