- This repository contains
mesoSPIM-control, a Python/PyQt application for mesoSPIM light-sheet microscopes. - The codebase mixes GUI code, acquisition logic, plugin infrastructure, docs, and hardware integrations.
- Many installations are customized per microscope; make narrow, reversible changes and avoid overwriting local hardware behavior.
- The worktree is often dirty and may include line-ending-only noise; inspect nearby changes before editing.
- Main entry point:
mesoSPIM/mesoSPIM_Control.py - Main application modules:
mesoSPIM/src/ - Hardware/config files:
mesoSPIM/config/ - Plugins:
mesoSPIM/src/plugins/ - Tests:
mesoSPIM/test/ - Docs:
docs/source/, published with Sphinx
- Preserve user or lab-specific configuration. Do not rewrite example configs or hardware paths unless the task requires it.
- Prefer small, targeted edits over sweeping refactors.
- Match the surrounding file style instead of normalizing old code to a new standard.
- Be careful with files that may already have unrelated local edits.
- Treat built artifacts in
docs/build/as generated unless the user explicitly asks to edit them.
- Existing
AGENTS.md: none was present at repo root when this file was created. - Cursor rules: no
.cursorrulesor.cursor/rules/files were found. - Copilot rules: no
.github/copilot-instructions.mdfile was found.
- Python target:
>=3.12according topyproject.toml. - Core runtime dependencies are listed in
requirements-conda-mamba.txt,requirements-clean-python.txt, andpyproject.toml. - The app is typically run in a conda/mamba environment with PyQt5 and hardware libraries installed.
- Some commands below fail in a bare environment if optional dependencies like
PyQt5,pytest, or hardware drivers are missing.
- Create/install the main environment with
pip install -r requirements-conda-mamba.txt. - Alternative lightweight dependency list:
pip install -r requirements-clean-python.txt. - Launch demo mode from repo root with
python mesoSPIM/mesoSPIM_Control.py -D. - Launch demo mode from
mesoSPIM/withpython mesoSPIM_Control.py -D. - Installed console script entry point:
mesospim-control.
- Automated coverage is limited because much of the software depends on physical hardware.
- Follow the repo's intended validation order: demo mode first, then real hardware if the change touches acquisition/device code.
- Unit tests exist in
mesoSPIM/test/, but some are old, environment-sensitive, interactive, or hardware-dependent. - Do not assume every historical test can run headlessly in CI.
- Run all repository tests from the
mesoSPIM/directory:python -m pytest test/. - Run one test file:
python -m pytest test/test_tiling.py -q. - Run one pytest test by keyword:
python -m pytest test/test_tiling.py -k image_counts -q. - Run one unittest-style test directly:
python -m unittest test.test_tiling.TestTilingWizard.test_image_counts. - Run legacy module-style test command noted in the file:
python -m unittest test.test_tiling. - If running from repo root, many tests need
mesoSPIM/on the import path because they importsrc...directly. - Hardware-oriented tests like
test_serial.pyshould only be run on the matching device setup. test_writing_speed.pyis interactive and disk-heavy; do not run it in automation.
- Syntax-check specific files:
python -m py_compile path/to/file.py. - Quick repo status:
git status --short. - Ignore CRLF-only noise while reviewing:
git diff --ignore-cr-at-eol --stat. - Review recent branch history:
git log --oneline --decorate -10. - Build docs on Linux/macOS:
make -C docs html. - Build docs on Windows:
docs\make.bat html. - Docs dependencies are not pinned separately; install
sphinx,furo,myst-parser, andsphinx-designif missing.
- No repo-level
ruff,black,isort,flake8, ormypyconfiguration was found. - There is no enforced autoformatter configuration in
pyproject.toml. - A
.ruff_cache/directory exists, which suggests ad hoc local Ruff usage, but not a committed Ruff policy. - Default to manual, minimal formatting changes.
- Do not mass-reformat files just because a local formatter would change them.
- Follow the file's existing import layout unless you are touching the section anyway.
- In new or heavily edited files, prefer standard library imports first, third-party imports second, local imports last.
- Keep one import per line when practical; avoid comma-packed imports in new code.
- Prefer explicit imports over wildcard imports.
- Preserve local relative-import conventions inside
mesoSPIM/src/. - Be aware that some older modules rely on running from the
mesoSPIM/directory and importsrc...directly.
- Use 4-space indentation.
- Keep whitespace changes minimal, especially in legacy modules.
- Match surrounding quote style; the repo uses both single and double quotes.
- Keep docstrings and UI strings concise.
- Avoid introducing non-ASCII unless the file already needs it.
- Avoid broad line wrapping churn unless you are already rewriting the block.
- Type hints are encouraged for new or significantly changed code, but they are not universal in the existing codebase.
- Add types where they improve clarity for APIs, plugin contracts, helpers, and non-trivial state structures.
- Do not force full typing retrofits across old PyQt or hardware modules.
- Prefer concrete container types when useful, e.g.
dict[str, Any],list[str],Path. - When extending plugin APIs, keep runtime behavior and documented types aligned.
- Follow local naming conventions, even when they differ from strict PEP 8.
- Many classes use project-specific names like
mesoSPIM_MainWindow; preserve that style in adjacent code. - Use
snake_casefor new functions, methods, variables, and module-level helpers unless the file clearly uses a different convention. - Use
CapWordsfor new standalone classes unless a project-specific prefix is already established. - Constants are generally uppercase when treated as constants.
- Plugin classes should expose stable classmethods like
name(),description(), andapi_version().
- Prefer raising specific exceptions (
ValueError,FileNotFoundError,ImportError) when the caller can act on them. - Use logging for operational context; many modules initialize
logger = logging.getLogger(__name__). - Log actionable context with failures, especially for plugins, device I/O, and model loading.
- Avoid swallowing exceptions silently.
- If you must catch broad exceptions around optional hardware/plugin imports, log enough context to debug the failure.
- Preserve pass-through or fallback behavior where the application must stay usable without optional components.
- Keep signal/slot code explicit and readable.
- Avoid blocking the GUI thread with long-running work.
- When editing dialogs or windows, preserve existing widget wiring and state refresh behavior.
- For UI text, prefer practical operator-facing wording over framework jargon.
- Validate GUI-affecting changes in demo mode when possible.
- Plugin discovery and contracts live under
mesoSPIM/src/plugins/. - Keep plugin API changes backward-aware; discovery is dynamic and may load external lab plugins.
- Do not break
ImageWriterorImageProcessorregistration flows casually. - When adding configurable processor parameters, keep
parameter_descriptions()metadata and runtimeconfigure()behavior consistent. - Prefer clear failure messages for missing optional dependencies such as PyTorch-based processors.
- Any code in
mesoSPIM/src/devices/, waveform generation, stage control, or acquisition timing may affect real hardware. - Preserve fallback behavior for demo mode.
- Do not remove safety warnings or initialization guards unless you understand the hardware consequence.
- Avoid changing default voltages, trigger ordering, or serial behavior without checking config interactions.
- If a change touches live acquisition or stopping behavior, call out the need for bench validation.
- Keep
README.mdanddocs/source/aligned when both describe the same workflow. - The Sphinx config in
docs/source/conf.pyincludes mocks and platform shims so docs can build without hardware libraries. - Prefer updating docs when behavior, plugin authoring, or setup steps change.
- Do not edit generated HTML in
docs/build/unless explicitly asked.
- Before editing, inspect local diffs if the surrounding area may already be modified.
- After code changes, run the smallest reasonable verification command.
- For pure Python edits,
python -m py_compile ...is a good low-risk baseline. - For GUI changes, note whether validation was limited to static review, syntax check, demo mode, or real hardware.
- When test commands fail because dependencies are absent, report that clearly instead of guessing.
- Start from repo root unless a test explicitly expects
mesoSPIM/as the working directory. - For a single test, prefer
python -m pytest test/test_tiling.py -qfrommesoSPIM/. - For a single unittest target, prefer
python -m unittest test.test_tiling.TestTilingWizard.test_image_countsfrommesoSPIM/. - For docs-only changes, build docs if Sphinx is available; otherwise document the missing dependency.
- For hardware-facing changes, recommend manual demo-mode and on-instrument validation in the final note.
- Use
PROJECT_CONTEXT.mdonly for session-handoff notes: recent changes, current priorities, validation gaps, and open questions. - Keep stable repo guidance in
AGENTS.md; do not duplicate build commands, coding conventions, or evergreen architecture notes inPROJECT_CONTEXT.md. - Read
PROJECT_CONTEXT.mdbefore starting work, and update it at the end of each work session so the next agent can get up to speed quickly. PROJECT_CONTEXT.mdis ignored by git and will not be included in commits. Use it for local notes only. If the file does not exist, create it.