Contributed Nodes

These are modules that are not central to the functioning of MorphoCut, but are nevertheless useful in its application context.

EcoTaxa

Read and write EcoTaxa archives.

EcoTaxa is a web application dedicated to the visual exploration and the taxonomic annotation of images that illustrate the beauty of planktonic biodiversity.”

class morphocut.contrib.ecotaxa.Archive(archive_fn, mode='r')[source]

A generic archive reader and writer for ZIP and TAR archives.

read_member(member_fn)[source]
Raises

MemberNotFoundError – if a member was not found

class morphocut.contrib.ecotaxa.EcotaxaObject(meta, image_data, archive_fn=None, index_fn=None, default_mode=None)[source]
meta

Object metadata

Type

Mapping

index_fn

Source index filename inside the archive.

Type

str, optional

archive_fn

Sourche archive filename.

Type

str, optional

default_mode

Default mode for image loading. See PIL Modes.

Type

str, optional

get_image(img_rank=None, mode=None)[source]

Get an image for the object.

Parameters
  • img_rank – Rank of the image. (Default: The first one.)

  • mode – Mode to load the image. See PIL Modes.

morphocut.contrib.ecotaxa.EcotaxaReader()[source]

Stream Read an archive of images and metadata that is importable to EcoTaxa.

Parameters
  • archive_fn (str, Variable) – Location of the archive file.

  • query (str, Variable, optional) – A query string to select a subset of the data. See pandas.DataFrame.query().

  • prepare_data (callable, optional) – A function that receives a pandas.DataFrame and returns a modified version.

Returns

object – An EcotaxaObject that allows to access image(s) and metadata.

To read multiple image ranks, provide a tuple of ints as img_rank. The first output will then be a tuple of images.

The TSV file needs at least an img_file_name column that provides the name of the image file. Other columns are read from meta.

The TSV file MAY contain a row of types after the header ("[f]" for numeric columns, "[t]" else).

Example

with Pipeline() as p:
    obj = EcotaxaReader("path/to/archive.zip")
p.transform_stream()
morphocut.contrib.ecotaxa.EcotaxaWriter()[source]

Create an archive of images and metadata that is importable to EcoTaxa.

Parameters
  • archive_fn (str) – Location of the output file.

  • fnames_images (Tuple, Variable, or a list thereof) – Tuple of (filename, image) or a list of such tuples. filename is the name in the archive. image is a NumPy array. The file extension has to be one of ".jpg", ".png" or ".gif" to meet the specifications of EcoTaxa.

  • meta (Mapping or Variable, optional) – Metadata to store in the TSV file. Each key corresponds to a column in the resulting file.

  • object_meta (Mapping or Variable, optional) – Metadata stored with object_ prefix.

  • acq_meta (Mapping or Variable, optional) – Metadata stored with acq_ prefix.

  • process_meta (Mapping or Variable, optional) – Metadata stored with process_ prefix.

  • sample_meta (Mapping or Variable, optional) – Metadata stored with sample_ prefix.

  • meta_fn (str, optional) – TSV file. Must start with ecotaxa.

  • store_types (bool, optional) – Whether to add a row with types after the header. Defaults to True, according to EcoTaxa’s specifications.

If multiple images are provided, image and image_name must be tuples of the same length.

The TSV file will have the following columns by default:

  • img_file_name: Name of the image file (including extension)

  • img_rank: Rank of image to be displayed. Starts at 1.

Other columns are read from meta. The file will contain a column for each object in the stream.

Example

with Pipeline() as pipeline:
    image_fn = ...
    image = ImageReader(image_fn)
    meta = ... # Calculate some meta-data
    EcotaxaWriter("path/to/archive.zip", (image_fn, image), meta)
pipeline.transform_stream()

See also

For more information about the metadata fields, see the project import page of EcoTaxa.

exception morphocut.contrib.ecotaxa.MemberNotFoundError[source]
class morphocut.contrib.ecotaxa.TarArchive(archive_fn, mode='r')[source]
read_member(member_fn)[source]

Raises: MemberNotFoundError: if a member was not found

exception morphocut.contrib.ecotaxa.UnknownArchiveError[source]
class morphocut.contrib.ecotaxa.ZipArchive(archive_fn, mode='r')[source]
read_member(member)[source]

Raises: MemberNotFoundError: if a member was not found

ZooProcess

Feature calculation like in ZooProcess.

Zooprocess is a suite of routines in ImageJ macro language for Plankton image analysis.

morphocut.contrib.zooprocess.CalculateZooProcessFeatures()[source]

Calculate descriptive features similar to ZooProcess using skimage.measure.regionprops().

Parameters
  • regionprops (RegionProperties or Variable) – RegionProperties instance returned by FindRegions.

  • meta (dict or Variable, optional) – Meta-data dictionary to update.

  • prefix (str or Variable, optional) – Prefix for all keys.

Example

with Pipeline() as p:
    image = ...
    mask = ...

    regionprops = FindRegions(mask, image)

    features = CalculateZooProcessFeatures(regionprops)
morphocut.contrib.zooprocess.regionprop2zooprocess(prop)[source]

Calculate zooprocess features from skimage regionprops.

Notes

  • date/time specify the time of the sampling, not of the processing.