aicsimageio.writers package¶
Submodules¶
aicsimageio.writers.ome_tiff_writer module¶
-
class
aicsimageio.writers.ome_tiff_writer.
OmeTiffWriter
(file_path, overwrite_file=None)[source]¶ Bases:
object
This class can take arrays of pixel values and do the necessary metadata creation to write them properly in OME xml format.
- Parameters
file_path – Path to image output location
overwrite_file – Flag to overwrite image or pass over image if it already exists. None: (default) throw IOError if file exists True: overwrite existing file if file exists False: silently perform no write actions if file exists
Example
>>> image = numpy.ndarray([1, 10, 3, 1024, 2048]) ... writer = ome_tiff_writer.OmeTiffWriter("file.ome.tif") ... writer.save(image)
Using the context manager to close the write once done.
>>> image2 = numpy.ndarray([5, 486, 210]) ... with ome_tiff_writer.OmeTiffWriter("file2.ome.tif") as writer2: ... writer2.save(image2)
Convert a CZI file into OME-Tiff
>>> reader = cziReader.CziReader("file3.czi") ... with ome_tiff_writer.OmeTiffWriter("file3.ome.tif") as writer3: ... writer.save(reader.load())
-
save
(data, ome_xml=None, channel_names=None, image_name='IMAGE0', pixels_physical_size=None, channel_colors=None, dimension_order='STZCYX')[source]¶ Save an image with the proper OME XML metadata.
- Parameters
data (An array of 3, 4, or 5 dimensions to be written out to a file.)
ome_xml (A premade omexml.OMEXML object to use for metadata.)
channel_names (The names for each channel to be put into the OME metadata)
image_name (The name of the image to be put into the OME metadata)
pixels_physical_size (The physical size of each pixel in the image)
channel_colors (The channel colors to be put into the OME metadata)
dimension_order (The dimension ordering in the data array. Will be assumed)
STZCYX if not specified
aicsimageio.writers.png_writer module¶
-
class
aicsimageio.writers.png_writer.
PngWriter
(file_path, overwrite_file=None)[source]¶ Bases:
object
This class can take 3D arrays of CYX pixel values and writes them to a PNG.
- Parameters
file_path – Path to image output location
overwrite_file – Flag to overwrite image or pass over image if it already exists. None : (default) throw IOError if file exists. True : overwrite existing file if file exists. False: silently perform no write actions if file exists.
Examples
Construct and use as object
>>> image = numpy.ndarray([3, 1024, 2048]) ... writer = png_writer.PngWriter("file.png") ... writer.save(image)
Construct within a context manager
>>> image2 = numpy.ndarray([3, 1024, 2048]) ... with png_writer.PngWriter("file2.png") as writer2: ... writer2.save(image2)
-
save
(data)[source]¶ Takes in an array of CYX pixel values and writes them to a PNG.
- Parameters
data – A CYX or YX array with C being the rgb channels for each pixel value.
-
save_slice
(data, z=0, c=0, t=0)[source]¶ Exactly the same functionality as save() but allows the interface to be the same as OmeTiffWriter.
- Parameters
data – A CYX or YX array with C being the rgb channels for each pixel value.
z – An arbitrary Z index that does nothing.
c – An arbitrary C index that does nothing.
t – An arbitrary T index that does nothing.
aicsimageio.writers.writer module¶
-
class
aicsimageio.writers.writer.
Writer
(file_path: Union[str, pathlib.Path])[source]¶ Bases:
abc.ABC
Write STCZYX data arrays to file, with accompanying metadata Will overwrite existing files of same name.
- Parameters
file_path (types.PathLike) – Path to image output location
Examples
Construct and use as object
>>> image = numpy.ndarray([1, 10, 3, 1024, 2048]) ... writer = DerivedWriter("file.ome.tif") ... writer.save(image) ... writer.close()
Construct with a context manager
>>> image2 = numpy.ndarray([5, 486, 210]) ... with DerivedWriter("file2.ome.tif") as writer2: ... writer2.set_metadata(myMetaData) ... writer2.save(image2)