-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c4783c
commit a0f3638
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import os | ||
|
||
import matplotlib.pyplot as plt | ||
import neurokit2 as nk | ||
import numpy as np | ||
import pandas as pd | ||
|
||
# Variables ======================================================= | ||
# Change the path to your local data folder. | ||
# The data can be downloaded from OpenNeuro (TODO). | ||
path = "C:/Users/domma/Box/Data/PrimalsInteroception/pilots/physio/" | ||
|
||
|
||
# Convenience functions ============================================ | ||
def load_data(path, task="HBC"): | ||
files = os.listdir(path) | ||
df, info = nk.read_xdf(filename=path + [file for file in files if task in file][0]) | ||
|
||
# # Test | ||
# df1 = df.iloc[0:3000] | ||
# df2 = info["data"][0].iloc[0:300] | ||
# plt.plot(df1.index, df1["TP9"]) | ||
# plt.plot(df2.index, df2["TP9"]) | ||
|
||
# df3 = info["data"][4].iloc[0:1000] | ||
# plt.plot(df1.index, df1["ECG"]) | ||
# plt.plot(df3.index, df3["ECGBIT1"]) | ||
|
||
df = df.reset_index() | ||
|
||
df = df.drop( | ||
columns=[ | ||
"Right AUX", | ||
"X", | ||
"Y", | ||
"Z", | ||
"RED", | ||
"GYRO_X", | ||
"GYRO_Y", | ||
"GYRO_Z", | ||
"nSeq", | ||
"index", | ||
] | ||
) | ||
|
||
df = df.rename( | ||
columns={ | ||
"PPG": "PPG_Muse", | ||
"RESPBIT0": "RSP", | ||
"ECGBIT1": "ECG", | ||
"PULSEOXI2": "PPG", | ||
"LUX3": "PHOTO", | ||
} | ||
) | ||
|
||
return df, info | ||
|
||
|
||
# Load Data ======================================================= | ||
participants = os.listdir(path) | ||
|
||
for participant in participants: | ||
# participant = "sub-pilot2" | ||
path_sub = path + participant + "/ses-S001/beh/" | ||
|
||
df, info = load_data(path=path_sub, task="HBC") | ||
|
||
nk.signal_plot(df, subplots=True) |