MiHCSMe-py#
A Python package for handling MIHCSME (Minimum Information about a High Content Screening Microscopy Experiment) metadata from Excel spreadsheets to OMERO annotations and back.
Features#
- 📊 Parse MIHCSME Excel files into validated Pydantic models
- 🔄 Bidirectional conversion between Excel, Pydantic, and OMERO formats
- ✅ Built-in validation with helpful error messages
- 🚀 Modern CLI with rich terminal output
- 🐍 Type-safe with full type hints
- 📦 Ready for PyPI distribution
Installation#
Core Package#
Install the minimal package for use in Python scripts or OMERO.scripts:
With CLI Tools#
For interactive command-line use:
Development Installation#
For contributors:
Quick Start#
Parse Excel to JSON#
from mihcsme_py import parse_excel_to_model
# Parse Excel file
metadata = parse_excel_to_model("metadata.xlsx")
# Save as JSON
with open("metadata.json", "w") as f:
f.write(metadata.model_dump_json(indent=2))
Upload to OMERO#
import ezomero
from mihcsme_py import parse_excel_to_model, upload_metadata_to_omero
# Parse metadata
metadata = parse_excel_to_model("metadata.xlsx")
# Connect to OMERO
conn = ezomero.connect(
host="omero.example.com",
user="myuser",
password="mypassword"
)
# Upload to screen
result = upload_metadata_to_omero(
conn=conn,
metadata=metadata,
target_type="Screen",
target_id=123
)
print(f"Uploaded: {result['wells_succeeded']} wells")
conn.close()
CLI Usage#
# Parse Excel to JSON
mihcsme parse metadata.xlsx --output metadata.json
# Upload to OMERO
mihcsme upload metadata.xlsx \
--screen-id 123 \
--host omero.example.com \
--user myuser
# Convert JSON to Excel
mihcsme to-excel metadata.json --output metadata.xlsx
Data Flow#
Supported workflows:
- Excel → JSON: Parse and store metadata in version control
- JSON → Excel: Generate editable templates
- Excel → OMERO: Upload metadata annotations
- JSON → OMERO: Upload from stored metadata
Architecture#
The package provides four main components:
models.py: Pydantic models for MIHCSME metadataparser.py: Excel → Pydantic conversionwriter.py: Pydantic → Excel conversionuploader.py: Pydantic → OMERO uploadcli.py: Command-line interface (optional, requires[cli]install)