From a56a7cc665d5d7c8f16cd1586358e81ba1f8bccd Mon Sep 17 00:00:00 2001 From: Ruben Verweij Date: Mon, 27 Feb 2017 16:30:48 +0100 Subject: [PATCH] Fix dtype at np.float64 --- nd2reader/parser.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/nd2reader/parser.py b/nd2reader/parser.py index 71f3367..61e45fc 100644 --- a/nd2reader/parser.py +++ b/nd2reader/parser.py @@ -94,19 +94,15 @@ class Parser(object): else: return raw_image_data - def get_dtype_from_metadata(self): + @staticmethod + def get_dtype_from_metadata(): """ Determine the data type from the metadata. + For now, always use float64 to prevent unexpected overflow errors when manipulating the data (calculating sums/ + means/etc.) :return: """ - bit_depth = self._raw_metadata.image_attributes[six.b('SLxImageAttributes')][six.b('uiBpcInMemory')] - dtype = np.float64 - if bit_depth <= 16: - dtype = np.float16 - elif bit_depth <= 32: - dtype = np.float32 - - return dtype + return np.float64 def _check_version_supported(self): """