{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How To: Measure Colony Size and Intensity\n", "\n", "Extract area, perimeter, circularity, and intensity statistics from\n", "detected colonies using `MeasureSize`, `MeasureShape`, and\n", "`MeasureIntensity`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import phenotypic as pht\n", "from phenotypic.data import load_yeast_plate\n", "from phenotypic.enhance import GaussianBlur, CLAHE\n", "from phenotypic.detect import OtsuDetector\n", "from phenotypic.measure import MeasureSize, MeasureShape, MeasureIntensity" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pipeline = pht.ImagePipeline(\n", " ops=[GaussianBlur(sigma=2.0), CLAHE(clip_limit=0.01), OtsuDetector()],\n", " meas=[MeasureSize(), MeasureShape(), MeasureIntensity()],\n", ")\n", "df = pipeline.apply_and_measure(load_yeast_plate())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Size Metrics" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": "df[[\"Size_Area\", \"Size_IntegratedIntensity\"]].describe()" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Shape Metrics" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": "df[[\"Shape_Circularity\", \"Shape_Solidity\", \"Shape_Eccentricity\"]].describe()" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Intensity Metrics" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": "df[[\"Intensity_MeanIntensity\", \"Intensity_MedianIntensity\", \"Intensity_StandardDeviationIntensity\"]].describe()" }, { "cell_type": "markdown", "metadata": {}, "source": [ "The DataFrame has one row per colony. Filter, sort, and group using\n", "standard pandas operations to answer biological questions." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.11.0" } }, "nbformat": 4, "nbformat_minor": 4 }