diff --git a/vviewer/loadImage.py b/vviewer/loadImage.py
index a2e93d2526e0535dfb139c899757485e79bf931c..bfcbbbb41a6396c243a81642ecee4e54ab09ec43 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)