Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-dzaye committed May 31, 2022
1 parent 4fe44f3 commit d6e7fd0
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 281 deletions.
Binary file modified .DS_Store
Binary file not shown.
162 changes: 4 additions & 158 deletions berlin_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,161 +91,7 @@
],
}
layout = BIDSLayout(data_path)
files_off = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files_on = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
session=['EcogLfpMedOn01', 'EcogLfpMedOn02', 'EcogLfpMedOn03'],
return_type="filename",
)
files1_off = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='001',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files1_on = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='003',
session=['EcogLfpMedOn01', 'EcogLfpMedOn02', 'EcogLfpMedOn03'],
return_type="filename",
)
files3_off = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='003',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files3_on = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='003',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files4_off = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='004',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files4_on = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='004',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files5_off = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='005',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files5_on = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='005',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files6_off = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='006',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files6_on = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='006',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files7_off = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='007',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files7_on = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='007',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files8_off = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='008',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files8_on = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='008',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files9_off = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='009',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files9_on = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='009',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files10_off = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='010',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files10_on = layout.get(
extension="vhdr",
task="Rest",
acquisition="StimOff",
subject='010',
session=['EcogLfpMedOff01','EcogLfpMedOff02', 'EcogLfpMedOff03'],
return_type="filename",
)
files = layout.get(
extension="vhdr", task="Rest", acquisition="StimOff", return_type="filename",
)

75 changes: 40 additions & 35 deletions berlin_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from typing import Union
import runpy
from turtle import done

import pandas as pd

from bids import BIDSLayout
import mne_bids

import matplotlib.pyplot as plt
from src import pipeline


Expand All @@ -17,63 +19,66 @@ def main():
path_bids = project_constants["PATH_BIDS"]
m1_ids = project_constants["M1_IDS"]
new_ch_names_map = project_constants["NEW_CH_NAMES_MAP"]
files_off = project_constants["files_off"]
files_on = project_constants["files_on"]
files1_off = project_constants["files1_off"]
files1_on = project_constants["files1_on"]
files3_off = project_constants["files3_off"]
files3_on = project_constants["files3_on"]
files4_off = project_constants["files4_off"]
files4_on = project_constants["files4_on"]
files5_off = project_constants["files5_off"]
files5_on = project_constants["files5_on"]
files6_off = project_constants["files6_off"]
files6_on = project_constants["files6_on"]
files7_off = project_constants["files7_off"]
files7_on = project_constants["files7_on"]
files8_off = project_constants["files8_off"]
files8_on = project_constants["files8_on"]
files9_off = project_constants["files9_off"]
files9_on = project_constants["files9_on"]
files10_off = project_constants["files10_off"]
files10_on = project_constants["files10_on"]
files = project_constants["files"]
remove_subjects: Union[str, None] = ["002", "010", "011", "012"]
if remove_subjects:
for remove_subject in remove_subjects:
files = [file for file in files if remove_subject not in file]

files1_off = [f for f in files if "001" in f and "MedOff" in f]
files1_on = [f for f in files if "001" in f and "MedOn" in f]
files3_off = [f for f in files if "003" in f and "MedOff" in f]
files3_on = [f for f in files if "003" in f and "MedOn" in f]
files4_off = [f for f in files if "004" in f and "MedOff" in f]
files4_on = [f for f in files if "004" in f and "MedOn" in f]
files5_off = [f for f in files if "005" in f and "MedOff" in f]
files5_on = [f for f in files if "005" in f and "MedOn" in f]
files6_off = [f for f in files if "006" in f and "MedOff" in f]
files6_on = [f for f in files if "006" in f and "MedOn" in f]
files7_off = [f for f in files if "007" in f and "MedOff" in f]
files7_on = [f for f in files if "007" in f and "MedOn" in f]
files8_off = [f for f in files if "008" in f and "MedOff" in f]
files8_on = [f for f in files if "008" in f and "MedOn" in f]
files9_off = [f for f in files if "009" in f and "MedOff" in f]
files9_on = [f for f in files if "009" in f and "MedOn" in f]
files10_off = [f for f in files if "010" in f and "MedOff" in f]
files10_on = [f for f in files if "010" in f and "MedOn" in f]

# Define variables
burst_char_pd_all = []
M1_burst_dynamics_all = []
npow_list_all = []

# Process Files #
for path_run in files3_off:
burst_char_pd_all_on = []
M1_burst_dynamics_all_on = []
npow_list_all_on = []

# Process runs in one subject #
# def bursts_single_subject(runs):
for path_run in files:
entities = mne_bids.get_entities_from_fname(path_run)
sub = entities["subject"]
(
burst_char_pd,
M1_burst_dynamics,
npow,
) = pipeline.bursts_single_subject(
med = "On" if "MedOn" in entities["session"] else "Off"
run = entities["run"]
(burst_char_pd, M1_burst_dynamics, npow,) = pipeline.bursts_single_run(
path_run=path_run,
path_bids=path_bids,
sub=sub,
m1=m1_ids[sub],
new_ch_names=new_ch_names_map[sub],
)
burst_char_pd["Subject"] = sub
burst_char_pd["Medication"] = med
burst_char_pd["Run"] = run
M1_burst_dynamics["Subject"] = sub
npow["Subject"] = sub
burst_char_pd_all.append(burst_char_pd)
M1_burst_dynamics_all.append(M1_burst_dynamics)
npow_list_all.append(npow)

# burst_char_pd_df = pd.DataFrame(burst_char_pd_all)
# M1_burst_dynamics_df = pd.DataFrame(M1_burst_dynamics_all)
# npow_df = pd.DataFrame(npow_list_all)



return burst_char_pd_all, M1_burst_dynamics_all, npow_list_all


if __name__ == "__main__":
burst_char_pd_all, M1_burst_dynamics_all, npow_list_all = main()
print("done")
print(done)
21 changes: 11 additions & 10 deletions src/IO.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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
Expand All @@ -17,20 +18,20 @@ def read_BIDS_data(PATH_RUN, BIDS_PATH):
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,
)
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"]),)

int(raw_arr.info["line_freq"]),
)

Binary file modified src/__pycache__/pipeline.cpython-39.pyc
Binary file not shown.
Binary file modified src/__pycache__/preprocessing.cpython-39.pyc
Binary file not shown.
Loading

0 comments on commit d6e7fd0

Please sign in to comment.