boris-behav-obs 9.7.7__py3-none-any.whl

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.

Potentially problematic release.


This version of boris-behav-obs might be problematic. Click here for more details.

Files changed (109) hide show
  1. boris/__init__.py +26 -0
  2. boris/__main__.py +25 -0
  3. boris/about.py +143 -0
  4. boris/add_modifier.py +635 -0
  5. boris/add_modifier_ui.py +303 -0
  6. boris/advanced_event_filtering.py +455 -0
  7. boris/analysis_plugins/__init__.py +0 -0
  8. boris/analysis_plugins/_latency.py +59 -0
  9. boris/analysis_plugins/irr_cohen_kappa.py +109 -0
  10. boris/analysis_plugins/irr_cohen_kappa_with_modifiers.py +112 -0
  11. boris/analysis_plugins/irr_weighted_cohen_kappa.py +157 -0
  12. boris/analysis_plugins/irr_weighted_cohen_kappa_with_modifiers.py +162 -0
  13. boris/analysis_plugins/list_of_dataframe_columns.py +22 -0
  14. boris/analysis_plugins/number_of_occurences.py +22 -0
  15. boris/analysis_plugins/number_of_occurences_by_independent_variable.py +54 -0
  16. boris/analysis_plugins/time_budget.py +61 -0
  17. boris/behav_coding_map_creator.py +1110 -0
  18. boris/behavior_binary_table.py +305 -0
  19. boris/behaviors_coding_map.py +239 -0
  20. boris/boris_cli.py +340 -0
  21. boris/cmd_arguments.py +49 -0
  22. boris/coding_pad.py +280 -0
  23. boris/config.py +785 -0
  24. boris/config_file.py +356 -0
  25. boris/connections.py +409 -0
  26. boris/converters.py +333 -0
  27. boris/converters_ui.py +225 -0
  28. boris/cooccurence.py +250 -0
  29. boris/core.py +5901 -0
  30. boris/core_qrc.py +15958 -0
  31. boris/core_ui.py +1107 -0
  32. boris/db_functions.py +324 -0
  33. boris/dev.py +134 -0
  34. boris/dialog.py +1108 -0
  35. boris/duration_widget.py +238 -0
  36. boris/edit_event.py +245 -0
  37. boris/edit_event_ui.py +233 -0
  38. boris/event_operations.py +1040 -0
  39. boris/events_cursor.py +61 -0
  40. boris/events_snapshots.py +596 -0
  41. boris/exclusion_matrix.py +141 -0
  42. boris/export_events.py +1006 -0
  43. boris/export_observation.py +1203 -0
  44. boris/external_processes.py +332 -0
  45. boris/geometric_measurement.py +941 -0
  46. boris/gui_utilities.py +135 -0
  47. boris/image_overlay.py +72 -0
  48. boris/import_observations.py +242 -0
  49. boris/ipc_mpv.py +325 -0
  50. boris/irr.py +634 -0
  51. boris/latency.py +244 -0
  52. boris/measurement_widget.py +161 -0
  53. boris/media_file.py +115 -0
  54. boris/menu_options.py +213 -0
  55. boris/modifier_coding_map_creator.py +1013 -0
  56. boris/modifiers_coding_map.py +157 -0
  57. boris/mpv.py +2016 -0
  58. boris/mpv2.py +2193 -0
  59. boris/observation.py +1453 -0
  60. boris/observation_operations.py +2538 -0
  61. boris/observation_ui.py +679 -0
  62. boris/observations_list.py +337 -0
  63. boris/otx_parser.py +442 -0
  64. boris/param_panel.py +201 -0
  65. boris/param_panel_ui.py +305 -0
  66. boris/player_dock_widget.py +198 -0
  67. boris/plot_data_module.py +536 -0
  68. boris/plot_events.py +634 -0
  69. boris/plot_events_rt.py +237 -0
  70. boris/plot_spectrogram_rt.py +316 -0
  71. boris/plot_waveform_rt.py +230 -0
  72. boris/plugins.py +431 -0
  73. boris/portion/__init__.py +31 -0
  74. boris/portion/const.py +95 -0
  75. boris/portion/dict.py +365 -0
  76. boris/portion/func.py +52 -0
  77. boris/portion/interval.py +581 -0
  78. boris/portion/io.py +181 -0
  79. boris/preferences.py +510 -0
  80. boris/preferences_ui.py +770 -0
  81. boris/project.py +2007 -0
  82. boris/project_functions.py +2041 -0
  83. boris/project_import_export.py +1096 -0
  84. boris/project_ui.py +794 -0
  85. boris/qrc_boris.py +10389 -0
  86. boris/qrc_boris5.py +2579 -0
  87. boris/select_modifiers.py +312 -0
  88. boris/select_observations.py +210 -0
  89. boris/select_subj_behav.py +286 -0
  90. boris/state_events.py +197 -0
  91. boris/subjects_pad.py +106 -0
  92. boris/synthetic_time_budget.py +290 -0
  93. boris/time_budget_functions.py +1136 -0
  94. boris/time_budget_widget.py +1039 -0
  95. boris/transitions.py +365 -0
  96. boris/utilities.py +1810 -0
  97. boris/version.py +24 -0
  98. boris/video_equalizer.py +159 -0
  99. boris/video_equalizer_ui.py +248 -0
  100. boris/video_operations.py +310 -0
  101. boris/view_df.py +104 -0
  102. boris/view_df_ui.py +75 -0
  103. boris/write_event.py +538 -0
  104. boris_behav_obs-9.7.7.dist-info/METADATA +139 -0
  105. boris_behav_obs-9.7.7.dist-info/RECORD +109 -0
  106. boris_behav_obs-9.7.7.dist-info/WHEEL +5 -0
  107. boris_behav_obs-9.7.7.dist-info/entry_points.txt +2 -0
  108. boris_behav_obs-9.7.7.dist-info/licenses/LICENSE.TXT +674 -0
  109. boris_behav_obs-9.7.7.dist-info/top_level.txt +1 -0
@@ -0,0 +1,238 @@
1
+ """
2
+
3
+ widget to edit duration > 24 h or < 0
4
+
5
+ https://stackoverflow.com/questions/44380202/creating-a-custom-widget-in-PySide6
6
+ """
7
+
8
+ from decimal import Decimal as dec
9
+
10
+ from PySide6.QtWidgets import (
11
+ QWidget,
12
+ QHBoxLayout,
13
+ QPushButton,
14
+ QSpinBox,
15
+ QLabel,
16
+ QSpacerItem,
17
+ QSizePolicy,
18
+ QDoubleSpinBox,
19
+ QStackedWidget,
20
+ QRadioButton,
21
+ )
22
+
23
+ from PySide6.QtCore import Signal
24
+
25
+ from . import config as cfg
26
+
27
+
28
+ class Widget_hhmmss(QWidget):
29
+ time_changed_signal = Signal(float)
30
+
31
+ def __init__(self, parent=None):
32
+ QWidget.__init__(self, parent=parent)
33
+
34
+ lay = QHBoxLayout(self)
35
+ lay.setSpacing(0)
36
+ lay.setContentsMargins(0, 0, 0, 0)
37
+
38
+ self.sign = QPushButton("+")
39
+ self.sign.clicked.connect(self.change_sign)
40
+ self.sign.setStyleSheet("font-size:12px;")
41
+ lay.addWidget(self.sign)
42
+
43
+ self.hours = QSpinBox()
44
+ self.hours.setValue(0)
45
+ self.hours.setMinimum(0)
46
+ self.hours.setMaximum(2**31 - 1)
47
+ self.hours.valueChanged.connect(self.update_time_value)
48
+ lay.addWidget(self.hours)
49
+ lay.addWidget(QLabel(":"))
50
+
51
+ self.minutes = QSpinBox()
52
+ self.minutes.setMinimum(-1)
53
+ self.minutes.setMaximum(60)
54
+ self.minutes.setPrefix("0")
55
+ self.minutes.valueChanged.connect(lambda value, x=self.minutes: self.value_changed(value, x, 0, 59))
56
+ lay.addWidget(self.minutes)
57
+ lay.addWidget(QLabel(":"))
58
+
59
+ self.seconds = QSpinBox()
60
+ self.seconds.setMinimum(-1)
61
+ self.seconds.setMaximum(60)
62
+ self.seconds.setPrefix("0")
63
+ self.seconds.valueChanged.connect(lambda value, x=self.seconds: self.value_changed(value, x, 0, 59))
64
+ lay.addWidget(self.seconds)
65
+ lay.addWidget(QLabel(":"))
66
+
67
+ self.milliseconds = QSpinBox()
68
+ self.milliseconds.setMinimum(-1)
69
+ self.milliseconds.setMaximum(1000)
70
+ self.milliseconds.setPrefix("00")
71
+ self.milliseconds.valueChanged.connect(lambda value, x=self.milliseconds: self.value_changed(value, x, 0, 999))
72
+ lay.addWidget(self.milliseconds)
73
+
74
+ spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
75
+ lay.addItem(spacerItem)
76
+ self.setLayout(lay)
77
+
78
+ def change_sign(self):
79
+ """
80
+ sign has changed
81
+ """
82
+ self.sign.setText("+" if self.sign.text() == "-" else "-")
83
+ self.update_time_value()
84
+
85
+ def update_time_value(self):
86
+ new_time = self.hours.value() * 3600 + self.minutes.value() * 60 + self.seconds.value() + self.milliseconds.value() / 1000
87
+ if self.sign.text() == "-":
88
+ new_time = -new_time
89
+
90
+ self.time_changed_signal.emit(new_time)
91
+
92
+ def value_changed(self, new_value, widget, val_min, val_max):
93
+ """
94
+ time value changed
95
+ """
96
+
97
+ if new_value > val_max:
98
+ widget.setValue(val_min)
99
+ widget.setPrefix("0" if val_max < 100 else "00")
100
+ self.update_time_value()
101
+ return
102
+
103
+ if new_value < val_min:
104
+ widget.setValue(val_max)
105
+ widget.setPrefix("")
106
+ self.update_time_value()
107
+ return
108
+
109
+ if new_value < 10:
110
+ widget.setPrefix("0" if val_max < 100 else "00")
111
+ elif new_value < 100:
112
+ widget.setPrefix("" if val_max < 100 else "0")
113
+ else:
114
+ widget.setPrefix("")
115
+
116
+ self.update_time_value()
117
+
118
+
119
+ class Widget_seconds(QWidget):
120
+ time_changed_signal = Signal(float)
121
+
122
+ def __init__(self, parent=None):
123
+ QWidget.__init__(self, parent=parent)
124
+ lay = QHBoxLayout(self)
125
+ lay.setSpacing(0)
126
+ lay.setContentsMargins(0, 0, 0, 0)
127
+
128
+ self.seconds2 = QDoubleSpinBox()
129
+ self.seconds2.setValue(0)
130
+ self.seconds2.setMinimum(-100_000_000)
131
+ self.seconds2.setMaximum(100_000_000)
132
+ self.seconds2.setDecimals(3)
133
+ self.seconds2.valueChanged.connect(self.value_changed)
134
+ lay.addWidget(self.seconds2)
135
+
136
+ spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
137
+ lay.addItem(spacerItem)
138
+
139
+ self.setLayout(lay)
140
+
141
+ def value_changed(self, v):
142
+ self.time_changed_signal.emit(v)
143
+
144
+
145
+ class Duration_widget(QWidget):
146
+ def __init__(self, time_value=0, parent=None):
147
+ super().__init__()
148
+
149
+ self.time_value = dec(time_value).quantize(dec(".001"))
150
+
151
+ lay = QHBoxLayout(self)
152
+ lay.setSpacing(0)
153
+ lay.setContentsMargins(0, 0, 0, 0)
154
+
155
+ self.Stack = QStackedWidget()
156
+
157
+ self.w1 = Widget_hhmmss()
158
+ self.w1.time_changed_signal.connect(self.time_changed)
159
+ self.Stack.addWidget(self.w1)
160
+
161
+ self.w2 = Widget_seconds()
162
+ self.w2.time_changed_signal.connect(self.time_changed)
163
+ self.Stack.addWidget(self.w2)
164
+
165
+ lay.addWidget(self.Stack)
166
+
167
+ self.format_hhmmss = QRadioButton("HH:MM:SS:MS")
168
+ self.format_hhmmss.setChecked(True)
169
+ self.format_hhmmss.clicked.connect(self.set_format_hhmmss)
170
+ lay.addWidget(self.format_hhmmss)
171
+ self.format_s = QRadioButton("seconds")
172
+ self.format_s.clicked.connect(self.set_format_s)
173
+ lay.addWidget(self.format_s)
174
+
175
+ lay.addItem(QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum))
176
+
177
+ self.setLayout(lay)
178
+
179
+ self.set_time(self.time_value)
180
+
181
+ def time_changed(self, x):
182
+ """
183
+ widget time has changed
184
+ """
185
+ self.time_value = x
186
+
187
+ def set_time(self, new_time):
188
+ if new_time.is_nan():
189
+ return
190
+
191
+ self.w1.sign.setText("-" if new_time < 0 else "+")
192
+
193
+ h = int(abs(new_time) // 3600)
194
+ m = int((abs(new_time) - h * 3600) // 60)
195
+ s = int((abs(new_time) - h * 3600 - m * 60))
196
+ ms = round((abs(new_time) - h * 3600 - m * 60 - s) * 1000)
197
+
198
+ self.w1.hours.setValue(h)
199
+ self.w1.minutes.setValue(m)
200
+ self.w1.seconds.setValue(s)
201
+ self.w1.milliseconds.setValue(ms)
202
+
203
+ self.w2.seconds2.setValue(new_time)
204
+
205
+ self.time_value = new_time
206
+
207
+ def set_format_s(self):
208
+ """
209
+ switch to seconds widget
210
+ """
211
+
212
+ self.format_s.setChecked(True)
213
+ self.w2.seconds2.setValue(self.time_value)
214
+ self.Stack.setCurrentIndex(1)
215
+
216
+ def set_format_hhmmss(self):
217
+ """
218
+ switch to HHMMSS widget
219
+ """
220
+
221
+ self.format_hhmmss.setChecked(True)
222
+ self.set_time(self.time_value)
223
+ self.Stack.setCurrentIndex(0)
224
+
225
+ def set_format(self, time_format):
226
+ """
227
+ switch time format in base of time_format value
228
+ """
229
+ if time_format in [cfg.HHMMSS, cfg.HHMMSSZZZ]:
230
+ self.set_format_hhmmss()
231
+ if time_format in [cfg.S]:
232
+ self.set_format_s()
233
+
234
+ def get_time(self) -> dec:
235
+ """
236
+ return time displayed by widget in seconds
237
+ """
238
+ return dec(self.time_value).quantize(dec(".001"))
boris/edit_event.py ADDED
@@ -0,0 +1,245 @@
1
+ """
2
+ BORIS
3
+ Behavioral Observation Research Interactive Software
4
+ Copyright 2012-2025 Olivier Friard
5
+
6
+ This file is part of BORIS.
7
+
8
+ BORIS is free software; you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation; either version 3 of the License, or
11
+ any later version.
12
+
13
+ BORIS is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program; if not see <http://www.gnu.org/licenses/>.
20
+
21
+ """
22
+
23
+ from decimal import Decimal as dec
24
+ import logging
25
+
26
+ from PySide6.QtWidgets import (
27
+ QDialog,
28
+ QHBoxLayout,
29
+ QLabel,
30
+ QLineEdit,
31
+ QListWidget,
32
+ QMessageBox,
33
+ QPushButton,
34
+ QRadioButton,
35
+ QVBoxLayout,
36
+ )
37
+
38
+ from . import config as cfg
39
+ from . import dialog
40
+ from .edit_event_ui import Ui_Form
41
+
42
+
43
+ class DlgEditEvent(QDialog, Ui_Form):
44
+ def __init__(
45
+ self,
46
+ observation_type: str,
47
+ time_value: dec = dec("NaN"),
48
+ image_idx=None,
49
+ current_time=0,
50
+ time_format: str = cfg.S,
51
+ show_set_current_time: bool = False,
52
+ exif_date_time: dec | None = None,
53
+ parent=None,
54
+ ):
55
+ super().__init__(parent)
56
+ self.setupUi(self)
57
+ self.time_value = time_value
58
+ self.image_idx = image_idx
59
+ self.observation_type = observation_type
60
+
61
+ self.pb_set_to_current_time.setVisible(show_set_current_time)
62
+ self.current_time = current_time
63
+ self.exif_date_time = exif_date_time
64
+
65
+ # hide frame index for all observations
66
+ # frame index is determined in base of time
67
+ for w in (
68
+ self.lb_frame_idx,
69
+ self.sb_frame_idx,
70
+ self.cb_set_frame_idx_na,
71
+ ):
72
+ w.setVisible(False)
73
+
74
+ # hide image index
75
+ if observation_type in (cfg.LIVE, cfg.MEDIA):
76
+ # hide image index
77
+ for w in (
78
+ self.cb_set_time_na,
79
+ self.gb_image_index,
80
+ ):
81
+ w.setVisible(False)
82
+
83
+ # widget for time
84
+ self.time_widget = dialog.get_time_widget(self.time_value)
85
+
86
+ if time_format == cfg.S:
87
+ self.time_widget.rb_seconds.setChecked(True)
88
+ if time_format == cfg.HHMMSS:
89
+ self.time_widget.rb_time.setChecked(True)
90
+ if not self.time_value.is_nan() and int(self.time_value) > cfg.DATE_CUTOFF:
91
+ self.time_widget.rb_datetime.setChecked(True)
92
+
93
+ self.horizontalLayout_3.insertWidget(0, self.time_widget)
94
+
95
+ if observation_type == cfg.IMAGES:
96
+ # hide frame index widgets
97
+ self.pb_set_to_current_time.setVisible(self.exif_date_time is not None)
98
+ self.sb_image_idx.setValue(self.image_idx)
99
+
100
+ self.pb_set_to_current_time.clicked.connect(self.set_to_current_time)
101
+ self.pb_set_to_current_image_index.clicked.connect(self.set_to_current_image_index)
102
+
103
+ self.cb_set_time_na.stateChanged.connect(self.time_na)
104
+
105
+ # self.cb_set_frame_idx_na.stateChanged.connect(self.frame_idx_na)
106
+ self.pbOK.clicked.connect(self.close_widget)
107
+ self.pbCancel.clicked.connect(self.reject)
108
+
109
+ def close_widget(self):
110
+ """
111
+ close the widget
112
+ """
113
+ if self.observation_type in (cfg.IMAGES):
114
+ if self.sb_image_idx.value() == 0:
115
+ QMessageBox.warning(self, cfg.programName, "The image index cannot be null")
116
+ return
117
+ self.accept()
118
+
119
+ def set_to_current_image_index(self):
120
+ """
121
+ set image index to current image index
122
+ """
123
+ if self.observation_type in (cfg.IMAGES):
124
+ self.sb_image_idx.setValue(int(self.current_time))
125
+
126
+ def set_to_current_time(self):
127
+ """
128
+ set time to current media time
129
+ """
130
+
131
+ if self.observation_type in (cfg.LIVE, cfg.MEDIA):
132
+ self.time_widget.set_time(dec(float(self.current_time)))
133
+
134
+ if self.observation_type == cfg.IMAGES:
135
+ if self.exif_date_time is not None:
136
+ self.time_widget.set_time(dec(self.exif_date_time))
137
+
138
+ def time_na(self):
139
+ """
140
+ set/unset time to NA
141
+ """
142
+
143
+ logging.debug("time_na function")
144
+
145
+ self.time_widget.setVisible(not self.cb_set_time_na.isChecked())
146
+ self.time_widget.setEnabled(not self.cb_set_time_na.isChecked())
147
+
148
+ self.pb_set_to_current_time.setVisible(not self.cb_set_time_na.isChecked() and self.exif_date_time is not None)
149
+ self.pb_set_to_current_time.setEnabled(not self.cb_set_time_na.isChecked())
150
+
151
+
152
+ class EditSelectedEvents(QDialog):
153
+ """
154
+ "edit selected events" dialog box
155
+ """
156
+
157
+ def __init__(self):
158
+ super(EditSelectedEvents, self).__init__()
159
+
160
+ self.setWindowTitle("Edit selected events")
161
+
162
+ hbox = QVBoxLayout(self)
163
+
164
+ self.rbSubject = QRadioButton("Subject")
165
+ self.rbSubject.setChecked(False)
166
+ self.rbSubject.toggled.connect(self.rb_changed)
167
+ hbox.addWidget(self.rbSubject)
168
+
169
+ self.rbBehavior = QRadioButton("Behavior")
170
+ self.rbBehavior.setChecked(False)
171
+ self.rbBehavior.toggled.connect(self.rb_changed)
172
+ hbox.addWidget(self.rbBehavior)
173
+
174
+ self.lb = QLabel("New value")
175
+ hbox.addWidget(self.lb)
176
+ self.newText = QListWidget(self)
177
+ hbox.addWidget(self.newText)
178
+
179
+ self.rbComment = QRadioButton("Comment")
180
+ self.rbComment.setChecked(False)
181
+ self.rbComment.toggled.connect(self.rb_changed)
182
+ hbox.addWidget(self.rbComment)
183
+
184
+ self.lbComment = QLabel("New comment")
185
+ hbox.addWidget(self.lbComment)
186
+
187
+ self.commentText = QLineEdit()
188
+ hbox.addWidget(self.commentText)
189
+
190
+ hbox2 = QHBoxLayout(self)
191
+ self.pbOK = QPushButton("OK")
192
+ self.pbOK.clicked.connect(self.pbOK_clicked)
193
+ self.pbCancel = QPushButton("Cancel")
194
+ self.pbCancel.clicked.connect(self.pbCancel_clicked)
195
+ hbox2.addWidget(self.pbCancel)
196
+ hbox2.addWidget(self.pbOK)
197
+ hbox.addLayout(hbox2)
198
+
199
+ self.setLayout(hbox)
200
+
201
+ def rb_changed(self):
202
+ self.newText.setEnabled(not self.rbComment.isChecked())
203
+ self.commentText.setEnabled(self.rbComment.isChecked())
204
+
205
+ if self.rbSubject.isChecked():
206
+ self.newText.clear()
207
+ self.newText.addItems(self.all_subjects)
208
+
209
+ if self.rbBehavior.isChecked():
210
+ self.newText.clear()
211
+ self.newText.addItems(self.all_behaviors)
212
+
213
+ if self.rbComment.isChecked():
214
+ self.newText.clear()
215
+
216
+ def pbOK_clicked(self):
217
+ """
218
+ if not self.rbSubject.isChecked() and not self.rbBehavior.isChecked() and not self.rbComment.isChecked():
219
+ QMessageBox.warning(
220
+ None,
221
+ cfg.programName,
222
+ "You must select a field to be edited",
223
+ QMessageBox.Ok | QMessageBox.Default,
224
+ QMessageBox.NoButton,
225
+ )
226
+ return
227
+ """
228
+
229
+ if (self.rbSubject.isChecked() or self.rbBehavior.isChecked()) and self.newText.selectedItems() == []:
230
+ QMessageBox.warning(
231
+ None,
232
+ cfg.programName,
233
+ "You must select a new value from the list",
234
+ QMessageBox.Ok | QMessageBox.Default,
235
+ QMessageBox.NoButton,
236
+ )
237
+ return
238
+
239
+ self.accept()
240
+
241
+ def pbCancel_clicked(self):
242
+ """
243
+ Cancel editing
244
+ """
245
+ self.reject()