Browse Source

resolves #112: removed ImageGroup object and image_sets method, as they were deprecated because of their general uselessness

zolfa-add_slices_loading
jim 9 years ago
parent
commit
fd3c67d65b
3 changed files with 0 additions and 63 deletions
  1. +0
    -25
      nd2reader/interface.py
  2. +0
    -1
      nd2reader/model/__init__.py
  3. +0
    -37
      nd2reader/model/group.py

+ 0
- 25
nd2reader/interface.py View File

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from nd2reader.model import ImageGroup
from nd2reader.parser import get_parser
from nd2reader.version import get_version
import warnings
@ -82,30 +81,6 @@ class Nd2(object):
for i in range(start, stop)[::step]:
yield self[i]
@property
def image_sets(self):
"""
Iterates over groups of related images. This is useful if your ND2 contains multiple fields of view.
A typical use case might be that you have, say, four areas of interest that you're monitoring, and every
minute you take a bright field and GFP image of each one. For each cycle, this method would produce four
ImageSet objects, each containing one bright field and one GFP image.
:return: model.ImageSet()
"""
warnings.warn("Nd2.image_sets will be removed from the nd2reader library in the near future.",
DeprecationWarning)
for frame in self.frames:
image_group = ImageGroup()
for fov in self.fields_of_view:
for channel_name in self.channels:
for z_level in self.z_levels:
image = self.get_image(frame, fov, channel_name, z_level)
if image is not None:
image_group.add(image)
yield image_group
@property
def date(self):
return self._metadata.date


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

@ -1,2 +1 @@
from nd2reader.model.image import Image
from nd2reader.model.group import ImageGroup

+ 0
- 37
nd2reader/model/group.py View File

@ -1,37 +0,0 @@
import collections
class ImageGroup(object):
"""
A group of images that were taken at roughly the same time and in the same field of view.
"""
def __init__(self):
self._images = collections.defaultdict(dict)
def __len__(self):
""" The number of images in the image set. """
return sum([len(channel) for channel in self._images.values()])
def __repr__(self):
return "\n".join(["<ND2 Image Group>",
"Image count: %s" % len(self)])
def get(self, channel, z_level=0):
"""
Retrieve an image with a given channel and z-level. For most users, z_level will always be 0.
:type channel: str
:type z_level: int
"""
return self._images.get(channel).get(z_level)
def add(self, image):
"""
Stores an image.
:type image: nd2reader.model.Image()
"""
self._images[image.channel][image.z_level] = image

Loading…
Cancel
Save