xarray-behave 0.38.0a5__tar.gz → 1.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.
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/.github/workflows/test_install.yaml +12 -14
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/AGENTS.md +3 -15
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/PKG-INFO +14 -10
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/README.md +7 -3
- xarray_behave-1.0/env/xb.yml +7 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/pyproject.toml +15 -17
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/__init__.py +1 -1
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/api.py +1 -1
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/event_utils.py +0 -9
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/app.py +20 -33
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/formbuilder.py +5 -2
- xarray_behave-0.38.0a5/src/xarray_behave/gui/forms/das_make.yaml → xarray_behave-1.0/src/xarray_behave/gui/forms/training_package.yaml +7 -6
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/utils.py +3 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/view_dialog.py +3 -17
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/views.py +1 -17
- xarray_behave-1.0/src/xarray_behave/io/annotations.py +54 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/io/annotations_manual.py +9 -14
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/io/audio.py +22 -56
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/io/poses.py +2 -2
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/io/tracks.py +15 -38
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/manifests/default.yaml +0 -6
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/xarray_behave.py +44 -55
- xarray_behave-1.0/tests/fixtures/zarr2/README.md +1 -0
- xarray_behave-1.0/tests/fixtures/zarr2/recording_poses_dpk.zarr +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_api.py +16 -6
- xarray_behave-1.0/tests/test_assemble.py +70 -0
- xarray_behave-1.0/tests/test_assemble_metrics.py +20 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_gui_annotation_import.py +4 -3
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_gui_das.py +12 -12
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_gui_event_widgets.py +4 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_gui_utils.py +6 -4
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_io.py +20 -2
- xarray_behave-1.0/tests/test_zarr_compatibility.py +60 -0
- xarray_behave-0.38.0a5/env/xb.yml +0 -10
- xarray_behave-0.38.0a5/src/xarray_behave/io/annotations.py +0 -163
- xarray_behave-0.38.0a5/tests/test_assemble.py +0 -184
- xarray_behave-0.38.0a5/tests/test_assemble_metrics.py +0 -58
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/.gitignore +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/LICENSE +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/doc/demo.ipynb +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/doc/demo_behavioral_features.ipynb +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/doc/demo_behavioral_features_large_group.ipynb +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/doc/ncb.mplstyle +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/scripts/fix_camera_timestamps.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/_audio_filter.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/_dataset_service.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/annot.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/__init__.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/annotation_import.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/audio_playback.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/checkbox_check.svg +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/event_widgets.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/forms/envelope_computation.yaml +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/forms/from_dir.yaml +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/forms/from_file.yaml +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/forms/from_zarr.yaml +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/gui_config.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/icon.png +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/media_dialog.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/modern_video.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/project.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/style_profile.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/toolbar_icons/import_annotations.svg +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/toolbar_icons/open_audio_annotations.svg +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/toolbar_icons/save_annotations.svg +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/toolbar_icons/show_event_table.svg +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/toolbar_icons/show_movie.svg +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/toolbar_icons/show_sidebar.svg +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/toolbar_icons/show_spec.svg +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/toolbar_icons/show_timeline.svg +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/toolbar_icons/show_trace.svg +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/toolbar_icons/threshold_mode.svg +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/gui/widgets.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/io/__init__.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/io/balltracks.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/io/movieparams.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/io/samplestamps/__init__.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/io/samplestamps/samplestamps.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/io/samplestamps/utils.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/io/timestamps.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/loaders.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/metrics.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/src/xarray_behave/v1.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_annot.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_dataset_service.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_event_utils.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_fix_camera_timestamps.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_gui_app.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_gui_config.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_gui_media_dialog.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_gui_modern_video.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_gui_opengl.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_gui_project.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_gui_views.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_imports.py +0 -0
- {xarray_behave-0.38.0a5 → xarray_behave-1.0}/tests/test_sampstamps.py +0 -0
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
name: Test install
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [alpha]
|
|
4
6
|
release:
|
|
5
7
|
types:
|
|
6
8
|
- published
|
|
7
9
|
workflow_dispatch:
|
|
8
|
-
inputs:
|
|
9
|
-
logLevel:
|
|
10
|
-
description: 'Log level'
|
|
11
|
-
required: true
|
|
12
|
-
default: 'warning'
|
|
13
|
-
tags:
|
|
14
|
-
description: 'manual run'
|
|
15
10
|
|
|
16
11
|
jobs:
|
|
17
12
|
test:
|
|
@@ -20,6 +15,9 @@ jobs:
|
|
|
20
15
|
fail-fast: False
|
|
21
16
|
matrix:
|
|
22
17
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
|
18
|
+
env:
|
|
19
|
+
QT_QPA_PLATFORM: offscreen
|
|
20
|
+
PYTEST_QT_API: pyside6
|
|
23
21
|
defaults: # https://github.com/marketplace/actions/setup-miniconda#use-a-default-shell
|
|
24
22
|
run:
|
|
25
23
|
shell: bash -l {0}
|
|
@@ -28,18 +26,18 @@ jobs:
|
|
|
28
26
|
- name: Setup miniconda # https://github.com/marketplace/actions/setup-miniconda
|
|
29
27
|
uses: conda-incubator/setup-miniconda@v3
|
|
30
28
|
with:
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
miniforge-version: latest
|
|
30
|
+
activate-environment: xb-ci
|
|
31
|
+
auto-activate-base: false
|
|
33
32
|
channels: conda-forge
|
|
34
|
-
python-version: 3.
|
|
33
|
+
python-version: "3.14"
|
|
35
34
|
- name: Install OpenGL dependencies
|
|
36
35
|
run: sudo apt-get update && sudo apt-get install -qq -y libx11-dev libgl1-mesa-dev libxkbcommon-x11-0
|
|
37
36
|
if: runner.os == 'Linux'
|
|
38
37
|
- name: Test
|
|
39
38
|
run: |
|
|
40
|
-
conda
|
|
41
|
-
|
|
42
|
-
python -m pip install ".[dev]"
|
|
39
|
+
conda install -y uv
|
|
40
|
+
uv pip install ".[dev]"
|
|
43
41
|
python -c "import xarray_behave; print(xarray_behave.__version__)"
|
|
44
42
|
python -c "import xarray_behave.gui.app"
|
|
45
|
-
python -m pytest -q
|
|
43
|
+
python -m pytest -q
|
|
@@ -75,11 +75,8 @@ and swap into y/x before returning arrays.
|
|
|
75
75
|
- `assemble_metrics(...)` computes absolute and relative behavioral features
|
|
76
76
|
from poses or body tracking.
|
|
77
77
|
- `convert_spatial_units(...)` mutates dataset arrays in place.
|
|
78
|
-
- `save(...)`
|
|
79
|
-
|
|
80
|
-
cannot serialize that attr.
|
|
81
|
-
- `load(...)` opens zipped zarr stores, optionally copying to a temp store and
|
|
82
|
-
normalizing byte-string coordinates.
|
|
78
|
+
- `save(...)` stages a Zarr v3 store and atomically replaces the recording ZIP.
|
|
79
|
+
- `load(...)` opens the recording ZIP and can unpack it for lazy editing.
|
|
83
80
|
|
|
84
81
|
- `src/xarray_behave/annot.py`
|
|
85
82
|
- `Events` is the annotation container used across assembly and GUI code.
|
|
@@ -100,8 +97,6 @@ and swap into y/x before returning arrays.
|
|
|
100
97
|
- Converts between binary `song_events` traces and event-time dictionaries.
|
|
101
98
|
- Connected runs in binary traces become event start/stop rows. Single-sample
|
|
102
99
|
runs become point events with `start == stop`.
|
|
103
|
-
- Category inference helpers are legacy shims and return `"event"` for every
|
|
104
|
-
event type.
|
|
105
100
|
- `eventtimes_to_traces(...)` updates existing event names only.
|
|
106
101
|
- `update_traces(...)` rebuilds traces and can add new events.
|
|
107
102
|
|
|
@@ -168,8 +163,6 @@ Registered provider families:
|
|
|
168
163
|
- `DeepPoseKit`: `_poses_dpk.zarr`
|
|
169
164
|
- `Sleap`: `_poses_sleap.h5`, `_sleap.h5`, `_sleap.h5.slp`
|
|
170
165
|
- Annotations:
|
|
171
|
-
- `DAS`: `_song.h5`, `_vibration.h5`, `_pulse.h5`, `_sine.h5`,
|
|
172
|
-
`_dss.h5`, `_das.h5`
|
|
173
166
|
- `FlySongSegmenter`: `_song.mat`
|
|
174
167
|
- manual CSV/zarr/mat loaders in `annotations_manual.py`
|
|
175
168
|
- definitions loader: `_definitions.csv`
|
|
@@ -276,12 +269,7 @@ conda run -n das-conformer python -m pytest -q tests/test_gui_utils.py tests/tes
|
|
|
276
269
|
conda run -n das-conformer python -m pytest -q tests/test_imports.py tests/test_io.py
|
|
277
270
|
```
|
|
278
271
|
|
|
279
|
-
|
|
280
|
-
`tests/test_assemble_metrics.py` use fixture data paths under `tests/data`.
|
|
281
|
-
They are closer to smoke tests than strict structure assertions.
|
|
282
|
-
|
|
283
|
-
The GitHub Actions workflow only runs import/IO/samplestamp smoke tests after
|
|
284
|
-
creating an env from `env/xb.yml`.
|
|
272
|
+
The assembly and metrics tests use small, synthetic recordings.
|
|
285
273
|
|
|
286
274
|
## Common Change Patterns
|
|
287
275
|
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xarray-behave
|
|
3
|
-
Version: 0
|
|
3
|
+
Version: 1.0
|
|
4
4
|
Summary: xarray tools for behavioral data.
|
|
5
5
|
Author-email: Jan Clemens <clemensjan@googlemail.com>
|
|
6
|
-
Requires-Python: >=3.
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
9
|
License-File: LICENSE
|
|
10
10
|
Requires-Dist: defopt==6.3
|
|
11
|
-
Requires-Dist: flammkuchen
|
|
12
11
|
Requires-Dist: h5py
|
|
13
12
|
Requires-Dist: pyyaml
|
|
14
|
-
Requires-Dist: zarr
|
|
13
|
+
Requires-Dist: zarr>=3.1,<4
|
|
15
14
|
Requires-Dist: dask
|
|
16
15
|
Requires-Dist: pandas
|
|
17
|
-
Requires-Dist: xarray
|
|
16
|
+
Requires-Dist: xarray>=2025.3
|
|
18
17
|
Requires-Dist: numba
|
|
19
18
|
Requires-Dist: numpy
|
|
20
19
|
Requires-Dist: scipy>1.9
|
|
@@ -22,23 +21,28 @@ Requires-Dist: soundfile
|
|
|
22
21
|
Requires-Dist: librosa>0.8
|
|
23
22
|
Requires-Dist: av>=12
|
|
24
23
|
Requires-Dist: PySide6>=6.10
|
|
25
|
-
Requires-Dist: pyqtgraph
|
|
24
|
+
Requires-Dist: pyqtgraph>=0.13.4
|
|
26
25
|
Requires-Dist: qtpy
|
|
27
26
|
Requires-Dist: pytest ; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest-qt ; extra == "dev"
|
|
28
28
|
Requires-Dist: flit ; extra == "dev"
|
|
29
|
-
Project-URL: documentation, https://
|
|
29
|
+
Project-URL: documentation, https://github.com/janclemenslab/xarray-behave/blob/v1.0/README.md
|
|
30
30
|
Project-URL: source, https://github.com/janclemenslab/xarray-behave
|
|
31
31
|
Provides-Extra: dev
|
|
32
32
|
|
|
33
33
|
# xarray-behave
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Create a Python environment with Conda and install xarray-behave with uv.
|
|
36
36
|
|
|
37
37
|
```shell
|
|
38
|
-
conda
|
|
38
|
+
conda create -n xb -c conda-forge python=3.14 uv
|
|
39
|
+
conda activate xb
|
|
40
|
+
uv pip install xarray-behave==1.0
|
|
39
41
|
```
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
The GUI saves and opens recording archives in zipped Zarr format 3.
|
|
44
|
+
|
|
45
|
+
See [the demo](doc/demo.ipynb) for usage examples.
|
|
42
46
|
|
|
43
47
|
## GUI configuration
|
|
44
48
|
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
# xarray-behave
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Create a Python environment with Conda and install xarray-behave with uv.
|
|
4
4
|
|
|
5
5
|
```shell
|
|
6
|
-
conda
|
|
6
|
+
conda create -n xb -c conda-forge python=3.14 uv
|
|
7
|
+
conda activate xb
|
|
8
|
+
uv pip install xarray-behave==1.0
|
|
7
9
|
```
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
The GUI saves and opens recording archives in zipped Zarr format 3.
|
|
12
|
+
|
|
13
|
+
See [the demo](doc/demo.ipynb) for usage examples.
|
|
10
14
|
|
|
11
15
|
## GUI configuration
|
|
12
16
|
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["flit_core >=3.2"]
|
|
3
|
-
build-backend = "flit_core.buildapi"
|
|
4
|
-
|
|
5
1
|
[project]
|
|
6
2
|
name = "xarray-behave"
|
|
7
3
|
authors = [{ name = "Jan Clemens", email = "clemensjan@googlemail.com" }]
|
|
8
4
|
classifiers = ["License :: OSI Approved :: Apache Software License"]
|
|
9
5
|
dynamic = ["version", "description"]
|
|
10
|
-
requires-python = ">=3.
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
readme = "README.md"
|
|
11
8
|
dependencies = [
|
|
12
9
|
'defopt==6.3',
|
|
13
|
-
'flammkuchen',
|
|
14
10
|
'h5py',
|
|
15
11
|
'pyyaml',
|
|
16
|
-
'zarr
|
|
12
|
+
'zarr>=3.1,<4',
|
|
17
13
|
'dask',
|
|
18
14
|
'pandas',
|
|
19
|
-
'xarray
|
|
15
|
+
'xarray>=2025.3',
|
|
20
16
|
'numba',
|
|
21
17
|
'numpy',
|
|
22
18
|
'scipy>1.9',
|
|
@@ -24,30 +20,32 @@ dependencies = [
|
|
|
24
20
|
'librosa>0.8',
|
|
25
21
|
'av>=12',
|
|
26
22
|
'PySide6>=6.10',
|
|
27
|
-
'pyqtgraph
|
|
23
|
+
'pyqtgraph>=0.13.4',
|
|
28
24
|
'qtpy',
|
|
29
25
|
]
|
|
30
|
-
readme = "README.md"
|
|
31
26
|
|
|
32
27
|
[project.optional-dependencies]
|
|
33
|
-
dev = ["pytest", "flit"]
|
|
28
|
+
dev = ["pytest", "pytest-qt", "flit"]
|
|
34
29
|
|
|
35
30
|
[project.urls]
|
|
36
31
|
source = "https://github.com/janclemenslab/xarray-behave"
|
|
37
|
-
documentation = "https://
|
|
32
|
+
documentation = "https://github.com/janclemenslab/xarray-behave/blob/v1.0/README.md"
|
|
33
|
+
|
|
34
|
+
[build-system]
|
|
35
|
+
requires = ["flit_core >=3.2"]
|
|
36
|
+
build-backend = "flit_core.buildapi"
|
|
38
37
|
|
|
39
38
|
[tool.flit.module]
|
|
40
39
|
name = "xarray_behave"
|
|
41
40
|
|
|
42
|
-
[tool.flit.sdist]
|
|
43
|
-
include = ["scripts/fix_camera_timestamps.py", "tests/test_fix_camera_timestamps.py"]
|
|
44
|
-
|
|
45
41
|
[tool.pytest.ini_options]
|
|
46
42
|
minversion = "6.0"
|
|
47
43
|
testpaths = ["tests"]
|
|
48
44
|
|
|
49
45
|
[tool.ruff]
|
|
50
|
-
extend-select = ["C4", "NPY", "PD", "TCH"]
|
|
51
|
-
ignore = ["E501"]
|
|
52
46
|
show-fixes = true
|
|
53
47
|
line-length = 196
|
|
48
|
+
|
|
49
|
+
[tool.ruff.lint]
|
|
50
|
+
extend-select = ["C4", "NPY", "PD", "TC"]
|
|
51
|
+
ignore = ["E501"]
|
|
@@ -191,7 +191,7 @@ def _matches(spec, context):
|
|
|
191
191
|
patterns = spec.get("path", spec.get("paths", spec.get("patterns", [])))
|
|
192
192
|
matches = []
|
|
193
193
|
for pattern in patterns:
|
|
194
|
-
paths = sorted(glob(pattern.format(**context)))
|
|
194
|
+
paths = sorted(str(Path(path)) for path in glob(pattern.format(**context)))
|
|
195
195
|
if Path(pattern).name.startswith("{recording_prefix}*") and context["recording_prefix"]:
|
|
196
196
|
paths = [path for path in paths if io.is_recording_sidecar(path, context["recording_prefix"])]
|
|
197
197
|
matches.extend(paths)
|
|
@@ -55,15 +55,6 @@ def _as_start_stop_rows(event_data):
|
|
|
55
55
|
return rows[:, :2]
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
def infer_event_categories_from_traces(data):
|
|
59
|
-
"""Return legacy event categories for trace columns.
|
|
60
|
-
|
|
61
|
-
Args:
|
|
62
|
-
data ([type]): binary matrix [samples x events]
|
|
63
|
-
"""
|
|
64
|
-
return ["event"] * data.shape[1]
|
|
65
|
-
|
|
66
|
-
|
|
67
58
|
def update_traces(ds, event_times):
|
|
68
59
|
"""Slightly redundant with eventtimes_to_traces but
|
|
69
60
|
will add populate new events.
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import os
|
|
7
7
|
import sys
|
|
8
8
|
import logging
|
|
9
|
-
import inspect
|
|
10
9
|
from pathlib import Path
|
|
11
10
|
from functools import partial
|
|
12
11
|
|
|
@@ -261,11 +260,11 @@ class _DatasetBuildWorker(QtCore.QObject):
|
|
|
261
260
|
@QtCore.Slot()
|
|
262
261
|
def run(self):
|
|
263
262
|
try:
|
|
264
|
-
from das.data.
|
|
263
|
+
from das.data.training_package import export_training_package
|
|
265
264
|
|
|
266
|
-
self.result =
|
|
265
|
+
self.result = export_training_package(
|
|
267
266
|
self.values["data_folder"],
|
|
268
|
-
self.values["
|
|
267
|
+
self.values["destination"],
|
|
269
268
|
split_by=self.values["split_by"],
|
|
270
269
|
validation_fraction=self.values["validation_fraction"],
|
|
271
270
|
test_fraction=self.values["test_fraction"],
|
|
@@ -353,7 +352,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
353
352
|
|
|
354
353
|
def _build_das_menu(self):
|
|
355
354
|
self.das_menu = self.bar.addMenu("DAS")
|
|
356
|
-
self._add_keyed_menuitem(self.das_menu, "
|
|
355
|
+
self._add_keyed_menuitem(self.das_menu, "Export training package...", self.export_training_package, None)
|
|
357
356
|
self._add_keyed_menuitem(self.das_menu, "Train", self.das_train, None)
|
|
358
357
|
self._add_keyed_menuitem(self.das_menu, "Predict", self.das_predict, None)
|
|
359
358
|
|
|
@@ -983,7 +982,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
983
982
|
from das.gui_app import DASConformerWindow
|
|
984
983
|
except ImportError as e:
|
|
985
984
|
logger.exception(e)
|
|
986
|
-
|
|
985
|
+
QtWidgets.QMessageBox.warning(self, "DAS unavailable", f"Install das to train or predict.\n{e}")
|
|
987
986
|
return None
|
|
988
987
|
|
|
989
988
|
current_audio_provider = self._das_current_audio if use_current_audio and self._has_current_das_audio() else None
|
|
@@ -996,22 +995,12 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
996
995
|
}
|
|
997
996
|
if startup_config is not None:
|
|
998
997
|
window_kwargs["startup_config"] = startup_config
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
):
|
|
1006
|
-
window_kwargs["current_duration_provider"] = self._das_current_audio_duration
|
|
1007
|
-
if current_audio_provider is not None and (
|
|
1008
|
-
accepts_extra_kwargs or "annotated_region_provider" in das_signature.parameters
|
|
1009
|
-
):
|
|
1010
|
-
window_kwargs["annotated_region_provider"] = self._das_annotated_regions
|
|
1011
|
-
if current_audio_provider is not None and (
|
|
1012
|
-
accepts_extra_kwargs or "current_annotations_provider" in das_signature.parameters
|
|
1013
|
-
):
|
|
1014
|
-
window_kwargs["current_annotations_provider"] = self._das_current_annotations
|
|
998
|
+
if current_audio_provider is not None:
|
|
999
|
+
window_kwargs.update(
|
|
1000
|
+
current_duration_provider=self._das_current_audio_duration,
|
|
1001
|
+
annotated_region_provider=self._das_annotated_regions,
|
|
1002
|
+
current_annotations_provider=self._das_current_annotations,
|
|
1003
|
+
)
|
|
1015
1004
|
window = DASConformerWindow(**window_kwargs)
|
|
1016
1005
|
window.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
|
1017
1006
|
if not hasattr(self, "_das_windows"):
|
|
@@ -1034,24 +1023,24 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
1034
1023
|
del qt_keycode
|
|
1035
1024
|
self._open_das_window("train", use_current_audio=True)
|
|
1036
1025
|
|
|
1037
|
-
def
|
|
1026
|
+
def export_training_package(self, qt_keycode=None):
|
|
1038
1027
|
del qt_keycode
|
|
1039
1028
|
data_folder = QtWidgets.QFileDialog.getExistingDirectory(self, "Select annotated audio folder")
|
|
1040
1029
|
if not data_folder:
|
|
1041
1030
|
return
|
|
1042
1031
|
dialog = YamlDialog(
|
|
1043
|
-
yaml_file=package_dir + "/gui/forms/
|
|
1032
|
+
yaml_file=package_dir + "/gui/forms/training_package.yaml",
|
|
1044
1033
|
parent=self,
|
|
1045
|
-
title="
|
|
1034
|
+
title="Export training package",
|
|
1046
1035
|
)
|
|
1047
1036
|
dialog.form.fields["data_folder"].setText(data_folder)
|
|
1048
|
-
dialog.form.fields["
|
|
1037
|
+
dialog.form.fields["destination"].setText(os.path.normpath(data_folder) + ".h5")
|
|
1049
1038
|
if dialog.exec_() != QtWidgets.QDialog.Accepted:
|
|
1050
1039
|
return
|
|
1051
1040
|
|
|
1052
1041
|
values = dialog.form.get_form_data()
|
|
1053
1042
|
app = QtWidgets.QApplication.instance()
|
|
1054
|
-
progress = QtWidgets.QProgressDialog("
|
|
1043
|
+
progress = QtWidgets.QProgressDialog("Exporting training package...", "", 0, 0)
|
|
1055
1044
|
progress.setCancelButton(None)
|
|
1056
1045
|
progress.setWindowTitle("DAS")
|
|
1057
1046
|
progress.show()
|
|
@@ -1068,7 +1057,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
1068
1057
|
if worker.error is not None:
|
|
1069
1058
|
QtWidgets.QMessageBox.critical(None, "Dataset creation failed", worker.error)
|
|
1070
1059
|
else:
|
|
1071
|
-
QtWidgets.QMessageBox.information(None, "
|
|
1060
|
+
QtWidgets.QMessageBox.information(None, "Training package exported", f"Copy this file to your cluster:\n{worker.result}")
|
|
1072
1061
|
app._das_dataset_jobs.remove(job)
|
|
1073
1062
|
progress.deleteLater()
|
|
1074
1063
|
|
|
@@ -2758,11 +2747,9 @@ class PSV(MainWindow):
|
|
|
2758
2747
|
|
|
2759
2748
|
@spec_colormap.setter
|
|
2760
2749
|
def spec_colormap(self, value: str):
|
|
2761
|
-
self._spec_colormap = value
|
|
2762
|
-
|
|
2763
|
-
self.spec_view.set_colormap(
|
|
2764
|
-
except AttributeError:
|
|
2765
|
-
pass
|
|
2750
|
+
self._spec_colormap = value if value in utils.SPECTROGRAM_COLORMAPS else "turbo"
|
|
2751
|
+
if getattr(self, "spec_view", None) is not None:
|
|
2752
|
+
self.spec_view.set_colormap(self._spec_colormap)
|
|
2766
2753
|
|
|
2767
2754
|
@property
|
|
2768
2755
|
def box_size(self):
|
|
@@ -462,10 +462,13 @@ class FormBuilderLayout(QtWidgets.QFormLayout):
|
|
|
462
462
|
def select_file(*args, x=field):
|
|
463
463
|
if item["type"] == "file_dir":
|
|
464
464
|
filename = QtWidgets.QFileDialog.getExistingDirectory(None, caption="Select " + item["label"])
|
|
465
|
+
elif item["type"] == "file_save":
|
|
466
|
+
filename, _ = QtWidgets.QFileDialog.getSaveFileName(
|
|
467
|
+
None, "Export to", x.text(), item.get("filter", "Any File (*.*)")
|
|
468
|
+
)
|
|
465
469
|
else:
|
|
466
|
-
filter = item.get("filter", "Any File (*.*)")
|
|
467
470
|
filename, _ = QtWidgets.QFileDialog.getOpenFileName(
|
|
468
|
-
None, caption="Open File", dir=x.property("browse_directory") or "", filter=filter
|
|
471
|
+
None, caption="Open File", dir=x.property("browse_directory") or "", filter=item.get("filter", "Any File (*.*)")
|
|
469
472
|
)
|
|
470
473
|
if len(filename):
|
|
471
474
|
x.setText(filename)
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
main:
|
|
2
2
|
- type: text
|
|
3
|
-
text:
|
|
3
|
+
text: Export saved annotated recordings for native DAS training on another machine.
|
|
4
4
|
|
|
5
5
|
- name: data_folder
|
|
6
6
|
label: Data folder
|
|
7
7
|
type: file_dir
|
|
8
8
|
default: ""
|
|
9
9
|
|
|
10
|
-
- name:
|
|
11
|
-
label:
|
|
12
|
-
type:
|
|
10
|
+
- name: destination
|
|
11
|
+
label: Training package
|
|
12
|
+
type: file_save
|
|
13
|
+
filter: "HDF5 (*.h5 *.hdf5)"
|
|
13
14
|
default: ""
|
|
14
|
-
help:
|
|
15
|
+
help: Choose a new HDF5 file for the audio, labels, and splits.
|
|
15
16
|
|
|
16
17
|
- name: split_by
|
|
17
18
|
label: Split by
|
|
@@ -43,6 +44,6 @@ main:
|
|
|
43
44
|
range: 0,2147483647
|
|
44
45
|
|
|
45
46
|
- name: create
|
|
46
|
-
label:
|
|
47
|
+
label: Export
|
|
47
48
|
type: button
|
|
48
49
|
default: main action
|
|
@@ -5,6 +5,9 @@ import pyqtgraph as pg
|
|
|
5
5
|
from qtpy import QtGui, QtWidgets, QtCore
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
SPECTROGRAM_COLORMAPS = tuple(sorted(pg.colormap.listMaps(), key=str.casefold))
|
|
9
|
+
|
|
10
|
+
|
|
8
11
|
def make_colors(nb_colors: int) -> Iterable:
|
|
9
12
|
if nb_colors <= 0:
|
|
10
13
|
return np.zeros((0, 3), dtype=np.uint8)
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
from qtpy import QtWidgets, QtCore
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
"turbo",
|
|
6
|
-
"viridis",
|
|
7
|
-
"magma",
|
|
8
|
-
"inferno",
|
|
9
|
-
"plasma",
|
|
10
|
-
"cividis",
|
|
11
|
-
"gray",
|
|
12
|
-
"bone",
|
|
13
|
-
"hot",
|
|
14
|
-
"cool",
|
|
15
|
-
)
|
|
4
|
+
from . import utils
|
|
16
5
|
|
|
17
6
|
|
|
18
7
|
def _spectrogram_level_max(model):
|
|
@@ -38,11 +27,8 @@ def _make_colormap_row(model):
|
|
|
38
27
|
|
|
39
28
|
combo = QtWidgets.QComboBox(row)
|
|
40
29
|
combo.setObjectName("spectrogramColormapCombo")
|
|
41
|
-
combo.addItems(SPECTROGRAM_COLORMAPS)
|
|
42
|
-
|
|
43
|
-
if current_colormap not in SPECTROGRAM_COLORMAPS:
|
|
44
|
-
combo.addItem(current_colormap)
|
|
45
|
-
combo.setCurrentText(current_colormap)
|
|
30
|
+
combo.addItems(utils.SPECTROGRAM_COLORMAPS)
|
|
31
|
+
combo.setCurrentText(model.spec_colormap)
|
|
46
32
|
combo.currentTextChanged.connect(lambda value: setattr(model, "spec_colormap", value))
|
|
47
33
|
|
|
48
34
|
hbox = QtWidgets.QHBoxLayout(row)
|
|
@@ -337,22 +337,6 @@ class TrackView(TraceView):
|
|
|
337
337
|
self.addItem(pos_line)
|
|
338
338
|
|
|
339
339
|
|
|
340
|
-
def _lookup_colormap_lut(colormap: str):
|
|
341
|
-
cmap = None
|
|
342
|
-
try:
|
|
343
|
-
cmap = pg.colormap.getFromMatplotlib(colormap)
|
|
344
|
-
except Exception:
|
|
345
|
-
pass
|
|
346
|
-
if cmap is None:
|
|
347
|
-
try:
|
|
348
|
-
cmap = pg.colormap.get(colormap)
|
|
349
|
-
except Exception:
|
|
350
|
-
cmap = None
|
|
351
|
-
if cmap is None:
|
|
352
|
-
cmap = pg.colormap.get("viridis")
|
|
353
|
-
return cmap.getLookupTable()
|
|
354
|
-
|
|
355
|
-
|
|
356
340
|
class SpecView(pg.ImageView):
|
|
357
341
|
def __init__(self, model, callback, colormap="turbo"):
|
|
358
342
|
super().__init__(view=pg.PlotItem(axisItems={"left": InsideYTickAxis()}))
|
|
@@ -456,7 +440,7 @@ class SpecView(pg.ImageView):
|
|
|
456
440
|
_delete_dialog_later(dialog)
|
|
457
441
|
|
|
458
442
|
def set_colormap(self, colormap: str):
|
|
459
|
-
self.imageItem.setLookupTable(
|
|
443
|
+
self.imageItem.setLookupTable(pg.colormap.get(colormap).getLookupTable())
|
|
460
444
|
self.imageItem.update()
|
|
461
445
|
|
|
462
446
|
def update_spec(self, x, y):
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import h5py
|
|
2
|
+
import numpy as np
|
|
3
|
+
import scipy.io
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
from .. import io
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@io.register_provider
|
|
10
|
+
class FlySongSegmenter(io.BaseProvider):
|
|
11
|
+
KIND = "annotations"
|
|
12
|
+
NAME = "FlySongSegmenter"
|
|
13
|
+
SUFFIXES = ["_song.mat"]
|
|
14
|
+
|
|
15
|
+
def load(self, filename: Optional[str] = None):
|
|
16
|
+
"""Load output produced by FlySongSegmenter."""
|
|
17
|
+
if filename is None:
|
|
18
|
+
filename = self.path
|
|
19
|
+
|
|
20
|
+
res = dict()
|
|
21
|
+
try:
|
|
22
|
+
d = scipy.io.loadmat(filename)
|
|
23
|
+
res["pulse_times_samples"] = d["pInf"][0, 0]["wc"]
|
|
24
|
+
res["pulse_labels"] = d["pInf"][0, 0]["pulseLabels"]
|
|
25
|
+
res["song_mask"] = d["bInf"][0, 0]["Mask"].T # 0 - silence, 1 - pulse, 2 - sine
|
|
26
|
+
except NotImplementedError:
|
|
27
|
+
with h5py.File(filename, "r") as f:
|
|
28
|
+
res["pulse_times_samples"] = f["pInf/wc"][:].T
|
|
29
|
+
res["pulse_labels"] = f["pInf/pulseLabels"][:].T
|
|
30
|
+
res["song_mask"] = f["bInf/Mask"][:]
|
|
31
|
+
|
|
32
|
+
sine_song = res["song_mask"] == 2
|
|
33
|
+
fs = 10_000 # Hz
|
|
34
|
+
|
|
35
|
+
res["event_names"] = ["song_pulse_any_fss", "song_pulse_slow_fss", "song_pulse_fast_fss", "sine_fss"]
|
|
36
|
+
res["event_categories"] = ["event", "event", "event", "event"]
|
|
37
|
+
res["event_indices"] = [
|
|
38
|
+
res["pulse_times_samples"],
|
|
39
|
+
res["pulse_times_samples"][res["pulse_labels"] == 1],
|
|
40
|
+
res["pulse_times_samples"][res["pulse_labels"] == 0],
|
|
41
|
+
np.where(sine_song == 2)[0],
|
|
42
|
+
]
|
|
43
|
+
# extract event_seconds
|
|
44
|
+
event_seconds = {
|
|
45
|
+
"song_pulse_any_fss": res["pulse_times_samples"] / fs,
|
|
46
|
+
"song_pulse_slow_fss": res["pulse_times_samples"][res["pulse_labels"] == 1] / fs,
|
|
47
|
+
"song_pulse_fast_fss": res["pulse_times_samples"][res["pulse_labels"] == 0] / fs,
|
|
48
|
+
"sine_fss": np.where(sine_song == 2)[0] / fs,
|
|
49
|
+
}
|
|
50
|
+
# event_categories
|
|
51
|
+
event_categories = {}
|
|
52
|
+
for cat, typ in zip(event_seconds.keys(), ["event", "event", "event", "event"]):
|
|
53
|
+
event_categories[cat] = typ
|
|
54
|
+
return event_seconds, event_categories
|
|
@@ -4,7 +4,7 @@ import numpy as np
|
|
|
4
4
|
import pandas as pd
|
|
5
5
|
import scipy.io
|
|
6
6
|
from typing import Optional
|
|
7
|
-
from .. import io, annot,
|
|
7
|
+
from .. import io, annot, event_utils
|
|
8
8
|
|
|
9
9
|
logger = logging.getLogger(__name__)
|
|
10
10
|
|
|
@@ -156,20 +156,15 @@ class Manual_xb_zarr(io.BaseProvider):
|
|
|
156
156
|
if filename is None:
|
|
157
157
|
filename = self.path
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
from zarr.storage import ZipStore
|
|
160
|
+
import xarray as xr
|
|
160
161
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
event_seconds
|
|
167
|
-
|
|
168
|
-
event_categories = {}
|
|
169
|
-
for typ in manual_events_ds.event_types.data:
|
|
170
|
-
event_categories[typ] = "event"
|
|
171
|
-
|
|
172
|
-
return event_seconds, event_categories
|
|
162
|
+
with ZipStore(filename, mode="r") as store, xr.open_zarr(store) as ds:
|
|
163
|
+
ds = ds[["song_events"]].load()
|
|
164
|
+
if ds.event_types.dtype.kind == "S":
|
|
165
|
+
ds = ds.assign_coords(event_types=ds.event_types.astype(str))
|
|
166
|
+
event_seconds = event_utils.detect_events(ds)
|
|
167
|
+
return event_seconds, dict.fromkeys(event_seconds, "event")
|
|
173
168
|
|
|
174
169
|
|
|
175
170
|
@io.register_provider
|