npc-samstim 0.1.1__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.
- npc-samstim-0.1.1/LICENSE +22 -0
- npc-samstim-0.1.1/PKG-INFO +48 -0
- npc-samstim-0.1.1/README.md +24 -0
- npc-samstim-0.1.1/pyproject.toml +240 -0
- npc-samstim-0.1.1/setup.cfg +4 -0
- npc-samstim-0.1.1/src/npc_samstim/__init__.py +41 -0
- npc-samstim-0.1.1/src/npc_samstim/py.typed +0 -0
- npc-samstim-0.1.1/src/npc_samstim/stim.py +62 -0
- npc-samstim-0.1.1/src/npc_samstim/waveforms.py +928 -0
- npc-samstim-0.1.1/src/npc_samstim.egg-info/PKG-INFO +48 -0
- npc-samstim-0.1.1/src/npc_samstim.egg-info/SOURCES.txt +13 -0
- npc-samstim-0.1.1/src/npc_samstim.egg-info/dependency_links.txt +1 -0
- npc-samstim-0.1.1/src/npc_samstim.egg-info/requires.txt +4 -0
- npc-samstim-0.1.1/src/npc_samstim.egg-info/top_level.txt +1 -0
- npc-samstim-0.1.1/tests/test_core.py +5 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Allen Institute for Neural Dynamics
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: npc-samstim
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Tools for processing stim data from Sam's DynamicRoutingTask, compatible with data in the cloud.
|
|
5
|
+
Author-email: Ben Hardcastle <ben.hardcastle@alleninstitue.org>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/AllenInstitute/npc_samstim
|
|
8
|
+
Project-URL: Issues, https://github.com/AllenInstitute/npc_samstim/issues
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: DynamicRoutingTask>=0.1.91
|
|
21
|
+
Requires-Dist: npc-ephys>=0.1.1
|
|
22
|
+
Requires-Dist: numba>=0.59.0
|
|
23
|
+
Requires-Dist: npc-stim>=0.1.1
|
|
24
|
+
|
|
25
|
+
# npc_samstim
|
|
26
|
+
|
|
27
|
+
Tools for processing stim data from Sam's DynamicRoutingTask, compatible with data in the cloud.
|
|
28
|
+
|
|
29
|
+
[](https://pypi.org/project/npc_samstim/)
|
|
30
|
+
[](https://pypi.org/project/npc_samstim/)
|
|
31
|
+
|
|
32
|
+
[](https://app.codecov.io/github/AllenInstitute/npc_samstim)
|
|
33
|
+
[](https://github.com/AllenInstitute/npc_samstim/actions/workflows/publish.yml)
|
|
34
|
+
[](https://github.com/AllenInstitute/npc_samstim/issues)
|
|
35
|
+
|
|
36
|
+
# Usage
|
|
37
|
+
```bash
|
|
38
|
+
conda create -n npc_samstim python>=3.9
|
|
39
|
+
conda activate npc_samstim
|
|
40
|
+
pip install npc_samstim
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
>>> import npc_samstim
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
# Development
|
|
48
|
+
See instructions in https://github.com/AllenInstitute/npc_samstim/CONTRIBUTING.md and the original template: https://github.com/AllenInstitute/copier-pdm-npc/blob/main/README.md
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# npc_samstim
|
|
2
|
+
|
|
3
|
+
Tools for processing stim data from Sam's DynamicRoutingTask, compatible with data in the cloud.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/npc_samstim/)
|
|
6
|
+
[](https://pypi.org/project/npc_samstim/)
|
|
7
|
+
|
|
8
|
+
[](https://app.codecov.io/github/AllenInstitute/npc_samstim)
|
|
9
|
+
[](https://github.com/AllenInstitute/npc_samstim/actions/workflows/publish.yml)
|
|
10
|
+
[](https://github.com/AllenInstitute/npc_samstim/issues)
|
|
11
|
+
|
|
12
|
+
# Usage
|
|
13
|
+
```bash
|
|
14
|
+
conda create -n npc_samstim python>=3.9
|
|
15
|
+
conda activate npc_samstim
|
|
16
|
+
pip install npc_samstim
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
>>> import npc_samstim
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
# Development
|
|
24
|
+
See instructions in https://github.com/AllenInstitute/npc_samstim/CONTRIBUTING.md and the original template: https://github.com/AllenInstitute/copier-pdm-npc/blob/main/README.md
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "npc-samstim"
|
|
3
|
+
description = "Tools for processing stim data from Sam's DynamicRoutingTask, compatible with data in the cloud."
|
|
4
|
+
authors = [
|
|
5
|
+
{ name = "Ben Hardcastle", email = "ben.hardcastle@alleninstitue.org" },
|
|
6
|
+
]
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
requires-python = ">=3.9"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"DynamicRoutingTask>=0.1.91",
|
|
11
|
+
"npc-ephys>=0.1.1",
|
|
12
|
+
"numba>=0.59.0",
|
|
13
|
+
"npc-stim>=0.1.1",
|
|
14
|
+
]
|
|
15
|
+
version = "0.1.1"
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Operating System :: Microsoft :: Windows",
|
|
24
|
+
"Operating System :: POSIX :: Linux",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.license]
|
|
28
|
+
text = "MIT"
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Repository = "https://github.com/AllenInstitute/npc_samstim"
|
|
32
|
+
Issues = "https://github.com/AllenInstitute/npc_samstim/issues"
|
|
33
|
+
|
|
34
|
+
[build-system]
|
|
35
|
+
requires = [
|
|
36
|
+
"setuptools>=61",
|
|
37
|
+
"wheel",
|
|
38
|
+
]
|
|
39
|
+
build-backend = "setuptools.build_meta"
|
|
40
|
+
|
|
41
|
+
[tool.setuptools.packages.find]
|
|
42
|
+
where = [
|
|
43
|
+
"src",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.package-data]
|
|
47
|
+
npc_samstim = [
|
|
48
|
+
"py.typed",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[tool.black]
|
|
52
|
+
target-version = [
|
|
53
|
+
"py39",
|
|
54
|
+
"py310",
|
|
55
|
+
"py311",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
line-length = 100
|
|
60
|
+
select = [
|
|
61
|
+
"B",
|
|
62
|
+
"C4",
|
|
63
|
+
"E",
|
|
64
|
+
"F",
|
|
65
|
+
"PGH",
|
|
66
|
+
"RUF",
|
|
67
|
+
"W",
|
|
68
|
+
"YTT",
|
|
69
|
+
"ANN",
|
|
70
|
+
"C",
|
|
71
|
+
"I",
|
|
72
|
+
"RUF100",
|
|
73
|
+
"N",
|
|
74
|
+
"UP",
|
|
75
|
+
]
|
|
76
|
+
src = [
|
|
77
|
+
"src",
|
|
78
|
+
]
|
|
79
|
+
extend-exclude = [
|
|
80
|
+
"tests/fixtures",
|
|
81
|
+
]
|
|
82
|
+
target-version = "py39"
|
|
83
|
+
|
|
84
|
+
[tool.ruff.flake8-tidy-imports]
|
|
85
|
+
ban-relative-imports = "all"
|
|
86
|
+
|
|
87
|
+
[tool.ruff.mccabe]
|
|
88
|
+
max-complexity = 10
|
|
89
|
+
|
|
90
|
+
[tool.coverage.paths]
|
|
91
|
+
source = [
|
|
92
|
+
"src",
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
[tool.coverage.run]
|
|
96
|
+
branch = true
|
|
97
|
+
source = [
|
|
98
|
+
"src",
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
[tool.coverage.report]
|
|
102
|
+
skip_covered = true
|
|
103
|
+
show_missing = true
|
|
104
|
+
skip_empty = true
|
|
105
|
+
exclude_also = [
|
|
106
|
+
"raise AssertionError",
|
|
107
|
+
"raise NotImplementedError",
|
|
108
|
+
"if __name__ == .__main__.:",
|
|
109
|
+
"@(abc.)?abstractmethod",
|
|
110
|
+
"@typing.runtime_checkable",
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
[tool.pytest.ini_options]
|
|
114
|
+
addopts = [
|
|
115
|
+
"--import-mode=importlib",
|
|
116
|
+
"--doctest-modules",
|
|
117
|
+
"--ignore-glob=*scripts*,*examples*,*docs*",
|
|
118
|
+
"--cov",
|
|
119
|
+
"--cov-report=html",
|
|
120
|
+
"--cov-config=pyproject.toml",
|
|
121
|
+
"--doctest-glob=*README.md",
|
|
122
|
+
"-x",
|
|
123
|
+
"-n=auto",
|
|
124
|
+
]
|
|
125
|
+
doctest_optionflags = [
|
|
126
|
+
"NORMALIZE_WHITESPACE",
|
|
127
|
+
"IGNORE_EXCEPTION_DETAIL",
|
|
128
|
+
"ELLIPSIS",
|
|
129
|
+
]
|
|
130
|
+
testpaths = [
|
|
131
|
+
"src",
|
|
132
|
+
"tests",
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
[tool.mypy]
|
|
136
|
+
check_untyped_defs = false
|
|
137
|
+
disallow_untyped_defs = false
|
|
138
|
+
disallow_incomplete_defs = false
|
|
139
|
+
disallow_untyped_decorators = false
|
|
140
|
+
disallow_any_unimported = false
|
|
141
|
+
warn_return_any = false
|
|
142
|
+
warn_unused_ignores = true
|
|
143
|
+
no_implicit_optional = true
|
|
144
|
+
show_error_codes = true
|
|
145
|
+
ignore_missing_imports = true
|
|
146
|
+
implicit_reexport = false
|
|
147
|
+
exclude = [
|
|
148
|
+
"src/npc_samstim/scripts",
|
|
149
|
+
]
|
|
150
|
+
|
|
151
|
+
[tool.isort]
|
|
152
|
+
profile = "black"
|
|
153
|
+
atomic = true
|
|
154
|
+
skip_glob = [
|
|
155
|
+
"*/setup.py",
|
|
156
|
+
]
|
|
157
|
+
filter_files = true
|
|
158
|
+
known_first_party = [
|
|
159
|
+
"npc_samstim",
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
[tool.pdm]
|
|
163
|
+
plugins = [
|
|
164
|
+
"pdm-bump",
|
|
165
|
+
"copier",
|
|
166
|
+
]
|
|
167
|
+
|
|
168
|
+
[tool.pdm.build]
|
|
169
|
+
package-dir = "src"
|
|
170
|
+
|
|
171
|
+
[tool.pdm.dev-dependencies]
|
|
172
|
+
dev = [
|
|
173
|
+
"pytest>=7.4.0",
|
|
174
|
+
"ruff>=0.0.282",
|
|
175
|
+
"mypy>=1.4.1",
|
|
176
|
+
"pytest-cov>=4.1.0",
|
|
177
|
+
"black>=23.7.0",
|
|
178
|
+
"git-changelog>=2.3",
|
|
179
|
+
"parver>=0.3",
|
|
180
|
+
"pytest-xdist>=3.5.0",
|
|
181
|
+
]
|
|
182
|
+
docs = [
|
|
183
|
+
"markdown-callouts>=0.3",
|
|
184
|
+
"markdown-exec>=1.7",
|
|
185
|
+
"mkdocs>=1.5",
|
|
186
|
+
"mkdocs-coverage>=1.0",
|
|
187
|
+
"mkdocs-gen-files>=0.5",
|
|
188
|
+
"mkdocs-git-committers-plugin-2>=1.2",
|
|
189
|
+
"mkdocs-git-revision-date-localized-plugin>=1.2",
|
|
190
|
+
"mkdocs-literate-nav>=0.6",
|
|
191
|
+
"mkdocs-material>=9.4",
|
|
192
|
+
"mkdocs-minify-plugin>=0.7",
|
|
193
|
+
"mkdocstrings[python]>=0.23",
|
|
194
|
+
"tomli>=2.0; python_version < '3.11'",
|
|
195
|
+
]
|
|
196
|
+
|
|
197
|
+
[tool.pdm.scripts]
|
|
198
|
+
ruff = "ruff check src --fix-only"
|
|
199
|
+
black = "black src"
|
|
200
|
+
pytest = "pytest --cov-report term-missing:skip-covered --cov-report=html"
|
|
201
|
+
mypy = "mypy src --install-types --non-interactive"
|
|
202
|
+
log = "git-changelog -o CHANGELOG.md"
|
|
203
|
+
dryrun = "pdm publish --repository testpypi --dry-run"
|
|
204
|
+
post_init = "pdm install --plugins"
|
|
205
|
+
|
|
206
|
+
[tool.pdm.scripts.test]
|
|
207
|
+
composite = [
|
|
208
|
+
"pdm run mypy",
|
|
209
|
+
"pdm run pytest",
|
|
210
|
+
]
|
|
211
|
+
|
|
212
|
+
[tool.pdm.scripts.docs]
|
|
213
|
+
shell = "cd docs && mkdocs serve"
|
|
214
|
+
help = "Start the dev server for doc preview"
|
|
215
|
+
|
|
216
|
+
[tool.pdm.scripts.bumpver]
|
|
217
|
+
composite = [
|
|
218
|
+
"pdm self add pdm-bump",
|
|
219
|
+
"pdm bump micro",
|
|
220
|
+
]
|
|
221
|
+
|
|
222
|
+
[tool.pdm.scripts.tag]
|
|
223
|
+
composite = [
|
|
224
|
+
"pdm self add pdm-bump",
|
|
225
|
+
"pdm bump tag",
|
|
226
|
+
]
|
|
227
|
+
|
|
228
|
+
[tool.pdm.scripts.pre_build]
|
|
229
|
+
composite = [
|
|
230
|
+
"pdm run black",
|
|
231
|
+
"pdm run ruff",
|
|
232
|
+
"pdm run bumpver",
|
|
233
|
+
]
|
|
234
|
+
|
|
235
|
+
[tool.pdm.scripts.post_build]
|
|
236
|
+
composite = [
|
|
237
|
+
"git commit -am 'Bump'",
|
|
238
|
+
"pdm run tag",
|
|
239
|
+
"pdm run log",
|
|
240
|
+
]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tools for processing stim data from Sam's DynamicRoutingTask, compatible with data in the cloud.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import doctest
|
|
6
|
+
import importlib.metadata
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
from npc_samstim.stim import *
|
|
10
|
+
|
|
11
|
+
# import functions from submodules here:
|
|
12
|
+
from npc_samstim.waveforms import *
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
__version__ = importlib.metadata.version("npc_samstim")
|
|
17
|
+
logger.debug(f"{__name__}.{__version__ = }")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def testmod(**testmod_kwargs) -> doctest.TestResults:
|
|
21
|
+
"""
|
|
22
|
+
Run doctests for the module, configured to ignore exception details and
|
|
23
|
+
normalize whitespace.
|
|
24
|
+
|
|
25
|
+
Accepts kwargs to pass to doctest.testmod().
|
|
26
|
+
|
|
27
|
+
Add to modules to run doctests when run as a script:
|
|
28
|
+
.. code-block:: text
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
from npc_io import testmod
|
|
31
|
+
testmod()
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
_ = testmod_kwargs.setdefault(
|
|
35
|
+
"optionflags", doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
|
|
36
|
+
)
|
|
37
|
+
return doctest.testmod(**testmod_kwargs)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if __name__ == "__main__":
|
|
41
|
+
testmod()
|
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import contextlib
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
import h5py
|
|
7
|
+
import npc_io
|
|
8
|
+
import npc_stim
|
|
9
|
+
import numpy as np
|
|
10
|
+
from DynamicRoutingTask.Analysis.DynamicRoutingAnalysisUtils import DynRoutData
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_sam(
|
|
16
|
+
stim_path_or_data: npc_io.PathLike | h5py.File,
|
|
17
|
+
) -> DynRoutData:
|
|
18
|
+
stim_data = npc_stim.get_stim_data(stim_path_or_data)
|
|
19
|
+
if not isinstance(stim_data, h5py.File):
|
|
20
|
+
raise TypeError(f"Expected h5py.File, got {type(stim_data)}")
|
|
21
|
+
obj = DynRoutData()
|
|
22
|
+
try:
|
|
23
|
+
obj.loadBehavData(filePath="dummy_366122_", h5pyFile=stim_data)
|
|
24
|
+
except Exception as exc:
|
|
25
|
+
raise TypeError(
|
|
26
|
+
"Loading Sam's `DynRoutData` object requires data from a `DynamicRouting1` hdf5 file"
|
|
27
|
+
) from exc
|
|
28
|
+
return obj
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def is_opto(
|
|
32
|
+
stim_path_or_data: npc_io.PathLike | h5py.File,
|
|
33
|
+
) -> bool:
|
|
34
|
+
"""
|
|
35
|
+
>>> is_opto('s3://aind-ephys-data/ecephys_670248_2023-08-01_11-27-17/behavior/DynamicRouting1_670248_20230801_120304.hdf5')
|
|
36
|
+
True
|
|
37
|
+
"""
|
|
38
|
+
with contextlib.suppress(TypeError):
|
|
39
|
+
return bool(
|
|
40
|
+
(onset := getattr(get_sam(stim_path_or_data), "trialOptoOnsetFrame", None))
|
|
41
|
+
is not None
|
|
42
|
+
and np.any(~np.isnan(onset.squeeze()))
|
|
43
|
+
)
|
|
44
|
+
return False
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def is_galvo_opto(
|
|
48
|
+
stim_path_or_data: npc_io.PathLike | h5py.File,
|
|
49
|
+
) -> bool:
|
|
50
|
+
"""
|
|
51
|
+
>>> is_galvo_opto('s3://aind-ephys-data/ecephys_670248_2023-08-01_11-27-17/behavior/DynamicRouting1_670248_20230801_120304.hdf5')
|
|
52
|
+
True
|
|
53
|
+
>>> is_galvo_opto('s3://aind-scratch-data/ben.hardcastle/DynamicRoutingTask/Data/677352/DynamicRouting1_677352_20231013_155330.hdf5')
|
|
54
|
+
False
|
|
55
|
+
"""
|
|
56
|
+
with contextlib.suppress(TypeError, AttributeError):
|
|
57
|
+
return bool(
|
|
58
|
+
(voltage := getattr(get_sam(stim_path_or_data), "trialGalvoVoltage", None))
|
|
59
|
+
is not None
|
|
60
|
+
and not all(np.isnan(a).any() for a in voltage)
|
|
61
|
+
)
|
|
62
|
+
return False
|