boris-behav-obs 8.12__py3-none-any.whl → 9.7.6__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.
- boris/__init__.py +1 -1
- boris/__main__.py +1 -1
- boris/about.py +28 -39
- boris/add_modifier.py +122 -109
- boris/add_modifier_ui.py +239 -135
- boris/advanced_event_filtering.py +81 -45
- boris/analysis_plugins/__init__.py +0 -0
- boris/analysis_plugins/_latency.py +59 -0
- boris/analysis_plugins/irr_cohen_kappa.py +109 -0
- boris/analysis_plugins/irr_cohen_kappa_with_modifiers.py +112 -0
- boris/analysis_plugins/irr_weighted_cohen_kappa.py +157 -0
- boris/analysis_plugins/irr_weighted_cohen_kappa_with_modifiers.py +162 -0
- boris/analysis_plugins/list_of_dataframe_columns.py +22 -0
- boris/analysis_plugins/number_of_occurences.py +22 -0
- boris/analysis_plugins/number_of_occurences_by_independent_variable.py +54 -0
- boris/analysis_plugins/time_budget.py +61 -0
- boris/behav_coding_map_creator.py +228 -229
- boris/behavior_binary_table.py +33 -50
- boris/behaviors_coding_map.py +17 -18
- boris/boris_cli.py +6 -25
- boris/cmd_arguments.py +12 -1
- boris/coding_pad.py +42 -49
- boris/config.py +141 -65
- boris/config_file.py +58 -67
- boris/connections.py +107 -61
- boris/converters.py +13 -37
- boris/converters_ui.py +187 -110
- boris/cooccurence.py +250 -0
- boris/core.py +2373 -1786
- boris/core_qrc.py +15895 -10743
- boris/core_ui.py +943 -798
- boris/db_functions.py +17 -42
- boris/dev.py +109 -8
- boris/dialog.py +482 -236
- boris/duration_widget.py +9 -14
- boris/edit_event.py +61 -31
- boris/edit_event_ui.py +208 -97
- boris/event_operations.py +408 -293
- boris/events_cursor.py +25 -17
- boris/events_snapshots.py +36 -82
- boris/exclusion_matrix.py +4 -9
- boris/export_events.py +184 -223
- boris/export_observation.py +74 -100
- boris/external_processes.py +123 -98
- boris/geometric_measurement.py +644 -290
- boris/gui_utilities.py +91 -14
- boris/image_overlay.py +4 -4
- boris/import_observations.py +190 -98
- boris/ipc_mpv.py +325 -0
- boris/irr.py +20 -57
- boris/latency.py +31 -24
- boris/measurement_widget.py +14 -18
- boris/media_file.py +17 -19
- boris/menu_options.py +17 -6
- boris/modifier_coding_map_creator.py +1013 -0
- boris/modifiers_coding_map.py +7 -9
- boris/mpv.py +1 -0
- boris/mpv2.py +732 -705
- boris/observation.py +533 -221
- boris/observation_operations.py +1025 -390
- boris/observation_ui.py +572 -362
- boris/observations_list.py +71 -53
- boris/otx_parser.py +74 -68
- boris/param_panel.py +31 -16
- boris/param_panel_ui.py +254 -138
- boris/player_dock_widget.py +90 -60
- boris/plot_data_module.py +25 -33
- boris/plot_events.py +127 -90
- boris/plot_events_rt.py +17 -31
- boris/plot_spectrogram_rt.py +95 -30
- boris/plot_waveform_rt.py +32 -21
- boris/plugins.py +431 -0
- boris/portion/__init__.py +18 -8
- boris/portion/const.py +35 -18
- boris/portion/dict.py +5 -5
- boris/portion/func.py +2 -2
- boris/portion/interval.py +21 -41
- boris/portion/io.py +41 -32
- boris/preferences.py +306 -83
- boris/preferences_ui.py +684 -227
- boris/project.py +448 -293
- boris/project_functions.py +671 -238
- boris/project_import_export.py +213 -222
- boris/project_ui.py +674 -438
- boris/qrc_boris.py +6 -3
- boris/qrc_boris5.py +6 -3
- boris/select_modifiers.py +74 -48
- boris/select_observations.py +20 -198
- boris/select_subj_behav.py +67 -39
- boris/state_events.py +52 -35
- boris/subjects_pad.py +6 -9
- boris/synthetic_time_budget.py +45 -28
- boris/time_budget_functions.py +171 -171
- boris/time_budget_widget.py +84 -114
- boris/transitions.py +41 -47
- boris/utilities.py +627 -236
- boris/version.py +3 -3
- boris/video_equalizer.py +16 -14
- boris/video_equalizer_ui.py +199 -130
- boris/video_operations.py +95 -29
- boris/view_df.py +104 -0
- boris/view_df_ui.py +75 -0
- boris/write_event.py +538 -0
- boris_behav_obs-9.7.6.dist-info/METADATA +139 -0
- boris_behav_obs-9.7.6.dist-info/RECORD +109 -0
- {boris_behav_obs-8.12.dist-info → boris_behav_obs-9.7.6.dist-info}/WHEEL +1 -1
- boris_behav_obs-9.7.6.dist-info/entry_points.txt +2 -0
- boris/README.TXT +0 -22
- boris/add_modifier.ui +0 -323
- boris/converters.ui +0 -289
- boris/core.qrc +0 -36
- boris/core.ui +0 -1556
- boris/edit_event.ui +0 -233
- boris/icons/logo_eye.ico +0 -0
- boris/map_creator.py +0 -850
- boris/observation.ui +0 -814
- boris/param_panel.ui +0 -379
- boris/preferences.ui +0 -537
- boris/project.ui +0 -1069
- boris/project_server.py +0 -236
- boris/vlc.py +0 -10343
- boris/vlc_local.py +0 -90
- boris_behav_obs-8.12.dist-info/LICENSE.TXT +0 -674
- boris_behav_obs-8.12.dist-info/METADATA +0 -128
- boris_behav_obs-8.12.dist-info/RECORD +0 -108
- boris_behav_obs-8.12.dist-info/entry_points.txt +0 -3
- {boris → boris_behav_obs-9.7.6.dist-info/licenses}/LICENSE.TXT +0 -0
- {boris_behav_obs-8.12.dist-info → boris_behav_obs-9.7.6.dist-info}/top_level.txt +0 -0
boris/db_functions.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""
|
|
2
2
|
BORIS
|
|
3
3
|
Behavioral Observation Research Interactive Software
|
|
4
|
-
Copyright 2012-
|
|
4
|
+
Copyright 2012-2025 Olivier Friard
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
This program is free software; you can redistribute it and/or modify
|
|
@@ -56,8 +56,7 @@ def load_events_in_db(
|
|
|
56
56
|
state_behaviors_codes = [
|
|
57
57
|
pj[cfg.ETHOGRAM][x][cfg.BEHAVIOR_CODE]
|
|
58
58
|
for x in pj[cfg.ETHOGRAM]
|
|
59
|
-
if cfg.STATE in pj[cfg.ETHOGRAM][x][cfg.TYPE].upper()
|
|
60
|
-
and pj[cfg.ETHOGRAM][x][cfg.BEHAVIOR_CODE] in selected_behaviors
|
|
59
|
+
if cfg.STATE in pj[cfg.ETHOGRAM][x][cfg.TYPE].upper() and pj[cfg.ETHOGRAM][x][cfg.BEHAVIOR_CODE] in selected_behaviors
|
|
61
60
|
]
|
|
62
61
|
|
|
63
62
|
# selected behaviors defined as point event
|
|
@@ -71,6 +70,7 @@ def load_events_in_db(
|
|
|
71
70
|
"""
|
|
72
71
|
|
|
73
72
|
db = sqlite3.connect(":memory:", isolation_level=None)
|
|
73
|
+
|
|
74
74
|
"""
|
|
75
75
|
import os
|
|
76
76
|
os.system("rm /tmp/ramdisk/events.sqlite")
|
|
@@ -99,20 +99,14 @@ def load_events_in_db(
|
|
|
99
99
|
cursor.execute("CREATE INDEX modifiers_idx ON events(modifiers)")
|
|
100
100
|
|
|
101
101
|
for subject_to_analyze in selected_subjects:
|
|
102
|
-
|
|
103
102
|
for obs_id in selected_observations:
|
|
104
|
-
|
|
105
103
|
for event in pj[cfg.OBSERVATIONS][obs_id][cfg.EVENTS]:
|
|
106
|
-
|
|
107
104
|
if event[cfg.EVENT_BEHAVIOR_FIELD_IDX] in selected_behaviors:
|
|
108
|
-
|
|
109
105
|
# extract time, code, modifier and comment (time:0, subject:1, code:2, modifier:3, comment:4)
|
|
110
106
|
if (subject_to_analyze == cfg.NO_FOCAL_SUBJECT and event[cfg.EVENT_SUBJECT_FIELD_IDX] == "") or (
|
|
111
107
|
event[cfg.EVENT_SUBJECT_FIELD_IDX] == subject_to_analyze
|
|
112
108
|
):
|
|
113
|
-
|
|
114
109
|
if pj[cfg.OBSERVATIONS][obs_id][cfg.TYPE] in (cfg.MEDIA, cfg.LIVE):
|
|
115
|
-
|
|
116
110
|
cursor.execute(
|
|
117
111
|
(
|
|
118
112
|
"INSERT INTO events "
|
|
@@ -125,18 +119,12 @@ def load_events_in_db(
|
|
|
125
119
|
if event[cfg.EVENT_SUBJECT_FIELD_IDX] == ""
|
|
126
120
|
else event[cfg.EVENT_SUBJECT_FIELD_IDX],
|
|
127
121
|
event[cfg.EVENT_BEHAVIOR_FIELD_IDX],
|
|
128
|
-
cfg.STATE
|
|
129
|
-
if event[cfg.EVENT_BEHAVIOR_FIELD_IDX] in state_behaviors_codes
|
|
130
|
-
else cfg.POINT,
|
|
122
|
+
cfg.STATE if event[cfg.EVENT_BEHAVIOR_FIELD_IDX] in state_behaviors_codes else cfg.POINT,
|
|
131
123
|
event[cfg.EVENT_MODIFIER_FIELD_IDX],
|
|
132
|
-
float(event[cfg.EVENT_TIME_FIELD_IDX])
|
|
133
|
-
if not event[cfg.EVENT_TIME_FIELD_IDX].is_nan()
|
|
134
|
-
else None,
|
|
124
|
+
float(event[cfg.EVENT_TIME_FIELD_IDX]) if not event[cfg.EVENT_TIME_FIELD_IDX].is_nan() else None,
|
|
135
125
|
event[cfg.EVENT_COMMENT_FIELD_IDX],
|
|
136
126
|
# frame index or NA
|
|
137
|
-
event_operations.read_event_field(
|
|
138
|
-
event, pj[cfg.OBSERVATIONS][obs_id][cfg.TYPE], cfg.FRAME_INDEX
|
|
139
|
-
),
|
|
127
|
+
event_operations.read_event_field(event, pj[cfg.OBSERVATIONS][obs_id][cfg.TYPE], cfg.FRAME_INDEX),
|
|
140
128
|
),
|
|
141
129
|
)
|
|
142
130
|
|
|
@@ -153,13 +141,9 @@ def load_events_in_db(
|
|
|
153
141
|
if event[cfg.EVENT_SUBJECT_FIELD_IDX] == ""
|
|
154
142
|
else event[cfg.EVENT_SUBJECT_FIELD_IDX],
|
|
155
143
|
event[cfg.EVENT_BEHAVIOR_FIELD_IDX],
|
|
156
|
-
cfg.STATE
|
|
157
|
-
if event[cfg.EVENT_BEHAVIOR_FIELD_IDX] in state_behaviors_codes
|
|
158
|
-
else cfg.POINT,
|
|
144
|
+
cfg.STATE if event[cfg.EVENT_BEHAVIOR_FIELD_IDX] in state_behaviors_codes else cfg.POINT,
|
|
159
145
|
event[cfg.EVENT_MODIFIER_FIELD_IDX],
|
|
160
|
-
float(event[cfg.EVENT_TIME_FIELD_IDX])
|
|
161
|
-
if not event[cfg.EVENT_TIME_FIELD_IDX].is_nan()
|
|
162
|
-
else None,
|
|
146
|
+
float(event[cfg.EVENT_TIME_FIELD_IDX]) if not event[cfg.EVENT_TIME_FIELD_IDX].is_nan() else None,
|
|
163
147
|
event[cfg.EVENT_COMMENT_FIELD_IDX],
|
|
164
148
|
event[cfg.PJ_OBS_FIELDS[cfg.IMAGES][cfg.IMAGE_INDEX]],
|
|
165
149
|
event[cfg.PJ_OBS_FIELDS[cfg.IMAGES][cfg.IMAGE_PATH]],
|
|
@@ -189,7 +173,7 @@ def load_aggregated_events_in_db(
|
|
|
189
173
|
|
|
190
174
|
"""
|
|
191
175
|
|
|
192
|
-
logging.debug(
|
|
176
|
+
logging.debug("function: load_aggregated_events_in_db")
|
|
193
177
|
|
|
194
178
|
# if no observation selected select all
|
|
195
179
|
if not selected_observations:
|
|
@@ -197,20 +181,16 @@ def load_aggregated_events_in_db(
|
|
|
197
181
|
|
|
198
182
|
# if no subject selected select all
|
|
199
183
|
if not selected_subjects:
|
|
200
|
-
selected_subjects = sorted(
|
|
201
|
-
[pj[cfg.SUBJECTS][x][cfg.SUBJECT_NAME] for x in pj[cfg.SUBJECTS]] + [cfg.NO_FOCAL_SUBJECT]
|
|
202
|
-
)
|
|
184
|
+
selected_subjects = sorted([pj[cfg.SUBJECTS][x][cfg.SUBJECT_NAME] for x in pj[cfg.SUBJECTS]] + [cfg.NO_FOCAL_SUBJECT])
|
|
203
185
|
|
|
204
186
|
# if no behavior selected select all
|
|
205
187
|
if not selected_behaviors:
|
|
206
188
|
selected_behaviors = sorted([pj[cfg.ETHOGRAM][x][cfg.BEHAVIOR_CODE] for x in pj[cfg.ETHOGRAM]])
|
|
207
189
|
|
|
208
190
|
# check if state events are paired
|
|
209
|
-
out = ""
|
|
191
|
+
out: str = ""
|
|
210
192
|
for obs_id in selected_observations:
|
|
211
|
-
r, msg = project_functions.check_state_events_obs(
|
|
212
|
-
obs_id, pj[cfg.ETHOGRAM], pj[cfg.OBSERVATIONS][obs_id], cfg.HHMMSS
|
|
213
|
-
)
|
|
193
|
+
r, msg = project_functions.check_state_events_obs(obs_id, pj[cfg.ETHOGRAM], pj[cfg.OBSERVATIONS][obs_id], cfg.HHMMSS)
|
|
214
194
|
if not r:
|
|
215
195
|
out += f"Observation: <strong>{obs_id}</strong><br>{msg}<br>"
|
|
216
196
|
if out:
|
|
@@ -220,24 +200,23 @@ def load_aggregated_events_in_db(
|
|
|
220
200
|
state_behaviors_codes = [
|
|
221
201
|
pj[cfg.ETHOGRAM][x][cfg.BEHAVIOR_CODE]
|
|
222
202
|
for x in pj[cfg.ETHOGRAM]
|
|
223
|
-
if cfg.STATE in pj[cfg.ETHOGRAM][x][cfg.TYPE].upper()
|
|
224
|
-
and pj[cfg.ETHOGRAM][x][cfg.BEHAVIOR_CODE] in selected_behaviors
|
|
203
|
+
if cfg.STATE in pj[cfg.ETHOGRAM][x][cfg.TYPE].upper() and pj[cfg.ETHOGRAM][x][cfg.BEHAVIOR_CODE] in selected_behaviors
|
|
225
204
|
]
|
|
226
205
|
|
|
227
206
|
# selected behaviors defined as point event
|
|
228
207
|
point_behaviors_codes = [
|
|
229
208
|
pj[cfg.ETHOGRAM][x][cfg.BEHAVIOR_CODE]
|
|
230
209
|
for x in pj[cfg.ETHOGRAM]
|
|
231
|
-
if cfg.POINT in pj[cfg.ETHOGRAM][x][cfg.TYPE].upper()
|
|
232
|
-
and pj[cfg.ETHOGRAM][x][cfg.BEHAVIOR_CODE] in selected_behaviors
|
|
210
|
+
if cfg.POINT in pj[cfg.ETHOGRAM][x][cfg.TYPE].upper() and pj[cfg.ETHOGRAM][x][cfg.BEHAVIOR_CODE] in selected_behaviors
|
|
233
211
|
]
|
|
234
212
|
|
|
235
213
|
db = sqlite3.connect(":memory:")
|
|
236
214
|
|
|
215
|
+
# only for debugging
|
|
237
216
|
"""
|
|
238
217
|
import os
|
|
239
|
-
os.system("rm /tmp/ramdisk/
|
|
240
|
-
db = sqlite3.connect("/tmp/ramdisk/
|
|
218
|
+
os.system("rm /tmp/ramdisk/aggregated_events.sqlite")
|
|
219
|
+
db = sqlite3.connect("/tmp/ramdisk/aggregated_events.sqlite", isolation_level=None)
|
|
241
220
|
"""
|
|
242
221
|
|
|
243
222
|
db.row_factory = sqlite3.Row
|
|
@@ -277,12 +256,10 @@ def load_aggregated_events_in_db(
|
|
|
277
256
|
)
|
|
278
257
|
|
|
279
258
|
for obs_id in selected_observations:
|
|
280
|
-
|
|
281
259
|
cursor1 = load_events_in_db(pj, selected_subjects, [obs_id], selected_behaviors)
|
|
282
260
|
|
|
283
261
|
for subject in selected_subjects:
|
|
284
262
|
for behavior in selected_behaviors:
|
|
285
|
-
|
|
286
263
|
cursor1.execute(
|
|
287
264
|
"SELECT DISTINCT modifiers FROM events WHERE subject=? AND code=? ORDER BY modifiers",
|
|
288
265
|
(
|
|
@@ -294,7 +271,6 @@ def load_aggregated_events_in_db(
|
|
|
294
271
|
rows_distinct_modifiers = list(x[0] for x in cursor1.fetchall())
|
|
295
272
|
|
|
296
273
|
for distinct_modifiers in rows_distinct_modifiers:
|
|
297
|
-
|
|
298
274
|
cursor1.execute(
|
|
299
275
|
(
|
|
300
276
|
"SELECT occurence, comment, image_index, image_path FROM events "
|
|
@@ -305,7 +281,6 @@ def load_aggregated_events_in_db(
|
|
|
305
281
|
rows = list(cursor1.fetchall())
|
|
306
282
|
|
|
307
283
|
for idx, row in enumerate(rows):
|
|
308
|
-
|
|
309
284
|
if behavior in point_behaviors_codes:
|
|
310
285
|
data = (
|
|
311
286
|
obs_id,
|
boris/dev.py
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import sys
|
|
2
|
+
import time
|
|
2
3
|
import pprint
|
|
4
|
+
import pandas as pd
|
|
5
|
+
|
|
3
6
|
from . import project_functions
|
|
4
7
|
from . import config as cfg
|
|
8
|
+
from . import utilities as util
|
|
5
9
|
|
|
6
10
|
|
|
7
11
|
def event_val(event, field, obs_type: str = cfg.MEDIA):
|
|
@@ -13,21 +17,118 @@ def event_val(event, field, obs_type: str = cfg.MEDIA):
|
|
|
13
17
|
|
|
14
18
|
_, _, pj, _ = project_functions.open_project_json(sys.argv[1])
|
|
15
19
|
|
|
16
|
-
pprint.pprint(list(pj[cfg.OBSERVATIONS].keys()))
|
|
20
|
+
# pprint.pprint(list(pj[cfg.OBSERVATIONS].keys()))
|
|
17
21
|
|
|
18
|
-
print()
|
|
22
|
+
# print()
|
|
19
23
|
|
|
24
|
+
"""
|
|
20
25
|
obs_id = "images NO TIME"
|
|
21
|
-
|
|
22
26
|
pprint.pprint(pj[cfg.OBSERVATIONS][obs_id])
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
state_events_list = util.state_behavior_codes(pj[cfg.ETHOGRAM])
|
|
30
|
+
|
|
31
|
+
df_def = {
|
|
32
|
+
"observation id": pd.Series(dtype="str"),
|
|
33
|
+
"observation type": pd.Series(dtype="str"),
|
|
34
|
+
"observation description": pd.Series(dtype="str"),
|
|
35
|
+
"subject": pd.Series(dtype="str"),
|
|
36
|
+
"behavior": pd.Series(dtype="str"),
|
|
37
|
+
"modifier": pd.Series(dtype="str"),
|
|
38
|
+
"start": pd.Series(dtype="float"),
|
|
39
|
+
"stop": pd.Series(dtype="float"),
|
|
40
|
+
"duration": pd.Series(dtype="float"),
|
|
41
|
+
}
|
|
42
|
+
df = pd.DataFrame(df_def)
|
|
43
|
+
l = []
|
|
44
|
+
# print(df.info)
|
|
45
|
+
|
|
46
|
+
for obs_id in pj[cfg.OBSERVATIONS]:
|
|
47
|
+
# print(obs_id)
|
|
48
|
+
obs_type = pj[cfg.OBSERVATIONS][obs_id][cfg.TYPE]
|
|
49
|
+
obs_descr = pj[cfg.OBSERVATIONS][obs_id][cfg.DESCRIPTION]
|
|
50
|
+
mem_idx = []
|
|
51
|
+
for idx, event in enumerate(pj[cfg.OBSERVATIONS][obs_id][cfg.EVENTS]):
|
|
52
|
+
if idx in mem_idx:
|
|
53
|
+
continue
|
|
54
|
+
start = event_val(event, cfg.TIME)
|
|
55
|
+
subject = event_val(event, cfg.SUBJECT)
|
|
56
|
+
behavior = event_val(event, cfg.BEHAVIOR_CODE)
|
|
57
|
+
modifier = event_val(event, cfg.MODIFIER)
|
|
58
|
+
if behavior in state_events_list:
|
|
59
|
+
stop = None
|
|
60
|
+
for idx2, event2 in enumerate(pj[cfg.OBSERVATIONS][obs_id][cfg.EVENTS][idx + 1 :], start=idx + 1):
|
|
61
|
+
subject2 = event_val(event2, cfg.SUBJECT)
|
|
62
|
+
behavior2 = event_val(event2, cfg.BEHAVIOR_CODE)
|
|
63
|
+
modifier2 = event_val(event2, cfg.MODIFIER)
|
|
64
|
+
if subject == subject2 and behavior == behavior2 and modifier == modifier2:
|
|
65
|
+
stop = event_val(event2, cfg.TIME)
|
|
66
|
+
mem_idx.append(idx2)
|
|
67
|
+
l.append([obs_id, obs_type, obs_descr, subject, behavior, modifier, start, stop, stop - start])
|
|
68
|
+
break
|
|
69
|
+
if stop is None:
|
|
70
|
+
print(obs_id, " not paired")
|
|
71
|
+
# print(pj[cfg.OBSERVATIONS][obs_id][cfg.EVENTS])
|
|
72
|
+
# print(f"{l=}")
|
|
73
|
+
# print(f"{mem_idx=}")
|
|
74
|
+
|
|
75
|
+
sys.exit()
|
|
76
|
+
else:
|
|
77
|
+
l.append([obs_id, obs_type, obs_descr, subject, behavior, modifier, start, start, 0])
|
|
78
|
+
|
|
79
|
+
# print(pd.DataFrame(l))
|
|
80
|
+
df = pd.concat(
|
|
81
|
+
[
|
|
82
|
+
df,
|
|
83
|
+
pd.DataFrame(
|
|
84
|
+
l,
|
|
85
|
+
columns=[
|
|
86
|
+
"observation id",
|
|
87
|
+
"observation type",
|
|
88
|
+
"observation description",
|
|
89
|
+
"subject",
|
|
90
|
+
"behavior",
|
|
91
|
+
"modifier",
|
|
92
|
+
"start",
|
|
93
|
+
"stop",
|
|
94
|
+
"duration",
|
|
95
|
+
],
|
|
96
|
+
),
|
|
97
|
+
]
|
|
98
|
+
)
|
|
99
|
+
del l
|
|
100
|
+
print("=" * 30)
|
|
101
|
+
print("describe")
|
|
102
|
+
print(df.describe())
|
|
103
|
+
print("=" * 30)
|
|
104
|
+
|
|
105
|
+
# print(f'{df["subject"].value_counts()=}')
|
|
106
|
+
# print(f'{df["subject"].nunique()=}')
|
|
107
|
+
|
|
108
|
+
pd.set_option("display.max_rows", None, "display.max_columns", None)
|
|
109
|
+
|
|
110
|
+
print("=" * 30)
|
|
111
|
+
print("mean")
|
|
112
|
+
r = df.groupby(["subject", "behavior"])["duration"].mean()
|
|
113
|
+
print(r)
|
|
114
|
+
print("=" * 30)
|
|
23
115
|
|
|
24
|
-
print(cfg.PJ_OBS_FIELDS[cfg.IMAGES][cfg.COMMENT])
|
|
25
116
|
|
|
26
|
-
|
|
117
|
+
r = df.groupby(["observation id", "subject", "behavior"])
|
|
118
|
+
print(r["start"])
|
|
27
119
|
|
|
28
|
-
print(f"{pj[cfg.OBSERVATIONS][obs_id][cfg.EVENTS][0][cfg.PJ_OBS_FIELDS[cfg.IMAGES][cfg.BEHAVIOR_CODE]]=}")
|
|
29
120
|
|
|
30
|
-
|
|
121
|
+
"""
|
|
122
|
+
# replace value (for selecting a time interval)
|
|
123
|
+
t1 = time.time()
|
|
124
|
+
df.loc[df["stop"] > 10, "stop"] = 10
|
|
125
|
+
print(time.time() - t1)
|
|
126
|
+
print(df)
|
|
127
|
+
"""
|
|
31
128
|
|
|
32
129
|
|
|
33
|
-
|
|
130
|
+
"""
|
|
131
|
+
t1 = 1
|
|
132
|
+
t2 = 2
|
|
133
|
+
print(df.query(f"`start` <= {t1} & `stop` >= {t2} & `duration` != 0"))
|
|
134
|
+
"""
|