From d045f677e4221919705e4b6336ef2adb9a5ad264 Mon Sep 17 00:00:00 2001 From: Malte Kuhlmann <malte-kuhlmann@web.de> Date: Thu, 10 Nov 2016 23:00:45 +0100 Subject: [PATCH] NaNs in input data are now changed to zeros to make the viewer functional for such files. --- vviewer/loadImage.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vviewer/loadImage.py b/vviewer/loadImage.py index a2e93d2..bfcbbbb 100644 --- a/vviewer/loadImage.py +++ b/vviewer/loadImage.py @@ -158,6 +158,12 @@ def loadImageFromFile(filename, pref, f_type): except RuntimeError: print("Cannot load .v file given!") + # if data contain NaNs convert to zero + if np.isnan(image.get_data()).any(): + notnan = image.get_data() + notnan[np.isnan(image.get_data())] = 0 + image = Nifti1Image(notnan, image.affine) + # allow 2d-images here: if len(image.get_data().shape) == 2: image = Nifti1Image(np.atleast_3d(image.get_data()), image.affine) -- GitLab