Lightweight utility to calculate spore dimension statistics and mycological parameters from CSV measurements.
Features
- Parses CSV rows with a "Length" column like "8.177, 5.515". These measurments are generated at the AMScope software using the "Vertical- Four Points" feature and then exporting the measurements to a CSV file.
- Computes min/max/mean/std for length and width, Q (L/W) statistics, coefficient of variation C, Me (mean of extremes) and Qe.
- Outputs a concise console summary and a detailed analysis log next to the input CSV.
Quick start
- Install dependencies:
pip install -r requirements.txt- Run the script:
python spore_mean_meas.py samples/Collybia_nuda.csvFiles and symbols
- Main script: spore_mean_meas.py — see functions
calculate_spore_dimensionsandwrite_log_file. - Sample data: samples/Collybia_nuda.csv, samples/Lepiota_subincarnata.csv
- Dependencies: requirements.txt
- License: LICENSE
Usage details
- Input CSV must contain a header with a column named
Lengthwhere each cell is formatted "height, width" (quotes optional). - The script writes an analysis log file next to the CSV named
<original>_analysis.log.
Example output (console)
6.11-7.52 (6.53) µm x 4.04-5.19 (4.56) µm; Q=1.43; σ=0.12; C=81.36%; Me=6.32 x 4.62; Qe=1.43
Analysis log saved to: samples/Collybia_nuda_analysis.log
Future improvements
The following enhancements are under consideration to improve code quality, readability, and statistical rigor:
Code Quality & Maintainability
- Replace dictionary return value with a
dataclassfor better type safety and IDE support - Extract formatting logic into a single reusable function to eliminate duplication between console and log output
- Migrate file path handling to
pathlib.Pathfor modern, cross-platform file operations
Robustness
- Improve CSV parsing to automatically strip whitespace: handle formats like
"8.177, 5.515"seamlessly
Statistical Enhancements
- Add median length and width statistics
- Compute interquartile range (IQR) for robustness analysis
- Include min/max of the Q ratio (L/W) across all measurements
- Consider skewness and kurtosis for distribution shape analysis
Contributing
- Open issues or pull requests for fixes and improvements.
- Keep changes minimal and include tests where appropriate.
Acknowledgements
- Special thanks to the outstanding work of the Asociación Micológica La Senderuela for their contributions to mycology, fieldwork, and community education — their efforts inspired and supported projects like this one.
License
- Released under the MIT License — see LICENSE.