def test_bad_id(): reader = ome_files.OMETIFFReader() filename = str(uuid.uuid4()) with pytest.raises(RuntimeError): reader.set_id(filename) with pytest.raises(TypeError): reader.set_id(0)
def get_metadata(filename): """ Simple wrapper for retrieving the 5D dimensions of an image from omefiles """ import ome_files reader = ome_files.OMETIFFReader() reader.set_id(filename) H, W, Z, T, C = reader.get_size_y(), reader.get_size_x( ), reader.get_size_z(), reader.get_size_t(), reader.get_size_c() reader.close() return H, W, Z, T, C
def read_plane(filename, plane): """ Simple wrapper for ome_files reader, choosing the correct ZCT coords from the plane value """ import ome_files reader = ome_files.OMETIFFReader() reader.set_id(filename) pixels = reader.open_array(plane) Z, C, T = reader.get_zct_coords(plane) reader.close() return pixels, Z, C, T
def dump(ome_tiff_fn): reader = ome_files.OMETIFFReader() reader.set_id(ome_tiff_fn) img_count = reader.get_image_count() H, W = reader.get_size_y(), reader.get_size_x() dtype = np.dtype(reader.get_pixel_dtype()) rgb = reader.get_rgb_channel_count(0) interleaved = reader.is_interleaved(0) print("image count: %d" % img_count) print("RGB sub-channels: %d (%sinterleaved)" % (rgb, "" if interleaved else "non-")) print("image size: %d x %d" % (W, H)) print("pixel type:", dtype) for i in range(img_count): pixels = reader.open_bytes_simple(i) out_fn = "plane_%d.tiff" % i print("writing %s" % out_fn) with closing(TIFF.open(out_fn, mode="w")) as fo: fo.write_image(pixels, write_rgb=(rgb > 1)) reader.close()
def setup_method(self): self.reader = ome_files.OMETIFFReader()
# -*- coding: utf-8 -*- """ Created on Tue Jun 5 17:21:10 2018 @author: Erick Martins Ratamero """ import sys reload(sys) sys.setdefaultencoding('utf8') #%matplotlib inline import numpy as np import matplotlib.pyplot as plt import ome_files reader = ome_files.OMETIFFReader() reader.set_id( '/home/erick/Nextcloud/CMCB/Michael_protrusions/smallstack.ome.tiff') # calculate number of planes no_planes = reader.get_image_count() print(no_planes) z = reader.get_size_z() print(z) # for each plane: for plane in range(no_planes): pixels = reader.open_bytes_simple(plane) # for each non-zero pixel: # get neighbourhood (adjust for borders) # fit circle to neighbourhood