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
- morphocut.contrib.ecotaxa.EcotaxaReader(archive_fn: str | Variable[str], *, query: str | None | Variable[str | None] = None, prepare_data: Callable[[pd.DataFrame], pd.DataFrame] | None = None, verbose=False, keep_going=False, print_summary=False, encoding='utf-8', index_pattern='*ecotaxa_*', columns: List | None = None, image_default_mode=None)[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.DataFrameand returns a modified version.
- Returns:
object – An
EcotaxaObjectthat 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_namecolumn that provides the name of the image file. Other columns are read frommeta.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(archive_fn: str | Variable[str], fnames_images: Tuple[str, ...] | Variable[Tuple[str, ...]] | List[Tuple[str, ...] | Variable[Tuple[str, ...]]], meta: Mapping | Variable[Mapping] | None = None, object_meta: Mapping | Variable[Mapping] | None = None, acq_meta: Mapping | Variable[Mapping] | None = None, process_meta: Mapping | Variable[Mapping] | None = None, sample_meta: Mapping | Variable[Mapping] | None = None, meta_fn: str | Variable[str] = 'ecotaxa_export.tsv', store_types: bool = True)[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.filenameis the name in the archive.imageis 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,
imageandimage_namemust 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.
- class morphocut.contrib.ecotaxa.TarArchive(archive_fn, mode='r')[source]
- read_member(member_fn)[source]
- Raises:
MemberNotFoundError – if a member was not found
- 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(regionprops: T | Variable[T], meta: dict | Variable[dict] | None = None, prefix: str | Variable[str] | None = None)[source]
Calculate descriptive features similar to ZooProcess using
skimage.measure.regionprops().- Parameters:
regionprops (RegionProperties or Variable) –
RegionPropertiesinstance returned byFindRegions.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)