Browse Source

extract absolute start time of acquisition

zolfa-add_slices_loading
jim 10 years ago
parent
commit
719fe46f86
1 changed files with 19 additions and 1 deletions
  1. +19
    -1
      nd2reader/service/__init__.py

+ 19
- 1
nd2reader/service/__init__.py View File

@ -8,6 +8,7 @@ from StringIO import StringIO
from collections import namedtuple
import logging
from nd2reader.model import Channel
from datetime import datetime
log = logging.getLogger("nd2reader")
log.setLevel(logging.DEBUG)
@ -36,6 +37,10 @@ class BaseNd2(object):
"""
return self._metadata['ImageAttributes']['SLxImageAttributes']['uiWidth']
@property
def absolute_start(self):
return self._reader.absolute_start
@property
def channels(self):
metadata = self._metadata['ImageMetadataSeq']['SLxPictureMetadata']['sPicturePlanes']
@ -126,6 +131,7 @@ class Nd2Reader(object):
"""
def __init__(self, filename):
self._absolute_start = None
self._filename = filename
self._file_handler = None
self._chunk_map_start_location = None
@ -138,7 +144,7 @@ class Nd2Reader(object):
@property
def _dimensions(self):
if self.__dimensions is None:
# TODO: Replace this with a single regex
# The particular slot that this data shows up in changes (seemingly) randomly
for line in self._metadata['ImageTextInfo']['SLxImageTextInfo'].values():
if "Dimensions:" in line:
metadata = line
@ -151,6 +157,18 @@ class Nd2Reader(object):
break
return self.__dimensions
@property
def absolute_start(self):
if self._absolute_start is None:
for line in self._metadata['ImageTextInfo']['SLxImageTextInfo'].values():
try:
absolute_start = datetime.strptime(line, "%m/%d/%Y %I:%M:%S %p")
except ValueError:
continue
else:
self._absolute_start = absolute_start
return self._absolute_start
@property
def fh(self):
if self._file_handler is None:


Loading…
Cancel
Save