# -*- coding: utf-8 -*- ''' Functions for randomly assigning participants as feedback participants or matched controls. Generates a .txt file in the subject_path (folder named with the subjectID), denoting whether a participant is feedback (first row containing 1) or control (first row containing 0) ''' # Imports import numpy as np import pandas as pd import os import shutil from settings import subject_path_init subject_path = subject_path_init() def copy_files(from_file, to_file): ''' Copies .csv files containing directories to images to the subject folder and renames the files. ''' shutil.copy(from_file+'_day_1.csv',to_file+'_day_1.csv') shutil.copy(from_file+'_day_2.csv',to_file+'_day_2.csv') shutil.copy(from_file+'_day_3.csv',to_file+'_day_3.csv') shutil.copy(from_file+'_day_4.csv',to_file+'_day_4.csv') shutil.copy(from_file+'_day_5.csv',to_file+'_day_5.csv') def copy_alpha(from_file,to_file): shutil.copy(from_file,to_file) def read_re_move_indices(subjects_dir, sub, feedback_from=None): '''
# -*- coding: utf-8 -*- ''' Functions for finding EEG and marker (trigger points for stimuli onset, from experimental script: experimentFunctions.py) streams, streaming and saving data, writing transcript files and changing system states for the neurofeedback system. ''' # Imports from pylsl import StreamInlet, resolve_stream, resolve_byprop import csv import time import numpy as np import sys import settings subject_path = settings.subject_path_init() class data_init: def __init__(self, fs, data_type, filename=None): ''' # Arguments fs: int EEG sampling frequency in Hz. data_type: string 'EEG' or 'marker' (trigger from experimental stimuli script, experimentFunctions.py) filename: string ''' self.fs, self.filename, self.data_type = fs, filename, data_type
#%% #%matplotlib qt import mne import os from mne_bids import write_raw_bids, BIDSPath,make_dataset_description import re import settings import event_test import pandas as pd #%% subjetc_file=settings.subject_path_init() os.chdir(settings.base_dir_init()) #%% raw_files=os.listdir(subjetc_file) raw_file_list=[] marker_lists=pd.read_csv('Behavioral/all_raw_marker.csv')['trigger'].to_list() event_ids=event_test.raw_marker_create(marker_lists) for raw_file in raw_files: if os.path.splitext(raw_file)[1]=='.vhdr': raw_file_list.append(raw_file) #%% for q in range(0,len(raw_file_list)): raw=mne.io.read_raw_brainvision(os.path.join(subjetc_file,raw_file_list[q]),preload=False) # if len(raw.info['ch_names'])>60: # raw.info['bads']=['BIP1','BIP2','BIP3','BIP4','BIP5','BIP6','BIP7','BIP8','BIP9','BIP10','BIP11','BIP12','BIP13','BIP14', # 'BIP15','BIP16','BIP17','BIP18','BIP19','BIP20','BIP21','BIP22','BIP23','BIP24'] # raw.drop_channels(ch_names=raw.info['bads']) raw.info['line_freq'] = 50