diff --git a/nd2reader/__init__.py b/nd2reader/__init__.py index 54169a4..264eb55 100644 --- a/nd2reader/__init__.py +++ b/nd2reader/__init__.py @@ -2,8 +2,7 @@ import logging from nd2reader.service import BaseNd2 from nd2reader.model import Image, ImageSet -log = logging.getLogger("nd2reader") -log.addHandler(logging.StreamHandler()) +log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) diff --git a/nd2reader/model/__init__.py b/nd2reader/model/__init__.py index 7d61046..9c15ac2 100644 --- a/nd2reader/model/__init__.py +++ b/nd2reader/model/__init__.py @@ -6,7 +6,7 @@ import array import struct -log = logging.getLogger("nd2reader") +log = logging.getLogger(__name__) class Channel(object): diff --git a/nd2reader/service/__init__.py b/nd2reader/service/__init__.py index 7fab1fa..65f2662 100644 --- a/nd2reader/service/__init__.py +++ b/nd2reader/service/__init__.py @@ -10,7 +10,7 @@ import logging from nd2reader.model import Channel from datetime import datetime -log = logging.getLogger("nd2reader") +log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) chunk = namedtuple('Chunk', ['location', 'length']) field_of_view = namedtuple('FOV', ['number', 'x', 'y', 'z', 'pfs_offset']) @@ -161,12 +161,25 @@ class Nd2Reader(object): def absolute_start(self): if self._absolute_start is None: for line in self._metadata['ImageTextInfo']['SLxImageTextInfo'].values(): + absolute_start_12 = None + absolute_start_24 = None + + # ND2s seem to randomly switch between 12- and 24-hour representations. + try: + absolute_start_24 = datetime.strptime(line, "%m/%d/%Y %H:%M:%S") + except ValueError: + pass + try: - absolute_start = datetime.strptime(line, "%m/%d/%Y %I:%M:%S %p") + absolute_start_12 = datetime.strptime(line, "%m/%d/%Y %I:%M:%S %p") except ValueError: + pass + + if not absolute_start_12 and not absolute_start_24: continue - else: - self._absolute_start = absolute_start + + self._absolute_start = absolute_start_12 if absolute_start_12 else absolute_start_24 + return self._absolute_start @property diff --git a/setup.py b/setup.py index 2e77d88..b7acbd1 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup( name="nd2reader", packages=find_packages(), - version="0.9.6", + version="0.9.7", install_requires=[ 'numpy', ],