Functions

The list of functions. Full API documentation is available at megafish package.

load

Workflow Functions

Description

megafish.load.ims_cYXzyx

Creates Zarr arrays for image data in cycle, tile, and spatial (z, y, x) dimensions, then loads .ims images into these arrays using metadata from an image path CSV.

megafish.load.tif_cYXzyx

Creates Zarr arrays for image data in cycle, tile, and spatial (z, y, x) dimensions, then loads TIFF images into these arrays using metadata from an image path CSV.

megafish.load.stitched_ims

Reads a single stitched .ims image and divides it into smaller tile_y, tile_x segments for loading. This segmented image is primarily used for registration purposes.

megafish.load.stitched_tif

Reads a single stitched TIFF image and divides it into smaller tile_y, tile_x segments for loading.

Helper Functions

Description

megafish.load.make_dirlist

Generates a CSV file listing all cycle directories within a specified image directory. Each cycle directory must contain tiled images organized by color, z, y, and x.

megafish.load.make_imagepath_cYX_from_dirlist

Generates a CSV file mapping image paths to cycle, tile, and channel information based on a directory list CSV file.

megafish.load.make_imagepath_cYX

Generates a CSV file mapping image paths to cycle, tile, and channel information using CSV files containing image paths and cycle directories.

register

Workflow Functions

Description

megafish.register.shift_cycle_cYXyx

Calculates and stores cycle shifts for aligning image tiles based on phase correlation and feature matching.

megafish.register.shift_tile_cYXyx

Calculates and stores tile shifts for aligning image tiles based on phase correlation and feature matching.

megafish.register.dummy_shift_tile

Creates a dummy tile shifts CSV file with identity transformation values.

megafish.register.merge_shift_cYXyx

Merges cycle and tile shift transformations and saves the combined shifts as a CSV file.

megafish.register.registration_cYXyx

Registers and stitches image tiles based on transformation matrices, creating a registered dataset in Zarr format.

megafish.register.registration_cYXyx_noref

Registers and stitches image tiles based on transformation matrices, creating a registered dataset in Zarr format. This version does not use a reference stitched image group, but instead takes the stitched shape directly as input.

process

Workflow Functions

Description

megafish.process.projection

Creates a projection of the image data along a specified dimension using the specified method.

megafish.process.masking

Applies a mask to the image data, setting masked regions to zero.

megafish.process.gaussian_blur

Applies a Gaussian blur to the image data.

megafish.process.binarization

Applies binarization to the image data based on a threshold.

segment

Workflow Functions

Description

megafish.segment.dilation

Applies a binary dilation operation to the image data.

megafish.segment.merge_split_label

Merges split labels in an image dataset by applying offsets and resolving conflicts.

megafish.segment.grow_voronoi

Expands labeled regions in an image using a Voronoi-like approach, filling the image based on the nearest labeled pixel within a specified maximum distance.

megafish.segment.masking

Applies a mask to the target image data, setting values outside the mask to zero.

megafish.segment.fill_holes

Fills holes in labeled regions of an image dataset.

megafish.segment.remove_edge_mask

Removes labeled regions touching the edges of the image.

megafish.segment.label_edge

Identifies and labels the edges of labeled regions in an image dataset, with adjustable thickness.

megafish.segment.repeat_cycle

Repeats an image dataset over multiple cycles.

megafish.segment.info_csv

Generates segment information CSV files from image data stored in a Zarr file, summarizing properties such as area and centroid for each segment. Merges the CSV files into a single summary.

megafish.segment.merge_groups

Merges multiple groups of image data from a Zarr file into a single output group.

megafish.segment.normalize_groups

Normalizes intensity values across groups within an image dataset and computes the maximum intensity projection (MIP).

megafish.segment.select_slice

Selects a slice from an image dataset along a specified dimension.

megafish.segment.merge_to_one_group

Merges multiple groups of image data from a Zarr file into a single output group.

megafish.segment.scaled_mip

Normalizes intensity values across a specified dimension and computes the maximum intensity projection (MIP).

tif

Workflow Functions

Description

megafish.tif.save

Saves image data from a Zarr file as individual TIFF files for each chunk.

megafish.tif.load

Loads TIFF images into a Zarr dataset using the structure of a template group.

megafish.tif.save_tile_montage

Creates a tiled montage of images from a Zarr file and saves it as a single TIFF file.

megafish.tif.save_whole_image

Saves the entire image from a Zarr file as a TIFF file, with an option to clip the image.

megafish.tif.save_chunk

Saves specific chunks of image data from a Zarr file as individual TIFF files.

megafish.tif.save_rgb

Combines individual red, green, and blue image groups from a Zarr file into RGB images and saves them as TIFF files.

seqfish

Workflow Functions

Description

megafish.seqfish.DoG_filter

Applies a Difference of Gaussians (DoG) filter to the image data in a Zarr file.

megafish.seqfish.local_maxima

Detects local maxima in the image data within a Zarr file using a specified footprint.

megafish.seqfish.select_by_intensity_sd

Selects spots in the image data based on intensity, using a threshold defined by the mean intensity and standard deviation.

megafish.seqfish.select_by_intensity_threshold

Selects spots in the image data based on a specified intensity threshold.

megafish.seqfish.count_spots

Counts spots within labeled segments in the image data stored in a Zarr file and saves the results as CSV files.

megafish.seqfish.count_summary

Summarizes spot counts across multiple groups and cycles, merging the results with segment data and optionally gene names.

megafish.seqfish.spot_coordinates

Extracts coordinates of spots from the image data stored in a Zarr file and saves them as CSV files.

megafish.seqfish.spot_intensity

Computes the intensity of spots within segmented regions for each chunk of the image data and saves the results as CSV files.

Helper Functions

Description

megafish.seqfish.dog_sds

Calculates the standard deviations for the Difference of Gaussians (DoG) based on the point spread function (PSF) and imaging parameters.

megafish.seqfish.local_maxima_footprint

Calculates the footprint for detecting local maxima based on the point spread function (PSF) and imaging parameters.

decode

Workflow Functions

Description

megafish.decode.merfish_prefilter

Applies MERFISH prefiltering steps, including high-pass filtering, Richardson-Lucy deconvolution, and low-pass filtering.

megafish.decode.scaling

Scales the intensity of the image data stored in a Zarr file based on a given percentile and scaling factor.

megafish.decode.norm_value

Calculates the L2 norm (Euclidean norm) of the image data across cycles stored in a Zarr file.

megafish.decode.divide_by_norm

Divides the filtered image data by the calculated norm values for normalization.

megafish.decode.nearest_neighbor

Calculates the nearest neighbor for each pixel’s intensity trace in an image dataset using a precomputed codebook.

megafish.decode.split_nnd

Splits the nearest neighbor dataset into two separate datasets: one for the code indices and one for the distances.

megafish.decode.select_decoded

Filters decoded spots based on intensity, distance, and area criteria.

megafish.decode.coordinates_decoded

Extracts and records the coordinates of decoded spots within nuclei, saving the information in a CSV file for each chunk.

Helper Functions

Description

megafish.decode.gaussian_kernel

Generates a Gaussian kernel for spatial filtering. This kernel is used for spatial filtering in the MERFISH prefiltering step.

seqif

Workflow Functions

Description

megafish.seqif.TCEP_subtraction

Subtracts consecutive cycles in the image data, assuming cycles are organized as TCEP and non-TCEP pairs.

megafish.seqif.skip_odd_cycle

Selects and retains only the even cycles in the dataset, removing all odd cycles.

megafish.seqif.get_intensity

Calculates the mean intensity of labeled segments in an image dataset and saves the results as a CSV file.

megafish.seqif.intnensity_summary

Summarizes intensity data for multiple groups and saves the results as a CSV file.

view

Workflow Functions

Description

megafish.view.make_pyramid

Generates a pyramid of downsampled image data from a zarr dataset and writes it back to zarr storage.

megafish.view.mask_edge

Creates an edge mask around binary regions in an image using dilation and erosion.

napari

Function Name

Description

megafish.napari.tile_2d

Visualizes 2D tiled image data from a Zarr dataset using napari.

megafish.napari.registered

Visualizes multiscale registered image data from a Zarr dataset using napari, with optional gene name display.

megafish.napari.registered_is

Visualizes registered image data with image stitching from a Zarr dataset using napari, with optional gene name display.

megafish.napari.segment

Visualizes segmented and labeled image data from a Zarr dataset using napari, with support for multiscale images.

misc

Module Name

Description

megafish.config

Manages the resource configuration for the MEGA-FISH framework, allowing for GPU usage and scheduling settings with Dask.

megafish.utils

Provides utility functions for natural sorting, generating tile coordinates based on scanning patterns.