cindra 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. cindra-1.0.0/.claude/settings.local.json +11 -0
  2. cindra-1.0.0/.claude-plugin/marketplace.json +13 -0
  3. cindra-1.0.0/.gitignore +216 -0
  4. cindra-1.0.0/CLAUDE.md +355 -0
  5. cindra-1.0.0/LICENSE +621 -0
  6. cindra-1.0.0/PKG-INFO +994 -0
  7. cindra-1.0.0/README.md +955 -0
  8. cindra-1.0.0/docs/Makefile +19 -0
  9. cindra-1.0.0/docs/make.bat +35 -0
  10. cindra-1.0.0/docs/source/api.rst +80 -0
  11. cindra-1.0.0/docs/source/conf.py +48 -0
  12. cindra-1.0.0/docs/source/index.rst +19 -0
  13. cindra-1.0.0/docs/source/welcome.rst +17 -0
  14. cindra-1.0.0/envs/cindra_dev_lin.yml +190 -0
  15. cindra-1.0.0/envs/cindra_dev_lin_spec.txt +186 -0
  16. cindra-1.0.0/envs/cindra_dev_osx.yml +175 -0
  17. cindra-1.0.0/envs/cindra_dev_osx_spec.txt +171 -0
  18. cindra-1.0.0/envs/cindra_dev_win.yml +110 -0
  19. cindra-1.0.0/envs/cindra_dev_win_spec.txt +106 -0
  20. cindra-1.0.0/plugins/cindra/.claude-plugin/plugin.json +18 -0
  21. cindra-1.0.0/plugins/cindra/skills/acquisition-data-preparation/SKILL.md +398 -0
  22. cindra-1.0.0/plugins/cindra/skills/cindra-mcp-environment-setup/SKILL.md +316 -0
  23. cindra-1.0.0/plugins/cindra/skills/multi-recording-configuration/SKILL.md +453 -0
  24. cindra-1.0.0/plugins/cindra/skills/multi-recording-processing/SKILL.md +370 -0
  25. cindra-1.0.0/plugins/cindra/skills/multi-recording-results/SKILL.md +324 -0
  26. cindra-1.0.0/plugins/cindra/skills/single-recording-configuration/SKILL.md +419 -0
  27. cindra-1.0.0/plugins/cindra/skills/single-recording-processing/SKILL.md +316 -0
  28. cindra-1.0.0/plugins/cindra/skills/single-recording-results/SKILL.md +409 -0
  29. cindra-1.0.0/plugins/cindra/skills/visualization/SKILL.md +477 -0
  30. cindra-1.0.0/pyproject.toml +245 -0
  31. cindra-1.0.0/src/cindra/__init__.py +44 -0
  32. cindra-1.0.0/src/cindra/classification/__init__.py +8 -0
  33. cindra-1.0.0/src/cindra/classification/classifier.npz +0 -0
  34. cindra-1.0.0/src/cindra/classification/classify.py +363 -0
  35. cindra-1.0.0/src/cindra/dataclasses/__init__.py +76 -0
  36. cindra-1.0.0/src/cindra/dataclasses/multi_recording_configuration.py +207 -0
  37. cindra-1.0.0/src/cindra/dataclasses/multi_recording_data.py +561 -0
  38. cindra-1.0.0/src/cindra/dataclasses/runtime_contexts.py +534 -0
  39. cindra-1.0.0/src/cindra/dataclasses/single_recording_configuration.py +563 -0
  40. cindra-1.0.0/src/cindra/dataclasses/single_recording_data.py +1619 -0
  41. cindra-1.0.0/src/cindra/dataclasses/version.py +22 -0
  42. cindra-1.0.0/src/cindra/detection/__init__.py +29 -0
  43. cindra-1.0.0/src/cindra/detection/denoise.py +125 -0
  44. cindra-1.0.0/src/cindra/detection/detect.py +537 -0
  45. cindra-1.0.0/src/cindra/detection/detect_rois.py +775 -0
  46. cindra-1.0.0/src/cindra/detection/roi_statistics.py +564 -0
  47. cindra-1.0.0/src/cindra/detection/tracking.py +583 -0
  48. cindra-1.0.0/src/cindra/detection/utils.py +326 -0
  49. cindra-1.0.0/src/cindra/extraction/__init__.py +14 -0
  50. cindra-1.0.0/src/cindra/extraction/colocalization.py +389 -0
  51. cindra-1.0.0/src/cindra/extraction/deconvolve.py +237 -0
  52. cindra-1.0.0/src/cindra/extraction/extract.py +1007 -0
  53. cindra-1.0.0/src/cindra/extraction/masks.py +277 -0
  54. cindra-1.0.0/src/cindra/gui/__init__.py +15 -0
  55. cindra-1.0.0/src/cindra/gui/app.py +220 -0
  56. cindra-1.0.0/src/cindra/gui/binary_viewer.py +562 -0
  57. cindra-1.0.0/src/cindra/gui/constants.py +336 -0
  58. cindra-1.0.0/src/cindra/gui/data_models.py +99 -0
  59. cindra-1.0.0/src/cindra/gui/overlays.py +986 -0
  60. cindra-1.0.0/src/cindra/gui/pc_viewer.py +527 -0
  61. cindra-1.0.0/src/cindra/gui/roi_viewer.py +1930 -0
  62. cindra-1.0.0/src/cindra/gui/styles.py +190 -0
  63. cindra-1.0.0/src/cindra/gui/tracking_viewer.py +902 -0
  64. cindra-1.0.0/src/cindra/gui/viewer_context.py +1234 -0
  65. cindra-1.0.0/src/cindra/gui/viewer_state.py +110 -0
  66. cindra-1.0.0/src/cindra/gui/widgets.py +580 -0
  67. cindra-1.0.0/src/cindra/interface/__init__.py +3 -0
  68. cindra-1.0.0/src/cindra/interface/acquisition_tools.py +472 -0
  69. cindra-1.0.0/src/cindra/interface/cli.py +312 -0
  70. cindra-1.0.0/src/cindra/interface/configuration_tools.py +833 -0
  71. cindra-1.0.0/src/cindra/interface/gui_cli.py +114 -0
  72. cindra-1.0.0/src/cindra/interface/gui_mcp_server.py +245 -0
  73. cindra-1.0.0/src/cindra/interface/mcp_instance.py +13 -0
  74. cindra-1.0.0/src/cindra/interface/mcp_server.py +21 -0
  75. cindra-1.0.0/src/cindra/interface/processing_tools.py +2205 -0
  76. cindra-1.0.0/src/cindra/interface/results_tools.py +1696 -0
  77. cindra-1.0.0/src/cindra/io/__init__.py +30 -0
  78. cindra-1.0.0/src/cindra/io/binary.py +547 -0
  79. cindra-1.0.0/src/cindra/io/combine.py +498 -0
  80. cindra-1.0.0/src/cindra/io/context.py +603 -0
  81. cindra-1.0.0/src/cindra/io/select.py +262 -0
  82. cindra-1.0.0/src/cindra/io/tiff.py +465 -0
  83. cindra-1.0.0/src/cindra/pipelines/__init__.py +19 -0
  84. cindra-1.0.0/src/cindra/pipelines/multi_recording.py +112 -0
  85. cindra-1.0.0/src/cindra/pipelines/pipeline.py +560 -0
  86. cindra-1.0.0/src/cindra/pipelines/single_recording.py +231 -0
  87. cindra-1.0.0/src/cindra/py.typed +0 -0
  88. cindra-1.0.0/src/cindra/registration/__init__.py +16 -0
  89. cindra-1.0.0/src/cindra/registration/bidiphase_correction.py +80 -0
  90. cindra-1.0.0/src/cindra/registration/deformation.py +817 -0
  91. cindra-1.0.0/src/cindra/registration/diffeomorphic.py +497 -0
  92. cindra-1.0.0/src/cindra/registration/metrics.py +412 -0
  93. cindra-1.0.0/src/cindra/registration/nonrigid.py +576 -0
  94. cindra-1.0.0/src/cindra/registration/pyramid.py +132 -0
  95. cindra-1.0.0/src/cindra/registration/register.py +1117 -0
  96. cindra-1.0.0/src/cindra/registration/register_recordings.py +523 -0
  97. cindra-1.0.0/src/cindra/registration/rigid.py +184 -0
  98. cindra-1.0.0/src/cindra/registration/spline_grid.py +408 -0
  99. cindra-1.0.0/src/cindra/registration/utils.py +351 -0
  100. cindra-1.0.0/tests/classification/classify_test.py +239 -0
  101. cindra-1.0.0/tests/dataclasses_configuration_test.py +114 -0
  102. cindra-1.0.0/tests/dataclasses_io_test.py +1538 -0
  103. cindra-1.0.0/tests/dataclasses_relocation_test.py +114 -0
  104. cindra-1.0.0/tests/dataclasses_test.py +758 -0
  105. cindra-1.0.0/tests/detection/denoise_test.py +106 -0
  106. cindra-1.0.0/tests/detection/detect_extended_test.py +117 -0
  107. cindra-1.0.0/tests/detection/detect_rois_extended_test.py +189 -0
  108. cindra-1.0.0/tests/detection/detect_rois_test.py +227 -0
  109. cindra-1.0.0/tests/detection/detect_test.py +169 -0
  110. cindra-1.0.0/tests/detection/roi_statistics_test.py +435 -0
  111. cindra-1.0.0/tests/detection/tracking_extended_test.py +145 -0
  112. cindra-1.0.0/tests/detection/tracking_test.py +234 -0
  113. cindra-1.0.0/tests/detection/utils_test.py +390 -0
  114. cindra-1.0.0/tests/extraction/colocalization_test.py +303 -0
  115. cindra-1.0.0/tests/extraction/deconvolve_test.py +216 -0
  116. cindra-1.0.0/tests/extraction/extract_extended_test.py +128 -0
  117. cindra-1.0.0/tests/extraction/extract_test.py +177 -0
  118. cindra-1.0.0/tests/extraction/masks_test.py +280 -0
  119. cindra-1.0.0/tests/io/binary_extended_test.py +295 -0
  120. cindra-1.0.0/tests/io/binary_test.py +451 -0
  121. cindra-1.0.0/tests/io/combine_test.py +133 -0
  122. cindra-1.0.0/tests/io/context_test.py +315 -0
  123. cindra-1.0.0/tests/io/select_extended_test.py +227 -0
  124. cindra-1.0.0/tests/io/select_test.py +120 -0
  125. cindra-1.0.0/tests/io/tiff_test.py +167 -0
  126. cindra-1.0.0/tests/registration/bidiphase_correction_test.py +109 -0
  127. cindra-1.0.0/tests/registration/deformation_test.py +469 -0
  128. cindra-1.0.0/tests/registration/diffeomorphic_test.py +103 -0
  129. cindra-1.0.0/tests/registration/metrics_test.py +145 -0
  130. cindra-1.0.0/tests/registration/nonrigid_test.py +241 -0
  131. cindra-1.0.0/tests/registration/pyramid_test.py +71 -0
  132. cindra-1.0.0/tests/registration/register_recordings_test.py +198 -0
  133. cindra-1.0.0/tests/registration/register_test.py +303 -0
  134. cindra-1.0.0/tests/registration/rigid_test.py +257 -0
  135. cindra-1.0.0/tests/registration/spline_grid_test.py +138 -0
  136. cindra-1.0.0/tests/registration/utils_test.py +395 -0
  137. cindra-1.0.0/tox.ini +172 -0
@@ -0,0 +1,11 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(grep -v \"\\\\.pyi$\")",
5
+ "Bash(python *)",
6
+ "Bash(conda env *)",
7
+ "Bash(conda run *)",
8
+ "Bash(.tox/py314-test/Scripts/python.exe -m pytest tests/ --co -q)"
9
+ ]
10
+ }
11
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "cindra",
3
+ "owner": {
4
+ "name": "Sun (NeuroAI) lab at Cornell University"
5
+ },
6
+ "plugins": [
7
+ {
8
+ "name": "cindra",
9
+ "source": "./plugins/cindra",
10
+ "description": "Provides neural imaging pipeline configuration, batch processing orchestration, results analysis, data preparation, visualization, and MCP environment setup skills for cindra. Includes MCP bindings for data processing and GUI viewer management."
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,216 @@
1
+ # This version of gitignore is designed to work for python projects using C++ computational core. It has been
2
+ # configured, it to exclude certain jetbrains files, but additional configuration may be needed for contributors
3
+ # seeking to use VSCode or other IDE / code editor.
4
+
5
+ # Prerequisites
6
+ *.d
7
+
8
+ # Compiled Object files
9
+ *.slo
10
+ *.lo
11
+ *.o
12
+ *.obj
13
+
14
+ # Precompiled Headers
15
+ *.gch
16
+ *.pch
17
+
18
+ # Compiled Dynamic libraries
19
+ *.so
20
+ *.dylib
21
+ *.dll
22
+
23
+ # Fortran module files
24
+ *.mod
25
+ *.smod
26
+
27
+ # Compiled Static libraries
28
+ *.lai
29
+ *.la
30
+ *.a
31
+ *.lib
32
+
33
+ # Executables
34
+ *.exe
35
+ *.out
36
+ *.app
37
+
38
+ # Platformio files
39
+ *.pio
40
+
41
+ # Byte-compiled / optimized / DLL files
42
+ __pycache__/
43
+ *.py[cod]
44
+ *$py.class
45
+
46
+ # Distribution / packaging
47
+ .Python
48
+ build/
49
+ develop-eggs/
50
+ dist/
51
+ downloads/
52
+ eggs/
53
+ .eggs/
54
+ lib/
55
+ lib64/
56
+ parts/
57
+ sdist/
58
+ var/
59
+ wheels/
60
+ share/python-wheels/
61
+ *.egg-info/
62
+ .installed.cfg
63
+ *.egg
64
+ MANIFEST
65
+
66
+ # PyInstaller
67
+ # Usually these files are written by a python script from a template
68
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
69
+ *.manifest
70
+ *.spec
71
+
72
+ # Installer logs
73
+ pip-log.txt
74
+ pip-delete-this-directory.txt
75
+
76
+ # Unit test / coverage reports
77
+ htmlcov/
78
+ .tox/
79
+ .nox/
80
+ .coverage
81
+ .coverage.*
82
+ .cache
83
+ nosetests.xml
84
+ coverage.xml
85
+ *.cover
86
+ *.py,cover
87
+ .hypothesis/
88
+ .pytest_cache/
89
+ cover/
90
+
91
+ # Translations
92
+ *.mo
93
+ *.pot
94
+
95
+ # Django stuff:
96
+ *.log
97
+ local_settings.py
98
+ db.sqlite3
99
+ db.sqlite3-journal
100
+
101
+ # Flask stuff:
102
+ instance/
103
+ .webassets-cache
104
+
105
+ # Scrapy stuff:
106
+ .scrapy
107
+
108
+ # Sphinx documentation
109
+ docs/_build/
110
+
111
+ # PyBuilder
112
+ .pybuilder/
113
+ target/
114
+
115
+ # Jupyter Notebook
116
+ .ipynb_checkpoints
117
+
118
+ # IPython
119
+ profile_default/
120
+ ipython_config.py
121
+
122
+ # pyenv
123
+ # For a library or package, you might want to ignore these files since the code is
124
+ # intended to run in multiple environments; otherwise, check them in:
125
+ # python-version
126
+
127
+ # pipenv
128
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
129
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
130
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
131
+ # install all needed dependencies.
132
+ #Pipfile.lock
133
+
134
+ # poetry
135
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
136
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
137
+ # commonly ignored for libraries.
138
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
139
+ #poetry.lock
140
+
141
+ # pdm
142
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
143
+ #pdm.lock
144
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
145
+ # in version control.
146
+ # https://pdm.fming.dev/#use-with-ide
147
+ .pdm.toml
148
+
149
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
150
+ __pypackages__/
151
+
152
+ # Celery stuff
153
+ celerybeat-schedule
154
+ celerybeat.pid
155
+
156
+ # SageMath parsed files
157
+ *.sage.py
158
+
159
+ # Environments
160
+ .env
161
+ .venv
162
+ env/
163
+ venv/
164
+ ENV/
165
+ env.bak/
166
+ venv.bak/
167
+
168
+ # Spyder project settings
169
+ .spyderproject
170
+ .spyproject
171
+
172
+ # Rope project settings
173
+ .ropeproject
174
+
175
+ # mkdocs documentation
176
+ /site
177
+
178
+ # mypy
179
+ .mypy_cache/
180
+ .dmypy.json
181
+ dmypy.json
182
+
183
+ # Pyre type checker
184
+ .pyre/
185
+
186
+ # pytype static type analyzer
187
+ .pytype/
188
+
189
+ # Cython debug symbols
190
+ cython_debug/
191
+
192
+ # PyCharm
193
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
194
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
195
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
196
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
197
+ .idea/
198
+
199
+ # VSCode
200
+ .vscode/
201
+
202
+ # OSx
203
+ .DS_Store
204
+
205
+ # Project files that are part of the general Sun Lab C-Python project architecture that should not be uploaded to and
206
+ # from Github
207
+ /cmake-build-debug/
208
+ /reports/
209
+ /docs/source/doxygen/
210
+ /docs/build/
211
+ /stubs/
212
+ /.pypirc
213
+
214
+ # Project: Add any project-specific exclusions here
215
+ /temp
216
+ *.lock
cindra-1.0.0/CLAUDE.md ADDED
@@ -0,0 +1,355 @@
1
+ # Claude Code Instructions
2
+
3
+ ## Session start behavior
4
+
5
+ At the beginning of each coding session, before making any code changes, you should build a comprehensive understanding
6
+ of the codebase by invoking the `/explore-codebase` skill.
7
+
8
+ This ensures you:
9
+ - Understand the project architecture before modifying code
10
+ - Follow existing patterns and conventions
11
+ - Do not introduce inconsistencies or break integrations
12
+
13
+ ## Style guide compliance
14
+
15
+ You MUST invoke the appropriate style skill before performing ANY of the following tasks:
16
+
17
+ | Task | Skill to invoke |
18
+ |----------------------------------------|--------------------|
19
+ | Writing or modifying Python code | `/python-style` |
20
+ | Writing or modifying README files | `/readme-style` |
21
+ | Writing git commit messages | `/commit` |
22
+ | Writing or modifying skill files | `/skill-design` |
23
+ | Writing or modifying pyproject.toml | `/pyproject-style` |
24
+ | Writing or modifying tox.ini | `/tox-config` |
25
+ | Writing or modifying Sphinx docs files | `/api-docs` |
26
+
27
+ Each skill contains a verification checklist that you MUST complete before submitting any work. Failure to invoke the
28
+ appropriate skill results in style violations.
29
+
30
+ ## Cross-referenced library verification
31
+
32
+ Sun Lab projects often depend on other `ataraxis-*` or `sl-*` libraries. These libraries may be stored locally in the
33
+ same parent directory as this project (`/home/cyberaxolotl/Desktop/GitHubRepos/`).
34
+
35
+ **Before writing code that interacts with a cross-referenced library, you MUST:**
36
+
37
+ 1. **Check for local version**: Look for the library in the parent directory (e.g., `../ataraxis-time/`,
38
+ `../ataraxis-base-utilities/`, `../ataraxis-data-structures/`).
39
+
40
+ 2. **Compare versions**: If a local copy exists, compare its version against the latest release or main branch on
41
+ GitHub:
42
+ - Read the local `pyproject.toml` to get the current version
43
+ - Use `gh api repos/Sun-Lab-NBB/{repo-name}/releases/latest` to check the latest release
44
+ - Alternatively, check the main branch version on GitHub
45
+
46
+ 3. **Handle version mismatches**: If the local version differs from the latest release or main branch, notify the user
47
+ with the following options:
48
+ - **Use online version**: Fetch documentation and API details from the GitHub repository
49
+ - **Update local copy**: The user will pull the latest changes locally before proceeding
50
+
51
+ 4. **Proceed with correct source**: Use whichever version the user selects as the authoritative reference for API
52
+ usage, patterns, and documentation.
53
+
54
+ **Why this matters**: Skills and documentation may reference outdated APIs. Always verify against the actual library
55
+ state to prevent integration errors.
56
+
57
+ ## MCP server integration
58
+
59
+ The cindra Claude Code plugin registers two MCP servers that expose neural imaging pipeline tools for agentic AI
60
+ interaction. The plugin provides the server registrations and skills; the cindra pip package provides the server
61
+ implementations (`cindra mcp` and `cindra-gui mcp` CLI commands). Both must be installed for MCP tools to function.
62
+ When working with this project or its dependencies, prefer using available MCP tools over direct code execution when
63
+ appropriate.
64
+
65
+ **Servers:**
66
+
67
+ | Server | CLI command | Purpose |
68
+ |--------------|------------------|----------------------------------------------------|
69
+ | `cindra-mcp` | `cindra mcp` | Data processing, configuration, discovery, results |
70
+ | `cindra-gui` | `cindra-gui mcp` | GUI viewer lifecycle management and state queries |
71
+
72
+ **Guidelines for MCP usage:**
73
+
74
+ 1. **Discover available tools**: At the start of a session, check which MCP servers are connected and what tools they
75
+ provide. Use these tools when they offer functionality relevant to the current task.
76
+
77
+ 2. **Prefer MCP for runtime operations**: For operations like batch processing orchestration, configuration generation,
78
+ recording discovery, and result querying, use MCP tools rather than writing and executing Python code directly. MCP
79
+ tools provide consistent, tested interfaces with proper resource management.
80
+
81
+ 3. **Use MCP for cross-library operations**: When dependency libraries (e.g., `ataraxis-data-structures`,
82
+ `ataraxis-time`) provide MCP servers, explore and use their tools for interacting with those libraries.
83
+
84
+ 4. **Fall back to code when necessary**: Use direct code execution when no MCP tool exists for the required
85
+ functionality, the task requires custom logic, or you are writing or modifying library source code.
86
+
87
+ ## Available skills
88
+
89
+ Skills are provided via Claude Code plugins, not the cindra pip package. The cindra plugin provides project-specific
90
+ skills (processing, configuration, results, visualization, MCP setup). The ataraxis automation plugin provides shared
91
+ Sun Lab workflow skills (style guides, commit, codebase exploration).
92
+
93
+ **Ataraxis automation plugin skills:**
94
+
95
+ | Skill | Description |
96
+ |-------------------------|---------------------------------------------------------------------------|
97
+ | `/explore-codebase` | Perform in-depth codebase exploration at session start |
98
+ | `/explore-dependencies` | Explore ataraxis dependency APIs for a live API snapshot |
99
+ | `/python-style` | Apply Sun Lab Python coding conventions (REQUIRED for all Python changes) |
100
+ | `/cpp-style` | Apply Sun Lab C++ coding conventions (not used by this Python-only repo) |
101
+ | `/csharp-style` | Apply Sun Lab C# coding conventions (not used by this Python-only repo) |
102
+ | `/readme-style` | Apply Sun Lab README conventions (REQUIRED for README changes) |
103
+ | `/commit` | Draft Sun Lab style-compliant git commit messages |
104
+ | `/skill-design` | Generate and verify skill files and CLAUDE.md project instructions |
105
+ | `/project-layout` | Apply Sun Lab project directory layout conventions |
106
+ | `/pyproject-style` | Apply Sun Lab pyproject.toml conventions |
107
+ | `/tox-config` | Apply Sun Lab tox.ini conventions |
108
+ | `/api-docs` | Apply Sun Lab API documentation conventions |
109
+
110
+ **Cindra plugin skills:**
111
+
112
+ | Skill | Description |
113
+ |-----------------------------------|------------------------------------------------------------------|
114
+ | `/single-recording-processing` | Orchestrate single-recording batch processing via MCP |
115
+ | `/multi-recording-processing` | Orchestrate multi-recording batch processing via MCP |
116
+ | `/single-recording-configuration` | Reference for single-recording pipeline configuration parameters |
117
+ | `/multi-recording-configuration` | Reference for multi-recording pipeline configuration parameters |
118
+ | `/single-recording-results` | Reference for single-recording pipeline output data formats |
119
+ | `/multi-recording-results` | Reference for multi-recording pipeline output data formats |
120
+ | `/acquisition-data-preparation` | Guide for preparing raw imaging data for cindra processing |
121
+ | `/visualization` | Launch and manage cindra GUI viewers for visual inspection |
122
+ | `/cindra-mcp-environment-setup` | Diagnose and resolve MCP server connectivity issues |
123
+
124
+ ## Project context
125
+
126
+ This is **cindra**, a reimplementation of the [suite2p](https://github.com/MouseLand/suite2p) neural imaging
127
+ processing library with expanded documentation, optimized algorithms, modern Python 3.14 support, and a novel
128
+ multi-recording ROI tracking pipeline based on the [OSM manuscript](https://www.nature.com/articles/s41586-024-08548-w).
129
+ The library provides CLI and MCP server interfaces for agentic processing, and interactive GUIs for visualization of
130
+ pipeline outputs.
131
+
132
+ ### Key areas
133
+
134
+ | Directory | Purpose |
135
+ |------------------------------|-----------------------------------------------------------------|
136
+ | `src/cindra/` | Main library source code |
137
+ | `src/cindra/classification/` | Cell type classification (distinguishing cells from artifacts) |
138
+ | `src/cindra/dataclasses/` | Configuration and runtime data structures (YamlConfig-based) |
139
+ | `src/cindra/detection/` | ROI detection, tracking, and statistics computation |
140
+ | `src/cindra/extraction/` | Fluorescence trace extraction, neuropil subtraction, OASIS |
141
+ | `src/cindra/gui/` | Interactive PySide6/PyQtGraph viewers for pipeline outputs |
142
+ | `src/cindra/interface/` | CLI, MCP servers, and tool modules for user-facing entry points |
143
+ | `src/cindra/io/` | TIFF loading, binary file management, multi-plane combination |
144
+ | `src/cindra/pipelines/` | High-level pipeline orchestration for single/multi-recording |
145
+ | `src/cindra/registration/` | Motion correction, diffeomorphic registration, deformation |
146
+ | `tests/` | Test suite (mirrors source module structure) |
147
+ | `docs/` | Sphinx API documentation source |
148
+
149
+ ### Architecture
150
+
151
+ - **Single-recording pipeline**: Three-phase workflow (binarize, process, combine). Phase 1 converts TIFFs to internal
152
+ binary format and initializes RuntimeContext per plane. Phase 2 runs per-plane registration, detection,
153
+ classification, and extraction (parallelizable across planes). Phase 3 merges plane-specific results into a unified
154
+ `combined_metadata.npz` dataset.
155
+ - **Multi-recording pipeline**: Two-phase workflow (discover, extract). Phase 1 selects ROIs from each recording,
156
+ performs diffeomorphic demons registration to a common space, clusters ROIs across recordings via spatial overlap,
157
+ and projects template masks back to individual recordings. Phase 2 extracts fluorescence traces and applies OASIS
158
+ deconvolution for tracked ROI templates (parallelizable across recordings).
159
+ - **Context pattern**: `RuntimeContext` and `MultiRecordingRuntimeContext` combine configuration, acquisition
160
+ parameters, and runtime data into single objects passed through pipeline steps.
161
+ - **Configuration-driven execution**: Pipelines read all parameters from YAML files (YamlConfig subclasses). The CLI
162
+ writes overrides to the config file before execution rather than passing arguments.
163
+ - **ProcessingTracker**: File-based YAML pipeline state tracking with FileLock for multi-process coordination. Manages
164
+ job states (SCHEDULED, RUNNING, SUCCEEDED, FAILED) for resumable batch processing.
165
+ - **Subprocess GUI isolation**: GUI viewers launch as separate subprocesses with state file exchange via temporary
166
+ files, avoiding Qt dependency loading during headless pipeline execution. The `cindra-gui` CLI entry point is
167
+ separate from `cindra` for this reason.
168
+ - **MCP tool organization**: Tools are split across four modules (`acquisition_tools`, `configuration_tools`,
169
+ `processing_tools`, `results_tools`) imported at module level to trigger `@mcp.tool()` registration.
170
+ Processing uses a prepare-then-execute model: preparation tools create execution manifests (trackers,
171
+ per-recording configurations, job lists) without starting computation, and execution tools dispatch jobs
172
+ with prerequisite validation, saturating core allocation, and automatic phase sequencing. I/O-bound jobs
173
+ (binarize, combine) use fixed concurrency; compute-bound jobs use saturating allocation.
174
+
175
+ ### Core components
176
+
177
+ | Component | File | Purpose |
178
+ |-----------------------------------|-------------------------------------------------|---------------------------------------------------------|
179
+ | `SingleRecordingConfiguration` | `dataclasses/single_recording_configuration.py` | User-facing config with nested dataclasses |
180
+ | `MultiRecordingConfiguration` | `dataclasses/multi_recording_configuration.py` | Multi-recording pipeline config |
181
+ | `AcquisitionParameters` | `dataclasses/single_recording_configuration.py` | Per-recording acquisition metadata |
182
+ | `RuntimeContext` | `dataclasses/runtime_contexts.py` | Single-recording config + acquisition + runtime data |
183
+ | `MultiRecordingRuntimeContext` | `dataclasses/runtime_contexts.py` | Multi-recording config + runtime data |
184
+ | `SingleRecordingRuntimeData` | `dataclasses/single_recording_data.py` | IOData, RegistrationData, DetectionData, ExtractionData |
185
+ | `MultiRecordingRuntimeData` | `dataclasses/multi_recording_data.py` | Multi-recording IO, registration, tracking, timing data |
186
+ | `run_single_recording_pipeline` | `pipelines/pipeline.py` | Execute single-recording three-phase workflow |
187
+ | `run_multi_recording_pipeline` | `pipelines/pipeline.py` | Execute multi-recording two-phase workflow |
188
+ | `register_plane` | `registration/register.py` | Per-plane motion correction (rigid + optional nonrigid) |
189
+ | `DiffeomorphicDemonsRegistration` | `registration/diffeomorphic.py` | Cross-day diffeomorphic alignment algorithm |
190
+ | `Deformation` | `registration/deformation.py` | Deformation field application and inversion |
191
+ | `detect_plane_rois` | `detection/detect.py` | ROI detection via sparse detection with PCA denoising |
192
+ | `track_rois_across_recordings` | `detection/tracking.py` | Multi-recording ROI tracking via spatial clustering |
193
+ | `compute_roi_statistics` | `detection/roi_statistics.py` | ROI property computation (skewness, compactness, etc.) |
194
+ | `extract_traces` | `extraction/extract.py` | Fluorescence extraction and neuropil subtraction |
195
+ | `apply_oasis_deconvolution` | `extraction/deconvolve.py` | OASIS spike deconvolution |
196
+ | `create_masks` | `extraction/masks.py` | ROI mask creation with lambda weight computation |
197
+ | `Classifier` | `classification/classify.py` | Cell vs. artifact classification |
198
+ | `BinaryFile` | `io/binary.py` | Memory-mapped binary file access for imaging data |
199
+ | `convert_tiffs_to_binary` | `io/tiff.py` | TIFF to internal binary format conversion |
200
+ | `combine_planes` | `io/combine.py` | Multi-plane result combination |
201
+ | `run_roi_viewer` | `gui/app.py` | Single-recording ROI inspector GUI |
202
+ | `run_tracking_viewer` | `gui/app.py` | Multi-recording tracking quality GUI |
203
+ | `run_registration_viewer` | `gui/app.py` | Registration quality viewer (binary + PC viewer) |
204
+
205
+ ### Key patterns
206
+
207
+ - **Numba parallelization**: The TBB threading layer is set in `__init__.py` before any Numba imports. Functions use
208
+ `@njit(cache=True, parallel=True)` with `prange` for frame-level parallelization. The
209
+ `# type: ignore[import-untyped]` comments on Numba imports and `# pragma: no cover` on JIT-compiled function bodies
210
+ are expected and should not be removed.
211
+ - **Memory efficiency**: Pre-allocates arrays with `np.empty` when overwritten immediately. Uses flattened mask arrays
212
+ with offset indices to reduce per-ROI allocations. Memory maps registration arrays on demand via
213
+ `memory_map_arrays()`. Results tools use lightweight NumPy/YAML reads for targeted queries without full data loading.
214
+ - **Polymorphic dispatch**: `extract_traces()` checks `isinstance(context, RuntimeContext)` to route between
215
+ single-recording and multi-recording extraction paths.
216
+ - **Channel 2 behavior**: Channel 2 data returns empty arrays (`[]`) instead of None when absent. Channel 1 data
217
+ raises an error if missing.
218
+ - **Module-level constants**: Use inline `"""docstring"""` below the definition, not `# comment` above.
219
+ - **Property docstrings**: Single sentence, even if spanning multiple lines. Do not split into summary + extended
220
+ description.
221
+ - **Error messages**: Follow the `"Unable to [action]..."` pattern using `console.error()` from
222
+ ataraxis-base-utilities.
223
+
224
+ ### CLI entry points
225
+
226
+ | Command | Entry point | Purpose |
227
+ |--------------|---------------------------------------|----------------------------------------------------------|
228
+ | `cindra` | `cindra.interface.cli:cindra_cli` | Main CLI for configuration, pipeline execution, and MCP |
229
+ | `cindra-gui` | `cindra.interface.gui_cli:cindra_gui` | GUI launcher (separate to avoid Qt during headless runs) |
230
+
231
+ **`cindra` commands:**
232
+
233
+ | Command | Description |
234
+ |--------------------|----------------------------------------------------------------------|
235
+ | `cindra configure` | Generate default config files for single or multi-recording pipeline |
236
+ | `cindra run` | Execute pipeline with CLI overrides for config parameters |
237
+ | `cindra mcp` | Start MCP server (stdio, sse, or streamable-http transport) |
238
+
239
+ **`cindra-gui` commands:**
240
+
241
+ | Command | Description |
242
+ |---------------------------|----------------------------------------------------------------|
243
+ | `cindra-gui roi` | Launch ROI viewer (single or multi-recording via dataset flag) |
244
+ | `cindra-gui registration` | Launch registration quality viewer (binary + PC viewer combo) |
245
+ | `cindra-gui tracking` | Launch multi-recording tracking quality viewer |
246
+ | `cindra-gui mcp` | Start GUI MCP server for viewer lifecycle management |
247
+
248
+ ### Dependencies
249
+
250
+ | Library | Purpose |
251
+ |----------------------------|---------------------------------------------------------------|
252
+ | `numpy` | Array operations, memory mapping, data storage |
253
+ | `numba` | JIT compilation for registration, detection, extraction |
254
+ | `scipy` | Signal processing, spatial algorithms, sparse matrices |
255
+ | `scikit-learn` | PCA denoising, clustering for ROI detection |
256
+ | `natsort` | Semantic file path sorting (1, 2, 10 vs 1, 10, 2) |
257
+ | `tifffile` | TIFF file loading and metadata extraction |
258
+ | `imagecodecs` | Image codec support for TIFF decompression |
259
+ | `matplotlib` | Visualization support for GUI viewers |
260
+ | `pyside6` | Qt6 GUI framework for interactive viewers |
261
+ | `pyqtgraph` | High-performance plotting for GUI image display |
262
+ | `click` | CLI framework for command-line interfaces |
263
+ | `mcp` | FastMCP server for agentic AI tool integration |
264
+ | `httpx` | HTTP client used by the MCP transport layer |
265
+ | `ataraxis-time` | PrecisionTimer for pipeline step timing |
266
+ | `ataraxis-base-utilities` | Console for unified message handling and error reporting |
267
+ | `ataraxis-data-structures` | YamlConfig, ProcessingTracker, and data logging utilities |
268
+ | `importlib_metadata` | Runtime version introspection for the cindra package |
269
+ | `tbb4py` | Intel TBB threading layer for Numba parallelization (non-Mac) |
270
+ | `intel-cmplr-lib-rt` | Intel compiler runtime paired with `tbb4py` (non-Mac) |
271
+
272
+ ### Code standards
273
+
274
+ - MyPy strict mode with full type annotations
275
+ - Google-style docstrings
276
+ - 120 character line limit
277
+ - Ruff for formatting and linting
278
+ - Python 3.14 only
279
+ - See `/python-style` for complete conventions
280
+
281
+ ### Development commands
282
+
283
+ ```bash
284
+ tox -e lint # Format, lint, and type-check
285
+ tox -e stubs # Generate .pyi stub files
286
+ tox -e py314-test # Run tests for Python 3.14
287
+ tox -e coverage # Aggregate coverage reports
288
+ tox -e docs # Build Sphinx API documentation
289
+ tox # Run full pipeline (uninstall -> export -> lint -> ... -> install)
290
+ ```
291
+
292
+ ### Testing
293
+
294
+ Tests use pytest with pytest-xdist for parallel execution (`-n logical --dist loadgroup`). Coverage is collected and
295
+ aggregated by the `coverage` tox environment. Test files mirror the source structure under `tests/` with a `_test.py`
296
+ suffix. Test directories: `classification/`, `detection/`, `extraction/`, `io/`, `registration/`.
297
+
298
+ ### Workflow guidance
299
+
300
+ **Modifying pipeline orchestration:**
301
+
302
+ 1. Review `src/cindra/pipelines/pipeline.py` for job orchestration and ProcessingTracker integration
303
+ 2. Review `src/cindra/pipelines/single_recording.py` for the three-phase single-recording workflow
304
+ 3. Review `src/cindra/pipelines/multi_recording.py` for the two-phase multi-recording workflow
305
+ 4. Maintain the job naming convention (`SingleRecordingJobNames`, `MultiRecordingJobNames`) for tracker consistency
306
+
307
+ **Modifying registration:**
308
+
309
+ 1. Review `src/cindra/registration/register.py` for per-plane motion correction entry point
310
+ 2. Understand the two-step registration refinement when enabled
311
+ 3. Rigid registration uses phase correlation (`rigid.py`); nonrigid uses block-based deformation (`nonrigid.py`)
312
+ 4. Cross-recording registration uses diffeomorphic demons (`diffeomorphic.py`) with multiscale pyramid (`pyramid.py`)
313
+
314
+ **Modifying detection:**
315
+
316
+ 1. Review `src/cindra/detection/detect.py` for the sparse detection entry point
317
+ 2. Understand the PCA denoising step and temporal binning strategy
318
+ 3. ROI extension logic is in `detect_rois.py`; statistics computation in `roi_statistics.py`
319
+ 4. Multi-recording tracking via spatial clustering is in `tracking.py`
320
+
321
+ **Modifying extraction:**
322
+
323
+ 1. Review `src/cindra/extraction/extract.py` for the polymorphic dispatch pattern
324
+ 2. Numba JIT functions use `@njit(cache=True, parallel=True)` with `prange` for frame parallelization
325
+ 3. Mask creation and lambda weight computation is in `masks.py`
326
+ 4. OASIS deconvolution and delta fluorescence computation is in `deconvolve.py`
327
+
328
+ **Modifying GUI viewers:**
329
+
330
+ 1. Review `src/cindra/gui/app.py` for viewer entry points
331
+ 2. Viewers use PySide6 + PyQtGraph with custom widgets in `widgets.py`
332
+ 3. State management via `viewer_context.py` and `viewer_state.py`
333
+ 4. The GUI CLI (`gui_cli.py`) is separate from the main CLI to avoid loading Qt during headless execution
334
+
335
+ **Adding or modifying MCP tools:**
336
+
337
+ 1. Review the relevant tool module in `src/cindra/interface/` (acquisition, configuration, processing, or results)
338
+ 2. Tools register via `@mcp.tool()` decorator on the shared `mcp` instance from `mcp_instance.py`
339
+ 3. Batch processing tools use background manager threads with per-job worker threads
340
+ 4. Return formatted strings for user-facing output; use JSON response mode
341
+
342
+ **Adding or modifying CLI commands:**
343
+
344
+ 1. Review `src/cindra/interface/cli.py` for the main CLI Click group structure
345
+ 2. Review `src/cindra/interface/gui_cli.py` for the GUI CLI structure
346
+ 3. Follow existing patterns for Click option decorators and error handling
347
+ 4. CLI writes configuration overrides to the config file before pipeline execution
348
+
349
+ **Important considerations:**
350
+
351
+ - The `console` is enabled in `src/cindra/__init__.py` — do not re-enable elsewhere
352
+ - The Numba TBB threading layer is set in `__init__.py` before any Numba imports — do not move this
353
+ - The `# type: ignore[import-untyped]` comments on Numba and tifffile imports are expected
354
+ - The `# pragma: no cover` annotations on `@njit` function bodies are intentional
355
+ - Use `console.error()` from ataraxis-base-utilities for all error handling (no bare `raise`)