Skip to content

Commit

Permalink
ignore invalid minecraft mission (#533)
Browse files Browse the repository at this point in the history
* ignore invalid minecraft mission

* Update readme
  • Loading branch information
eduongAZ authored Aug 22, 2023
1 parent f9da2f0 commit 1f9cf74
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 5 deletions.
71 changes: 70 additions & 1 deletion human_experiments/synchronize_signal_task/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,72 @@
# Synchronize signal task

This project is for synchronizing EEG and fNIRS signals with task data.
This project is for synchronizing EEG, EKG, GSR, and fNIRS signals with task data.

## Install dependencies

This project requires Python 3.11.

### Install dependencies with Conda

Ensure that Conda is already installed, then run the following command to install dependencies into a new conda environment

```
conda conda create -n tomcat-synchronize python=3.11
conda activate tomcat-synchronize
pip install -r requirements.txt
```

### Install dependcies with Pip

You can install the packages using Pip3 in a base environment or an environment created for this project, then run the follow command to install dependencies

```
pip3 install -r requirements.txt
```

### Install dependencies manually

If you want to set up environment and install dependencies manually, then you need the following packages

```
numpy
scipy
pandas
scikit-learn
mne
tqdm
python-dotenv
python-dateutil
```

## Set up project

Ensure that you downloaded the ToMCAT raw data [here](tomcat.ivilab.org)

Set the following variables in the `config.py` file:

- `DB_PATH` is the full path to the ToMCAT data you downloaded.
- `EEG_FILTERED_PATH` is the full path to the ToMCAT filtered EEG data.
- `FNIRS_FILTERED_PATH` is the full path to the ToMCAT filtered fNIRS data.
- `NUM_PROCESSES` number of processes you can use to run the data processing in parallel.
- `OUTPUT_DIR` the full path to where the output will be located.

## Run project

After setting up the `config.py` file, you can launch the program (make sure that you are in the python environment with required dependencies installed):

### Synchronize fNIRS with each task at 10 Hz

```
python3 process_nirs_10hz.py
```

### Synchronize EEG-EKG-GSR with each task at 500 Hz

```
python3 process_eeg_500hz.py
```

## Output

The program will output synchronized data to the path specified in `output_dir` in `config.py`.
9 changes: 8 additions & 1 deletion human_experiments/synchronize_signal_task/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
EEG_FILTERED_PATH = f"/space/{USER}/eeg_filtered"
FNIRS_FILTERED_PATH = f"/space/{USER}/fnirs_filtered"
NUM_PROCESSES = 40
OUTPUT_DIR = "/tomcat/data/derived/drafts/release_2023_08_19_17"
OUTPUT_DIR = "/tomcat/data/derived/drafts/release_2023_08_20_19"

MINECRAFT_MISSION_BLACKLIST = [
"560d4c45-dc45-4e19-bdb3-e4e15021728a",
"a48f475f-40b0-46b9-8284-0db267dddb67",
"171a8713-a554-4d8e-a4b1-3ec1b728d0a2",
"9cde1985-1179-4aac-8b67-1fc60ed65243",
]

EXPERIMENT_SESSIONS = [
"exp_2022_09_30_10", "exp_2022_11_01_10", "exp_2022_12_02_15", "exp_2023_02_21_14",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
synchronized_task_signals = synchronize_task_signal_all(task_synchronization_info)

output_dir = os.path.join(OUTPUT_DIR, f"eeg_{desired_freq}hz")
write_csv_all(synchronized_task_signals, OUTPUT_DIR, NUM_PROCESSES)
write_csv_all(synchronized_task_signals, output_dir, NUM_PROCESSES)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import sqlite3
from config import MINECRAFT_MISSION_BLACKLIST

import pandas as pd

Expand All @@ -16,11 +17,22 @@ def _get_testbed_messages(db_path: str, experiment: str, mission: str) -> pd.Dat
if mission_id is None:
return None

mission_id_result = mission_id.fetchone()
mission_id_result = mission_id.fetchall()
if mission_id_result is None or len(mission_id_result) == 0:
return None

mission_id = mission_id_result[0]
mission_found = False
for mission_id_considering in mission_id_result:
if mission_id_considering[0] not in MINECRAFT_MISSION_BLACKLIST:
mission_id = mission_id_considering[0]
mission_found = True
break

if not mission_found:
return None

if len(mission_id) != 36:
raise ValueError("Incorrect mission ID length")

query = f"""
SELECT *
Expand Down

0 comments on commit 1f9cf74

Please sign in to comment.