ZaksPhysicsLibrary 1.7.0__tar.gz → 1.8.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 (24) hide show
  1. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PKG-INFO +2 -2
  2. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/__init__.py +1 -0
  3. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/processing_TDT.py +36 -0
  4. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/README.md +1 -1
  5. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/ZaksPhysicsLibrary.egg-info/PKG-INFO +2 -2
  6. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/pyproject.toml +1 -1
  7. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/LICENSE +0 -0
  8. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/analysis.py +0 -0
  9. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/dataset.py +0 -0
  10. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/field_study_validation.py +0 -0
  11. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/file_parser.py +0 -0
  12. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/file_parser_generic.py +0 -0
  13. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/loaders/__init__.py +0 -0
  14. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/loaders/oxysoft_loader.py +0 -0
  15. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/loaders/pt2_loader.py +0 -0
  16. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/loaders/tdt_loader.py +0 -0
  17. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/models.py +0 -0
  18. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/splice.py +0 -0
  19. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/PhysicsLibrary/text_field_study.py +0 -0
  20. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/ZaksPhysicsLibrary.egg-info/SOURCES.txt +0 -0
  21. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/ZaksPhysicsLibrary.egg-info/dependency_links.txt +0 -0
  22. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/ZaksPhysicsLibrary.egg-info/requires.txt +0 -0
  23. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/ZaksPhysicsLibrary.egg-info/top_level.txt +0 -0
  24. {zaksphysicslibrary-1.7.0 → zaksphysicslibrary-1.8.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ZaksPhysicsLibrary
3
- Version: 1.7.0
3
+ Version: 1.8.0
4
4
  Summary: Data processing and analysis library for TDT, Oxysoft NIRS, Terranova EFNMR lab data, and text-field studies
5
5
  Author: zakgm2
6
6
  License-Expression: MIT
@@ -173,7 +173,7 @@ Everything importable from `PhysicsLibrary` directly:
173
173
  |----------|-------|
174
174
  | Format detection | `detect_format`, `detect_format_file`, `DataFormat`, `Dataset` |
175
175
  | Loading | `load_dataset`, `load_dataset_file`, `load_any_file`, `load_pt2` |
176
- | TDT processing | `process_tdt_folder`, `validate_tdt_folder`, `get_tdt_struct`, `get_plot_data`, `correct_bleaching`, `denoise_signal`, `get_event_markers` |
176
+ | TDT processing | `process_tdt_folder`, `validate_tdt_folder`, `get_tdt_struct`, `get_plot_data`, `correct_bleaching`, `denoise_signal`, `get_event_markers`, `debounce_events` |
177
177
  | Analysis | `get_zscore_slice`, `smooth_signal`, `bin_for_heatmap`, `compute_fft_slice`, `annotate_fft_peaks`, `compute_slope_segment`, `fit_model_to_segment` |
178
178
  | Curve fit models | `linear_model`, `single_exponential_model`, `exponential_rise_model`, `double_exponential_model`, `gaussian_model`, `sinusoidal_model`, `visibility_model` |
179
179
  | Text field study | `run_field_study_pipeline`, `load_field_study_folder`, `peek_fields`, `flag_low_quality`, `embed_text_fields`, `compute_delta_vector`, `compute_paired_similarity`, `permutation_test_similarity`, `wordcount_confound_check` |
@@ -35,6 +35,7 @@ from .processing_TDT import (
35
35
  correct_bleaching,
36
36
  denoise_signal,
37
37
  get_event_markers,
38
+ debounce_events,
38
39
  )
39
40
 
40
41
  from .analysis import (
@@ -375,6 +375,42 @@ def get_event_markers(data):
375
375
  return markers
376
376
 
377
377
 
378
+ def debounce_events(times, min_isi):
379
+ """
380
+ Collapse switch-bounce / double-tap duplicates out of a list of event
381
+ timestamps (e.g. lever-press onsets), independent of any fixed-ratio
382
+ schedule (FR1, FR3, ...).
383
+
384
+ A real lever contact and a bounce/duplicate reading of the same
385
+ physical press land within milliseconds of each other — far closer
386
+ than an animal can genuinely press again. Sorting the timestamps and
387
+ dropping anything within `min_isi` seconds of the last *kept* event
388
+ removes those duplicates while leaving genuinely fast consecutive
389
+ presses (e.g. during an FR3 burst) intact, as long as `min_isi` is
390
+ below the animal's real max press rate.
391
+
392
+ Parameters
393
+ ----------
394
+ times : sequence of float
395
+ Raw event timestamps, in seconds. Need not be sorted.
396
+ min_isi : float
397
+ Minimum inter-event interval, in seconds. Any event whose gap from
398
+ the previous kept event is smaller than this is dropped. The
399
+ first press of a bounce cluster is always the one kept.
400
+
401
+ Returns
402
+ -------
403
+ list of float
404
+ Sorted timestamps with sub-`min_isi` duplicates removed.
405
+ """
406
+ sorted_times = sorted(float(t) for t in times)
407
+ kept = []
408
+ for t in sorted_times:
409
+ if not kept or (t - kept[-1]) >= min_isi:
410
+ kept.append(t)
411
+ return kept
412
+
413
+
378
414
  def denoise_signal(signal, fs, cutoff=5, order=2):
379
415
  """
380
416
  Low-pass Butterworth filter for ΔF/F signals.
@@ -145,7 +145,7 @@ Everything importable from `PhysicsLibrary` directly:
145
145
  |----------|-------|
146
146
  | Format detection | `detect_format`, `detect_format_file`, `DataFormat`, `Dataset` |
147
147
  | Loading | `load_dataset`, `load_dataset_file`, `load_any_file`, `load_pt2` |
148
- | TDT processing | `process_tdt_folder`, `validate_tdt_folder`, `get_tdt_struct`, `get_plot_data`, `correct_bleaching`, `denoise_signal`, `get_event_markers` |
148
+ | TDT processing | `process_tdt_folder`, `validate_tdt_folder`, `get_tdt_struct`, `get_plot_data`, `correct_bleaching`, `denoise_signal`, `get_event_markers`, `debounce_events` |
149
149
  | Analysis | `get_zscore_slice`, `smooth_signal`, `bin_for_heatmap`, `compute_fft_slice`, `annotate_fft_peaks`, `compute_slope_segment`, `fit_model_to_segment` |
150
150
  | Curve fit models | `linear_model`, `single_exponential_model`, `exponential_rise_model`, `double_exponential_model`, `gaussian_model`, `sinusoidal_model`, `visibility_model` |
151
151
  | Text field study | `run_field_study_pipeline`, `load_field_study_folder`, `peek_fields`, `flag_low_quality`, `embed_text_fields`, `compute_delta_vector`, `compute_paired_similarity`, `permutation_test_similarity`, `wordcount_confound_check` |
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ZaksPhysicsLibrary
3
- Version: 1.7.0
3
+ Version: 1.8.0
4
4
  Summary: Data processing and analysis library for TDT, Oxysoft NIRS, Terranova EFNMR lab data, and text-field studies
5
5
  Author: zakgm2
6
6
  License-Expression: MIT
@@ -173,7 +173,7 @@ Everything importable from `PhysicsLibrary` directly:
173
173
  |----------|-------|
174
174
  | Format detection | `detect_format`, `detect_format_file`, `DataFormat`, `Dataset` |
175
175
  | Loading | `load_dataset`, `load_dataset_file`, `load_any_file`, `load_pt2` |
176
- | TDT processing | `process_tdt_folder`, `validate_tdt_folder`, `get_tdt_struct`, `get_plot_data`, `correct_bleaching`, `denoise_signal`, `get_event_markers` |
176
+ | TDT processing | `process_tdt_folder`, `validate_tdt_folder`, `get_tdt_struct`, `get_plot_data`, `correct_bleaching`, `denoise_signal`, `get_event_markers`, `debounce_events` |
177
177
  | Analysis | `get_zscore_slice`, `smooth_signal`, `bin_for_heatmap`, `compute_fft_slice`, `annotate_fft_peaks`, `compute_slope_segment`, `fit_model_to_segment` |
178
178
  | Curve fit models | `linear_model`, `single_exponential_model`, `exponential_rise_model`, `double_exponential_model`, `gaussian_model`, `sinusoidal_model`, `visibility_model` |
179
179
  | Text field study | `run_field_study_pipeline`, `load_field_study_folder`, `peek_fields`, `flag_low_quality`, `embed_text_fields`, `compute_delta_vector`, `compute_paired_similarity`, `permutation_test_similarity`, `wordcount_confound_check` |
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ZaksPhysicsLibrary"
7
- version = "1.7.0"
7
+ version = "1.8.0"
8
8
  description = "Data processing and analysis library for TDT, Oxysoft NIRS, Terranova EFNMR lab data, and text-field studies"
9
9
  requires-python = ">=3.10"
10
10
  readme = "README.md"