xarray-behave 0.35.1__tar.gz → 0.35.3__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 (57) hide show
  1. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/.github/workflows/publish.yaml +2 -1
  2. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/PKG-INFO +1 -1
  3. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/conda/xarray-behave/meta.yaml +2 -1
  4. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/__init__.py +2 -1
  5. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/annot.py +9 -7
  6. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/event_utils.py +7 -3
  7. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/app.py +5 -17
  8. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/das.py +9 -2
  9. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/formbuilder.py +1 -0
  10. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/io/audio.py +1 -0
  11. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/io/balltracks.py +1 -0
  12. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/io/movieparams.py +1 -0
  13. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/io/poses.py +1 -0
  14. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/loaders.py +1 -0
  15. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/metrics.py +1 -0
  16. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/xarray_behave.py +1 -0
  17. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/.gitignore +0 -0
  18. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/LICENSE +0 -0
  19. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/README.md +0 -0
  20. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/build_env.yml +0 -0
  21. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/conda/xarray-behave/bld.bat +0 -0
  22. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/conda/xarray-behave/build.sh +0 -0
  23. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/conda/xarray-behave/conda_build_config.yaml +0 -0
  24. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/condarc.yml +0 -0
  25. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/doc/demo.ipynb +0 -0
  26. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/doc/demo_behavioral_features.ipynb +0 -0
  27. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/doc/demo_behavioral_features_large_group.ipynb +0 -0
  28. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/doc/ncb.mplstyle +0 -0
  29. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/pyproject.toml +0 -0
  30. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/setup.py +0 -0
  31. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/__init__.py +0 -0
  32. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/audio_player.py +0 -0
  33. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/forms/das_make.yaml +0 -0
  34. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/forms/das_predict.yaml +0 -0
  35. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/forms/das_train.yaml +0 -0
  36. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/forms/envelope_computation.yaml +0 -0
  37. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/forms/export_for_das.yaml +0 -0
  38. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/forms/from_dir.yaml +0 -0
  39. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/forms/from_file.yaml +0 -0
  40. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/forms/from_zarr.yaml +0 -0
  41. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/forms/spec_freq.yaml +0 -0
  42. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/icon.png +0 -0
  43. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/table.py +0 -0
  44. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/utils.py +0 -0
  45. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/view_dialog.py +0 -0
  46. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/views.py +0 -0
  47. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/gui/widgets.py +0 -0
  48. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/io/__init__.py +0 -0
  49. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/io/annotations.py +0 -0
  50. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/io/annotations_manual.py +0 -0
  51. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/io/timestamps.py +0 -0
  52. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/src/xarray_behave/io/tracks.py +0 -0
  53. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/tests/test_annot.py +0 -0
  54. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/tests/test_assemble.py +0 -0
  55. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/tests/test_assemble_metrics.py +0 -0
  56. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/tests/test_imports.py +0 -0
  57. {xarray-behave-0.35.1 → xarray-behave-0.35.3}/tests/test_io.py +0 -0
@@ -19,8 +19,9 @@ jobs:
19
19
  strategy:
20
20
  fail-fast: False
21
21
  matrix:
22
- python-version: [3.9 , '3.10'] # , '3.11']
22
+ python-version: [3.9 , '3.10', '3.11']
23
23
  os: [ubuntu-latest, windows-latest, macOS-13, macOS-14]
24
+ # os: [macOS-13, macOS-14]
24
25
  # python-version: ['3.11']
25
26
  # os: [ubuntu-latest]
26
27
  defaults: # https://github.com/marketplace/actions/setup-miniconda#use-a-default-shell
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xarray-behave
3
- Version: 0.35.1
3
+ Version: 0.35.3
4
4
  Summary: xarray tools for behavioral data.
5
5
  Author-email: Jan Clemens <clemensjan@googlemail.com>
6
6
  Requires-Python: >3.6
@@ -35,7 +35,8 @@ requirements:
35
35
  - xarray
36
36
  - dask
37
37
  #- py
38
- - conda-forge::pyside6 # [not win]
38
+ - conda-forge::pyside6 # [linux]
39
+ - conda-forge::pyside2 # [osx or arm64]
39
40
  - pyside6 # [win and py==310]
40
41
  - pyside2 # [win and py>310]
41
42
  - pyside2 # [win and py==39]
@@ -1,5 +1,6 @@
1
1
  """xarray tools for behavioral data."""
2
- __version__ = "0.35.1"
2
+
3
+ __version__ = "0.35.3"
3
4
 
4
5
  from .xarray_behave import assemble, assemble_metrics, load, save
5
6
  import os
@@ -2,6 +2,7 @@
2
2
 
3
3
  TODO: From/to traces
4
4
  """
5
+
5
6
  import numpy as np
6
7
  import xarray as xr
7
8
  import pandas as pd
@@ -132,19 +133,20 @@ class Events(UserDict):
132
133
  names = []
133
134
  start_seconds = []
134
135
  stop_seconds = []
135
-
136
136
  if len(dct.values()):
137
- if list(dct.values())[0].shape[1] > 2:
137
+ # check if there are annotations and if so, if they comes with channel information
138
+ if list(dct.values())[0].ndim > 1 and list(dct.values())[0].shape[1] > 2:
138
139
  channels = []
139
140
  else:
140
141
  channels = None
141
142
 
142
143
  for k, v in dct.items():
143
- names.extend([k] * v.shape[0])
144
- start_seconds.extend(v[:, 0])
145
- stop_seconds.extend(v[:, 1])
146
- if channels is not None:
147
- channels.extend(v[:, 2])
144
+ if len(v): # check if there are annotations
145
+ names.extend([k] * v.shape[0])
146
+ start_seconds.extend(v[:, 0])
147
+ stop_seconds.extend(v[:, 1])
148
+ if channels is not None:
149
+ channels.extend(v[:, 2])
148
150
  out = cls.from_lists(names, start_seconds, stop_seconds, channels=channels)
149
151
  return out
150
152
 
@@ -2,6 +2,7 @@ import logging
2
2
  import numpy as np
3
3
  import xarray as xr
4
4
  import pandas as pd
5
+ import scipy
5
6
 
6
7
 
7
8
  logger = logging.getLogger(__name__)
@@ -182,14 +183,14 @@ def eventtimes_to_traces(ds, event_times):
182
183
  return ds
183
184
 
184
185
 
185
- def traces_to_eventtimes(traces, event_names, event_categories):
186
+ def traces_to_eventtimes(traces, event_names, event_categories, events_are_binary: bool = True):
186
187
  """[summary]
187
188
 
188
189
  Args:
189
190
  traces ([type]): list of numpy arrays with the binary traces for each event/segment
190
191
  event_names ([type]): [description]
191
192
  event_categories ([type]): [description]
192
-
193
+ events_are_binary (bool, True): detect events indices where value is 1.0. Otherwise use scipy.signal.find_peaks.
193
194
  Returns:
194
195
  [type]: [description]
195
196
  """
@@ -202,7 +203,10 @@ def traces_to_eventtimes(traces, event_names, event_categories):
202
203
  for event_idx, (event_name, event_category) in enumerate(zip(event_names, event_categories)):
203
204
  logger.info(f" {event_name}")
204
205
  if event_category == "event":
205
- event_times[event_name] = np.where(traces[event_idx] == 1)[0]
206
+ if events_are_binary:
207
+ event_times[event_name] = np.where(traces[event_idx] == 1)[0]
208
+ else:
209
+ event_times[event_name], _ = scipy.signal.find_peaks(traces[event_idx])
206
210
  elif event_category == "segment":
207
211
  tmp = (traces[event_idx] == 1).astype(float) # makes this more robust
208
212
  onsets = np.where(np.diff(tmp) == 1)[0]
@@ -2,6 +2,7 @@
2
2
 
3
3
  `python -m xarray_behave.ui datename root`
4
4
  """
5
+
5
6
  import os
6
7
  import sys
7
8
  import logging
@@ -2302,14 +2303,6 @@ class PSV(MainWindow):
2302
2303
  f" Moved {event_name_to_move} from t=[{region.bounds[0]:1.4f}:{region.bounds[1]:1.4f}] to [{new_region[0]:1.4f}:{new_region[1]:1.4f}] seconds."
2303
2304
  )
2304
2305
 
2305
- mp = self.annot_view.mousePoint.y()
2306
- if mp > 0 and mp < 1:
2307
- new_event_idx = int(mp * self.nb_eventtypes)
2308
- new_event_name = self.event_times.names[new_event_idx]
2309
- _, old_name, new_name = self.event_times.change_name(new_region[0], new_event_name)
2310
- if old_name is not None:
2311
- logger.info(f" Changed from {old_name} to {new_name}.")
2312
-
2313
2306
  self.update_xy()
2314
2307
 
2315
2308
  def on_position_change_finished(self, position):
@@ -2324,15 +2317,6 @@ class PSV(MainWindow):
2324
2317
  self.event_times.move_time(event_name_to_move, position.position, new_position)
2325
2318
  logger.info(f" Moved {event_name_to_move} from t={position.position:1.4f} to {new_position:1.4f} seconds.")
2326
2319
 
2327
- mp = self.annot_view.mousePoint.y()
2328
- if mp > 0 and mp < 1:
2329
- new_event_idx = int(mp * self.nb_eventtypes)
2330
- new_event_name = self.event_times.names[new_event_idx]
2331
- print(new_event_name)
2332
- _, old_name, new_name = self.event_times.change_name(new_position, new_event_name, tol=1)
2333
- if old_name is not None:
2334
- logger.info(f" Changed from {old_name} to {new_name}.")
2335
-
2336
2320
  self.update_xy()
2337
2321
 
2338
2322
  def on_position_dragged(self, fly, pos, offset):
@@ -2807,3 +2791,7 @@ def cli():
2807
2791
  logger.getLogger().setLevel(logging.INFO)
2808
2792
 
2809
2793
  defopt.run(main, show_defaults=False)
2794
+
2795
+
2796
+ if __name__ == "__main__":
2797
+ main_das()
@@ -8,6 +8,7 @@ import zarr
8
8
  import numpy as np
9
9
  import pandas as pd
10
10
  import librosa
11
+ import scipy
11
12
  import h5py
12
13
 
13
14
  import das.make_dataset as dsm
@@ -408,8 +409,14 @@ def make(
408
409
  names = store.attrs["class_names"][1:] # [1:] ignore the noise class
409
410
  types = store.attrs["class_types"][1:]
410
411
  for key in store.keys():
411
- ann = event_utils.traces_to_eventtimes(store[key]["y"][:, 1:].T, names, types)
412
- ann = {k: v / fs for k, v in ann.items()} # convert indices to seconds
412
+ ann = event_utils.traces_to_eventtimes(store[key]["y"][:, 1:].T, names, types, events_are_binary=False)
413
+ for k, v in ann.items():
414
+ if (
415
+ v.ndim == 1
416
+ ): # add start/stop seconds for events - traces_to_eventtimes only returns event start times but annot expects both start and end
417
+ v = np.stack((v, v)).T
418
+ v = v / fs # convert indices to seconds
419
+ ann[k] = v
413
420
  ev = annot.Events.from_dict(ann)
414
421
  ev.to_df().to_csv(os.path.join(store.attrs["store_folder"], key, "x_annotations.csv"))
415
422
  logger.info("The dataset has been made.")
@@ -26,6 +26,7 @@ is :py:method:`FormBuilderLayout.add_item()`. Look there if you want to know
26
26
  what's supported in the YAML file, what exactly each field type does, or if you
27
27
  want to add a new type of supported form field.
28
28
  """
29
+
29
30
  # modified from https://sleap.ai/_modules/sleap/gui/formbuilder.html
30
31
  import yaml
31
32
  from typing import Any, Dict, List, Optional, Union, Text
@@ -5,6 +5,7 @@ should return:
5
5
  non_audio_data: np.array[time, samples]
6
6
  samplerate: Optional[float]
7
7
  """
8
+
8
9
  # [x] daq.h5
9
10
  # [x] wav, ....
10
11
  # [x] npz, npy
@@ -3,6 +3,7 @@
3
3
  should return:
4
4
  x: pd.DataFrame[frames, (variables)]
5
5
  """
6
+
6
7
  import numpy as np
7
8
  import pandas as pd
8
9
  from .. import io
@@ -1,6 +1,7 @@
1
1
  """Load parameters for DLP movies
2
2
 
3
3
  """
4
+
4
5
  import numpy as np
5
6
  import pandas as pd
6
7
  import h5py
@@ -7,6 +7,7 @@ should return:
7
7
  first_pose_frame: int
8
8
  last_pose_frame: int
9
9
  """
10
+
10
11
  import h5py
11
12
  import numpy as np
12
13
  import xarray as xr
@@ -1,4 +1,5 @@
1
1
  """Load files created by various analysis programs created."""
2
+
2
3
  import numpy as np
3
4
  import pandas as pd
4
5
  import scipy.interpolate
@@ -1,4 +1,5 @@
1
1
  """Calculate metrics from behavioral data."""
2
+
2
3
  import numpy as np
3
4
  import scipy.signal.windows
4
5
 
@@ -1,4 +1,5 @@
1
1
  """Create self-documenting xarray dataset from behavioral recordings and annotations."""
2
+
2
3
  import numpy as np
3
4
  from samplestamps.samplestamps import SampStamp, SimpleStamp
4
5
  import scipy.interpolate
File without changes
File without changes
File without changes