光声图像处理 / Photoacoustic Image Processing
Overview
This skill enables automated analysis of photoacoustic (PA) imaging data:
read multi-format PA data, compute quantitative image quality metrics,
generate publication-quality visualizations, and produce structured
experiment evaluation reports (Markdown / Word / PDF / PPT).
When to Use
Trigger this skill when the user:
- Uploads PA raw signal data (.mat, .npy, .csv) or reconstructed images
(.tiff, .png, .dcm, .nii) and asks for analysis - Asks to evaluate PA image quality with quantitative metrics (SNR, CNR,
spatial resolution, contrast-to-noise ratio) - Requests a structured experiment report with statistics and figures
- Wants side-by-side comparison of multiple PA reconstruction methods
- Uses keywords: 光声/photoacoustic/PAI/optoacoustic + 分析/报告/评价/指标
Workflow
Step 1: Data Ingestion
Use scripts/read_pa_data.py to load input data.
python scripts/read_pa_data.py INPUT_PATH [--format auto|mat|npy|dcm|nii|img]
The script auto-detects format and returns a standardized data dict:
{"data": ndarray, "metadata": {...}, "shape": tuple, "dtype": str}.
Supported formats:
| Format | Extensions | Typical PA Use Case |
|---|---|---|
| MATLAB | .mat | k-Wave simulation output, raw channel data |
| NumPy | .npy, .npz | Pre-processed PA arrays |
| DICOM | .dcm | Clinical PA/CT systems |
| NIfTI | .nii, .nii.gz | 3D volumetric PA |
| Image | .tiff, .png, .jpg | Reconstructed 2D PA images |
Step 2: Quantitative Analysis
Use scripts/analyze_pa.py to compute quality metrics.
python scripts/analyze_pa.py DATA_PATH [--roi ROI_PATH] [--metrics snr,cnr,resolution,contrast,all] [--output OUTPUT_DIR]
Core metrics (defined in references/metrics.md):
| Metric | Formula | What It Tells |
|---|---|---|
| SNR | 20·log₁₀(μ_signal / σ_background) | Signal-to-noise ratio in dB |
| CNR | μ_ROI - μ_bg | |
| Resolution | FWHM of edge spread function | Spatial resolution in μm/pixels |
| Contrast | (I_max - I_min) / (I_max + I_min) | Michelson contrast |
| SSIM | Structural similarity index | Perceptual similarity to reference |
Step 3: Report Generation
Use scripts/generate_report.py to produce the final deliverable.
python scripts/generate_report.py ANALYSIS_DIR [--format md|docx|pptx|pdf|all] [--template assets/report_template.md] [--output REPORT_PATH]
The report template (see assets/report_template.md) organizes content into:
- 实验概述 — data source, acquisition parameters, sample info
- 方法 — reconstruction algorithm, processing pipeline
- 结果 — figures with metric tables
- 讨论 — interpretation of results, comparison across methods
- 结论与评价 — quantitative summary and quality assessment
Prerequisites
Before using this skill, ensure the Python environment has required packages:
pip install numpy scipy matplotlib pandas pydicom nibabel Pillow scikit-image python-docx python-pptx reportlab
Verify with:
python -c "import numpy, scipy, matplotlib, pandas, pydicom, nibabel, PIL, skimage; print('All dependencies OK')"
Resources
scripts/
read_pa_data.py— Multi-format PA data loader (MAT/NPY/DICOM/NIfTI/images)analyze_pa.py— Quantitative metrics: SNR, CNR, resolution, contrast, SSIM, statisticsgenerate_report.py— Report generator: Markdown, DOCX, PPTX, PDF
references/
metrics.md— Detailed definitions and formulas for all PA image quality metrics
Load this when the user asks for specific metric definitions or custom metrics.
assets/
report_template.md— Structured experiment report template (Markdown)
Copy and customize per experiment.