phenotypic.phenotypic_cli module#

PhenoTypic CLI#

A command-line interface for executing PhenoTypic ImagePipelines on directories of images. This script allows for parallel processing of images, saving both measurements and visual quality control overlays.

Usage:

python -m phenotypic PIPELINE_JSON INPUT_DIR OUTPUT_DIR [OPTIONS]

Example

python -m phenotypic my_pipeline.json ./raw_images ./results –n-jobs 4

phenotypic.phenotypic_cli.process_single_image(image_path: Path, meas_dir: Path, overlay_dir: Path, pipeline: ImagePipeline, image_cls: Type[Image], read_kwargs: Dict[str, Any]) DataFrame | None[source]#

Processes a single image of a microbe colony on solid media agar by applying an image processing pipeline, generating measurements, and creating a graphical overlay output. This function is highly versatile, allowing the user to control how images are read, analyzed, and stored based on provided arguments.

Parameters:
  • image_path (Path) – Path to the image file representing the microbe colony on agar. Adjusting this variable changes which colony image is analyzed.

  • meas_dir (Path) – Directory where the measurement results (CSV) will be saved. The choice of directory affects the organization of analysis results and resultant data pipeline workflows.

  • overlay_dir (Path) – Directory for saving visual overlays. This allows inspection of how the overlay corresponds to the processed regions in the image. Choose a directory accessible to tools used for review.

  • pipeline (ImagePipeline) – A sequence of image processing steps applied to the input image. The pipeline heavily influences the analysis’ sensitivity and accuracy in extracting colony features like size, shape, or density.

  • image_cls (Type[Image]) – Class responsible for reading and processing the input image. Changing this affects how the image format is handled (e.g., handling raw images produced in specific microscopy settings).

  • read_kwargs (Dict[str, Any]) – Parameters passed when reading the image (e.g., color modes, compression). Modifying these parameters tailors how images are interpreted and may change the fidelity of image data used in downstream analyses.

Returns:

A DataFrame containing microbiological measurements for the processed image, such as colony area, perimeter, and optical density. If processing fails, returns None. Adjustments in inputs or pipeline steps directly affect the resulting metrics.

Return type:

Optional[pd.DataFrame]

Raises:
  • This function handles all internal exceptions and reports processing failures

  • with user-friendly messages, allowing review of errors without interrupting a

  • batch process.