Skip to content

Commit e20ebd9

Browse files
adarshpPaulo Soares
and
Paulo Soares
authored
Updating data processing code to add demographic data, post game survey, playername-to-station mapping (#572)
This PR: - Adds code to populate the DB with demographic data, postgame survey data, and a playername-to-station mapping. - Adds *.egg-info to .gitignore, removes accidentally added .egg-info files from previous commit. - Updates the inspect file creation script to point to the new location of the sqlite db - Adds code for sentence labeling --------- Co-authored-by: Paulo Soares <paulosoares@SBS-7186.local>
1 parent a03d49e commit e20ebd9

File tree

17 files changed

+708
-234
lines changed

17 files changed

+708
-234
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,5 @@ HSR*
109109

110110
# Texpad
111111
*.texpadtmp/
112+
113+
*.egg-info

human_experiments/datasette_interface/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ The following `make` commands can be used to perform different operations on the
1414

1515
# Populating the ToMCAT database
1616

17-
The tomcat dataset is in a Postgres cluster that lives in `/space/paulosoares/postgres`. A series of `make` commands can be used to perform different operations on this dataset. The commands run by default in `development` mode, which uses an sqlite database created under `/space/USER/tomcat/.dev`. To modify the Postgres database, the commands need to be executed in `production` mode, which can be done by adding the following before each command:
17+
The tomcat dataset is in a Postgres cluster that lives in `/space/paulosoares/postgres`. A series of `make` commands can be used to perform different operations on this dataset. The commands run by default in `development` mode, which uses an sqlite database created under `/space/$USER/tomcat/.dev`. To modify the Postgres database, the commands need to be executed in `production` mode, which can be done by adding the following before each command:
1818
```
1919
working_env=production db_pass=<user_postgres_pass>
2020
```
21-
Your user must have permission to modify the Postgres database in production mode.
21+
Your user must have permission to modify the Postgres database in production mode.
2222

2323
## Commands
2424
1. **clear_db**: [WARNING] drops the tables in the ToMCAT database. It must only be called if one really wants a fresh copy.
2525
2. **create_tables**: creates new tables and indices. If a table already exists, it won't be changed.
2626
3. **update_raw**: Adds new raw data to the relevant tables. This can be called to update the database with new experiment data. It will skip experiments already processed.
2727
4. **sync_raw**: Filters and synchronizes fNIRS and EEG signals with a main clock with frequency 200Hz that starts 1 minute before the rest_state task and ends 1 minute after end of the last minecraft trial. Synchronized signals are saved to the `fnirs_sync` and `eeg_sync` tables.
28-
5. **to_sqlite**: Copies the Postgres database to an SQLite database for publication in the datasette interface. It runs in production mode automatically to make sure to read from the Postgres database. IThe environment variable `TBS` can be used in conjunction with this command to specify a subset of tables one wants to copy, otherwise, all tables will be copied. Be patient and run this in a tmux session as this process can take several days depending on the size of the tables.
28+
5. **to_sqlite**: Copies the Postgres database to an SQLite database for publication in the datasette interface. It runs in production mode automatically to make sure to read from the Postgres database. The environment variable `TBS` can be used in conjunction with this command to specify a subset of tables one wants to copy, otherwise, all tables will be copied. Be patient and run this in a tmux session as this process can take several days depending on the size of the tables.
2929

3030
# Miscellaneous
3131
The following `make` commands can be used to perform different operations.
3232

3333
1. **update_inspect_file**: Updates the `inspect-data.json` with the newest sqlite ToMCAT database.
3434
2. **generate_diagram**: Generates the database diagram from the newest sqlite ToMCAT database.
35-
3. **screenshots_to_server**: Copies screenshot images to the web server for access though a public URL.
35+
3. **screenshots_to_server**: Copies screenshot images to the web server for access though a public URL.

human_experiments/datasette_interface/bin/create_tables.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from datasette_interface.database.entity.base.group_session import GroupSession # noqa f401
77
from datasette_interface.database.entity.base.modality import Modality # noqa f401
88
from datasette_interface.database.entity.base.participant import Participant # noqa f401
9+
from datasette_interface.database.entity.base.post_game_survey import PostGameSurvey # noqa f401
910
from datasette_interface.database.entity.base.station import Station # noqa f401
1011
from datasette_interface.database.entity.base.task import Task # noqa f401
1112
from datasette_interface.database.entity.derived.eeg_sync import EEGSync # noqa f401
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22

33
# Update inspect-data.json
4-
time datasette inspect /space/paulosoares/tomcat/tomcat.db > inspect-data.json
4+
time datasette inspect /space/$USER/tomcat/.dev/tomcat.db > inspect-data.json

human_experiments/datasette_interface/datasette_interface.egg-info/PKG-INFO

Lines changed: 0 additions & 10 deletions
This file was deleted.

human_experiments/datasette_interface/datasette_interface.egg-info/SOURCES.txt

Lines changed: 0 additions & 75 deletions
This file was deleted.

human_experiments/datasette_interface/datasette_interface.egg-info/dependency_links.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

human_experiments/datasette_interface/datasette_interface.egg-info/top_level.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

human_experiments/datasette_interface/datasette_interface/common/config.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,28 @@ class Settings(BaseSettings):
2828
"/tomcat/data/raw/LangLab/experiments/study_3_pilot/"
2929
"station_to_eeg_amp_mapping.csv"
3030
)
31+
station_to_minecraft_playername_mapping_path: str = (
32+
"/tomcat/data/raw/LangLab/experiments/study_3_pilot/"
33+
"station_to_minecraft_playername_mapping.csv"
34+
)
35+
36+
self_report_data_path: str = (
37+
"/tomcat/data/raw/LangLab/experiments/study_3_pilot/"
38+
"ToMCATSelfReport_DATA_2023-06-11_2358.tsv"
39+
)
40+
self_report_data_dictionary_path: str = (
41+
"/tomcat/data/raw/LangLab/experiments/study_3_pilot/"
42+
"ToMCATSelfReport_DataDictionary_2023-08-08.tsv"
43+
)
44+
45+
post_game_survey_data_path: str = (
46+
"/tomcat/data/raw/LangLab/experiments/study_3_pilot/"
47+
"ToMCATPostGameSurvey_DATA_2024-07-16_2050.csv"
48+
)
49+
post_game_survey_data_dictionary_path: str = (
50+
"/tomcat/data/raw/LangLab/experiments/study_3_pilot/"
51+
"ToMCATPostGameSurvey_DataDictionary_2024-07-17.csv"
52+
)
3153

3254
@classmethod
3355
@field_validator(

human_experiments/datasette_interface/datasette_interface/database/entity/base/group_session.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ class GroupSession(Base):
99

1010
id: Mapped[str] = mapped_column(Text, primary_key=True)
1111
advisor: Mapped[str] = mapped_column(Text)
12+
lion_minecraft_playername: Mapped[str] = mapped_column(Text, nullable=True)
13+
tiger_minecraft_playername: Mapped[str] = mapped_column(Text, nullable=True)
14+
leopard_minecraft_playername: Mapped[str] = mapped_column(Text, nullable=True)

human_experiments/datasette_interface/datasette_interface/database/entity/base/participant.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from sqlalchemy import Integer
1+
from typing import Optional
2+
from sqlalchemy import Integer, Text, Boolean
23
from sqlalchemy.orm import Mapped, mapped_column
34

45
from datasette_interface.database.config import Base
@@ -8,3 +9,31 @@ class Participant(Base):
89
__tablename__ = "participant"
910

1011
id: Mapped[int] = mapped_column(Integer, primary_key=True)
12+
age: Mapped[Optional[int]] = mapped_column(Integer)
13+
sex: Mapped[Optional[str]] = mapped_column(Text)
14+
hisp: Mapped[Optional[bool]] = mapped_column(Boolean)
15+
race: Mapped[Optional[str]] = mapped_column(Text)
16+
income: Mapped[Optional[str]] = mapped_column(Text)
17+
edu: Mapped[Optional[str]] = mapped_column(Text)
18+
exp: Mapped[Optional[str]] = mapped_column(Text)
19+
exp_mc: Mapped[Optional[str]] = mapped_column(Text)
20+
handedness: Mapped[Optional[str]] = mapped_column(Text)
21+
trackpad_preference: Mapped[Optional[str]] = mapped_column(Text)
22+
sph_label: Mapped[Optional[str]] = mapped_column(Text)
23+
shl_impairments: Mapped[Optional[str]] = mapped_column(Text)
24+
shl_impairments_specify: Mapped[Optional[str]] = mapped_column(Text)
25+
shl_impairments_agediagnosis: Mapped[Optional[str]] = mapped_column(Text)
26+
shl_impairments_therapy: Mapped[Optional[str]] = mapped_column(Text)
27+
first_language: Mapped[Optional[str]] = mapped_column(Text)
28+
languages_spoken: Mapped[Optional[str]] = mapped_column(Text)
29+
language_age_learned: Mapped[Optional[str]] = mapped_column(Text)
30+
countries_live_one_year: Mapped[Optional[str]] = mapped_column(Text)
31+
major_schooling_country: Mapped[Optional[str]] = mapped_column(Text)
32+
health_label: Mapped[Optional[str]] = mapped_column(Text)
33+
health_concussion: Mapped[Optional[str]] = mapped_column(Text)
34+
health_seizure: Mapped[Optional[str]] = mapped_column(Text)
35+
health_trauma: Mapped[Optional[str]] = mapped_column(Text)
36+
health_other_trauma_specify: Mapped[Optional[str]] = mapped_column(Text)
37+
health_medications: Mapped[Optional[str]] = mapped_column(Text)
38+
health_vision: Mapped[Optional[str]] = mapped_column(Text)
39+
health_vision_specify: Mapped[Optional[str]] = mapped_column(Text)
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
from typing import Optional
2+
from sqlalchemy import Integer, Text, Boolean, ForeignKey
3+
from sqlalchemy.orm import Mapped, mapped_column
4+
5+
from datasette_interface.database.config import Base
6+
from datasette_interface.database.entity.base.participant import Participant
7+
8+
9+
class PostGameSurvey(Base):
10+
__tablename__ = "post_game_survey"
11+
12+
participant_id: Mapped[int] = mapped_column(
13+
"participant", Integer, ForeignKey(Participant.id), primary_key=True
14+
)
15+
16+
agent_calm: Mapped[Optional[str]] = mapped_column(Text)
17+
agent_anxious: Mapped[Optional[str]] = mapped_column(Text)
18+
agent_excited: Mapped[Optional[str]] = mapped_column(Text)
19+
agent_sad: Mapped[Optional[str]] = mapped_column(Text)
20+
agent_guilty: Mapped[Optional[str]] = mapped_column(Text)
21+
agent_angry: Mapped[Optional[str]] = mapped_column(Text)
22+
agent_happy: Mapped[Optional[str]] = mapped_column(Text)
23+
agent_lonely: Mapped[Optional[str]] = mapped_column(Text)
24+
agent_proud: Mapped[Optional[str]] = mapped_column(Text)
25+
agent_friendly: Mapped[Optional[str]] = mapped_column(Text)
26+
27+
game_calm: Mapped[Optional[str]] = mapped_column(Text)
28+
game_anxious: Mapped[Optional[str]] = mapped_column(Text)
29+
game_excited: Mapped[Optional[str]] = mapped_column(Text)
30+
game_sad: Mapped[Optional[str]] = mapped_column(Text)
31+
game_guilty: Mapped[Optional[str]] = mapped_column(Text)
32+
game_angry: Mapped[Optional[str]] = mapped_column(Text)
33+
game_happy: Mapped[Optional[str]] = mapped_column(Text)
34+
game_lonely: Mapped[Optional[str]] = mapped_column(Text)
35+
game_proud: Mapped[Optional[str]] = mapped_column(Text)
36+
game_friendly: Mapped[Optional[str]] = mapped_column(Text)
37+
38+
agent_intel: Mapped[Optional[int]] = mapped_column(Integer)
39+
agent_care: Mapped[Optional[int]] = mapped_column(Integer)
40+
agent_honest: Mapped[Optional[int]] = mapped_column(Integer)
41+
agent_expert: Mapped[Optional[int]] = mapped_column(Integer)
42+
agent_concern: Mapped[Optional[int]] = mapped_column(Integer)
43+
agent_trust: Mapped[Optional[int]] = mapped_column(Integer)
44+
agent_comp: Mapped[Optional[int]] = mapped_column(Integer)
45+
agent_insens: Mapped[Optional[int]] = mapped_column(Integer)
46+
agent_honor: Mapped[Optional[int]] = mapped_column(Integer)
47+
agent_bright: Mapped[Optional[int]] = mapped_column(Integer)
48+
agent_understand: Mapped[Optional[int]] = mapped_column(Integer)
49+
agent_phoney: Mapped[Optional[int]] = mapped_column(Integer)
50+
51+
agent_well: Mapped[Optional[str]] = mapped_column(Text)
52+
agent_smooth: Mapped[Optional[str]] = mapped_column(Text)
53+
agent_acc: Mapped[Optional[str]] = mapped_column(Text)
54+
agent_like: Mapped[Optional[str]] = mapped_column(Text)
55+
agent_enjoy: Mapped[Optional[str]] = mapped_column(Text)
56+
agent_awk: Mapped[Optional[str]] = mapped_column(Text)
57+
agent_place: Mapped[Optional[str]] = mapped_column(Text)
58+
agent_play: Mapped[Optional[str]] = mapped_column(Text)
59+
agent_perform: Mapped[Optional[str]] = mapped_column(Text)
60+
61+
team_calm: Mapped[Optional[str]] = mapped_column(Text)
62+
team_anxious: Mapped[Optional[str]] = mapped_column(Text)
63+
team_excited: Mapped[Optional[str]] = mapped_column(Text)
64+
team_sad: Mapped[Optional[str]] = mapped_column(Text)
65+
team_guilty: Mapped[Optional[str]] = mapped_column(Text)
66+
team_angry: Mapped[Optional[str]] = mapped_column(Text)
67+
team_happy: Mapped[Optional[str]] = mapped_column(Text)
68+
team_lonely: Mapped[Optional[str]] = mapped_column(Text)
69+
team_proud: Mapped[Optional[str]] = mapped_column(Text)
70+
team_friendly: Mapped[Optional[str]] = mapped_column(Text)
71+
72+
team_intel: Mapped[Optional[int]] = mapped_column(Integer)
73+
team_care: Mapped[Optional[int]] = mapped_column(Integer)
74+
team_honest: Mapped[Optional[int]] = mapped_column(Integer)
75+
team_expert: Mapped[Optional[int]] = mapped_column(Integer)
76+
team_concern: Mapped[Optional[int]] = mapped_column(Integer)
77+
team_trust: Mapped[Optional[int]] = mapped_column(Integer)
78+
team_comp: Mapped[Optional[int]] = mapped_column(Integer)
79+
team_insens: Mapped[Optional[int]] = mapped_column(Integer)
80+
team_honor: Mapped[Optional[int]] = mapped_column(Integer)
81+
team_bright: Mapped[Optional[int]] = mapped_column(Integer)
82+
team_understand: Mapped[Optional[int]] = mapped_column(Integer)
83+
team_phoney: Mapped[Optional[int]] = mapped_column(Integer)
84+
85+
team_wrong: Mapped[Optional[str]] = mapped_column(Text) # typo..
86+
team_forget: Mapped[Optional[str]] = mapped_column(Text)
87+
team_minimize: Mapped[Optional[str]] = mapped_column(Text)
88+
team_insult: Mapped[Optional[str]] = mapped_column(Text)
89+
team_irrat: Mapped[Optional[str]] = mapped_column(Text)
90+
team_crit: Mapped[Optional[str]] = mapped_column(Text)
91+
team_fault: Mapped[Optional[str]] = mapped_column(Text)
92+
team_ignore: Mapped[Optional[str]] = mapped_column(Text)
93+
team_impt: Mapped[Optional[str]] = mapped_column(Text)
94+
team_weak: Mapped[Optional[str]] = mapped_column(Text)
95+
96+
team_along: Mapped[Optional[str]] = mapped_column(Text)
97+
team_smooth: Mapped[Optional[str]] = mapped_column(Text)
98+
team_accept: Mapped[Optional[str]] = mapped_column(Text)
99+
team_like: Mapped[Optional[str]] = mapped_column(Text)
100+
team_enjoy: Mapped[Optional[str]] = mapped_column(Text)
101+
team_awk: Mapped[Optional[str]] = mapped_column(Text)
102+
team_place: Mapped[Optional[str]] = mapped_column(Text)
103+
team_likeme: Mapped[Optional[str]] = mapped_column(Text)
104+
team_genuine: Mapped[Optional[str]] = mapped_column(Text)
105+
team_part: Mapped[Optional[str]] = mapped_column(Text)
106+
team_listen: Mapped[Optional[str]] = mapped_column(Text)
107+
team_ilike: Mapped[Optional[str]] = mapped_column(Text)
108+
team_interact: Mapped[Optional[str]] = mapped_column(Text)
109+
team_itrust: Mapped[Optional[str]] = mapped_column(Text)
110+
team_fit: Mapped[Optional[str]] = mapped_column(Text)
111+
team_cohesion: Mapped[Optional[str]] = mapped_column(Text)
112+
team_work: Mapped[Optional[str]] = mapped_column(Text)
113+
team_knit: Mapped[Optional[str]] = mapped_column(Text)
114+
team_like_mem: Mapped[Optional[str]] = mapped_column(Text)
115+
team_work_well: Mapped[Optional[str]] = mapped_column(Text)
116+
team_decision: Mapped[Optional[str]] = mapped_column(Text)
117+
team_express: Mapped[Optional[str]] = mapped_column(Text)
118+
team_organize: Mapped[Optional[str]] = mapped_column(Text)
119+
team_accomplish: Mapped[Optional[str]] = mapped_column(Text)
120+
team_approp: Mapped[Optional[str]] = mapped_column(Text)
121+
team_alt: Mapped[Optional[str]] = mapped_column(Text)
122+
team_influ: Mapped[Optional[str]] = mapped_column(Text)
123+
team_contrib: Mapped[Optional[str]] = mapped_column(Text)
124+
125+
agent_emot1: Mapped[Optional[str]] = mapped_column(Text)
126+
agent_emot2: Mapped[Optional[str]] = mapped_column(Text)
127+
agent_emot3: Mapped[Optional[str]] = mapped_column(Text)
128+
agent_emot4: Mapped[Optional[str]] = mapped_column(Text)
129+
agent_emot5: Mapped[Optional[str]] = mapped_column(Text)
130+
agent_emot6: Mapped[Optional[str]] = mapped_column(Text)
131+
agent_emot7: Mapped[Optional[str]] = mapped_column(Text)
132+
agent_emot8: Mapped[Optional[str]] = mapped_column(Text)
133+
agent_emot9: Mapped[Optional[str]] = mapped_column(Text)
134+
agent_emot10: Mapped[Optional[str]] = mapped_column(Text)
135+
136+
know_team_members: Mapped[Optional[bool]] = mapped_column(Boolean)
137+
know_person_at_cheetah: Mapped[Optional[str]] = mapped_column(Text)
138+
know_person_at_lion: Mapped[Optional[str]] = mapped_column(Text)
139+
know_person_at_tiger: Mapped[Optional[str]] = mapped_column(Text)
140+
know_person_at_leopard: Mapped[Optional[str]] = mapped_column(Text)

0 commit comments

Comments
 (0)