-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIO.py
37 lines (32 loc) · 875 Bytes
/
IO.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import mne_bids
import numpy as np
def read_BIDS_data(PATH_RUN, BIDS_PATH):
"""Given a run path and bids data path, read the respective data
Parameters
----------
PATH_RUN : string
BIDS_PATH : string
Returns
-------
raw_arr : mne.io.RawArray
raw_arr_data : np.ndarray
fs : int
line_noise : int
"""
entities = mne_bids.get_entities_from_fname(PATH_RUN)
bids_path = mne_bids.BIDSPath(
subject=entities["subject"],
session=entities["session"],
task=entities["task"],
run=entities["run"],
acquisition=entities["acquisition"],
datatype="ieeg",
root=BIDS_PATH,
)
raw_arr = mne_bids.read_raw_bids(bids_path)
return (
raw_arr,
raw_arr.get_data(),
int(np.ceil(raw_arr.info["sfreq"])),
int(raw_arr.info["line_freq"]),
)