From 09dedf203d8a137c37391382e79564235dd1a00b Mon Sep 17 00:00:00 2001 From: Gabriele Girelli Date: Mon, 31 Aug 2020 10:40:59 +0200 Subject: [PATCH] Fixed new init method --- nd2reader/reader.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/nd2reader/reader.py b/nd2reader/reader.py index 5e524eb..f97e1a0 100644 --- a/nd2reader/reader.py +++ b/nd2reader/reader.py @@ -11,6 +11,7 @@ class ND2Reader(FramesSequenceND): This is the main class: use this to process your .nd2 files. """ + _fh = None class_priority = 12 def __init__(self, fh): @@ -27,26 +28,24 @@ class ND2Reader(FramesSequenceND): ("The file %s you want to read with nd2reader" % fh) + " does not have extension .nd2." ) + fh = open(fh, "rb") - self = ND2Reader(open(fh, "rb")) - self.filename = fh - else: - self._fh = fh - self.filename = "" + self._fh = fh + self.filename = "" - self._parser = Parser(self._fh) + self._parser = Parser(self._fh) - # Setup metadata - self.metadata = self._parser.metadata + # Setup metadata + self.metadata = self._parser.metadata - # Set data type - self._dtype = self._parser.get_dtype_from_metadata() + # Set data type + self._dtype = self._parser.get_dtype_from_metadata() - # Setup the axes - self._setup_axes() + # Setup the axes + self._setup_axes() - # Other properties - self._timesteps = None + # Other properties + self._timesteps = None @classmethod def class_exts(cls):