Browse Source

fixed absolute start and redid logging

zolfa-add_slices_loading
jim 10 years ago
parent
commit
c7cc838663
4 changed files with 20 additions and 8 deletions
  1. +1
    -2
      nd2reader/__init__.py
  2. +1
    -1
      nd2reader/model/__init__.py
  3. +17
    -4
      nd2reader/service/__init__.py
  4. +1
    -1
      setup.py

+ 1
- 2
nd2reader/__init__.py View File

@ -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)


+ 1
- 1
nd2reader/model/__init__.py View File

@ -6,7 +6,7 @@ import array
import struct
log = logging.getLogger("nd2reader")
log = logging.getLogger(__name__)
class Channel(object):


+ 17
- 4
nd2reader/service/__init__.py View File

@ -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


+ 1
- 1
setup.py View File

@ -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',
],


Loading…
Cancel
Save