Plugins and Extensibility
The phenotyping pipeline supports optional plugin registries for metadata extractors, report sections, and property functions.
Table of Contents
Section titled “Table of Contents”Property Functions
Section titled “Property Functions”Register custom property functions for use with compute_properties. Property functions have signature (image2d, mask2d) -> Dict[str, float].
Registering a Property
Section titled “Registering a Property”from phenome.plugins import register_property
def my_blob_counter(image2d, mask2d): """Count blobs in image.""" if image2d is None: return {"my_blob_count": float("nan")} # ... your logic ... return {"my_blob_count": 42.0}
register_property("my_blobs", my_blob_counter)Using a Registered Property
Section titled “Using a Registered Property”from phenome.plugins import get_property, get_blob_properties
df = pheno.compute_properties( property_preset="none", additional_property_functions={"image": [get_blob_properties]})
blob_fn = get_property("blob")if blob_fn: df = pheno.compute_properties( property_preset="none", additional_property_functions={"image": [blob_fn]} )Built-in Properties
Section titled “Built-in Properties”| Name | Function | Description |
|---|---|---|
blob |
get_blob_properties |
DoG blob detection (count, area, intensity stats) |
Metadata Extractors
Section titled “Metadata Extractors”Register metadata extractors for use with find_files(metadata_fn=...) or for discovery.
Registering an Extractor
Section titled “Registering an Extractor”from phenome.plugins import register_metadata_extractorimport re
def extract_from_path_template(path: str): """Extract metadata from path like /data/plate1/well_A01.tif""" match = re.search(r"plate(\d+)/well_([A-Z]\d+)", path) if match: return {"file_path": path, "plate": match.group(1), "well": match.group(2)} return {"file_path": path}
register_metadata_extractor("plate_well", extract_from_path_template)Using a Registered Extractor
Section titled “Using a Registered Extractor”from phenome.plugins import get_metadata_extractor
extractor = get_metadata_extractor("plate_well")if extractor: df = pheno.find_files("/data/images", metadata_fn=extractor)Report Sections
Section titled “Report Sections”Register custom HTML section generators for inclusion in generate_report().
Registering a Section
Section titled “Registering a Section”from phenome.plugins import register_report_section
def my_custom_section(pipeline, title: str = "Custom Analysis") -> str: """Generate HTML for a custom report section.""" n_images = pipeline.results.n_images return f""" <section id="custom"> <h2>{title}</h2> <p>Processed {n_images} images.</p> </section> """
register_report_section("custom_analysis", my_custom_section)Report integration: Custom report sections are registered in the plugin registry but are not automatically included in generate_report() by default. To add them to your reports, you need to extend generate_report in your project to iterate over get_report_sections() and append the generated HTML to the report body. The registry provides the discovery mechanism; the main report generator does not call it by default.
See Also
Section titled “See Also”| Topic | Document |
|---|---|
| Extension points overview | Extending the Pipeline |
| Metadata extractors | Experiment Details |
| Property functions | Select properties |
| Report API | Report Generation |
