コード例 #1
0
def parse_ieeg(data, i):
    #parsing data DataFrame to get iEEG information
    sub_ID = data.iloc[i].RID
    iEEG_filename = data.iloc[i].file
    ignore_electrodes = data.iloc[i].ignore_electrodes.split(",")
    start_time_usec = int(data.iloc[i].connectivity_start_time_seconds * 1e6)
    stop_time_usec = int(data.iloc[i].connectivity_end_time_seconds * 1e6)
    descriptor = data.iloc[i].descriptor
    #Output filename EEG
    ofpath_EEG_sub_ID = ospj(ofpath_EEG, f"sub-{sub_ID}")
    if not (os.path.isdir(ofpath_EEG_sub_ID)):
        os.mkdir(ofpath_EEG_sub_ID
                 )  #if the path doesn't exists, then make the directory
    outputfile_EEG = ospj(
        f"{ofpath_EEG_sub_ID}",
        f"sub-{sub_ID}_{iEEG_filename}_{start_time_usec}_{stop_time_usec}_EEG.csv"
    )
    print(f"\n\n\nID: {sub_ID}\nDescriptor: {descriptor}")

    if (os.path.exists(outputfile_EEG)):
        print(f"File already exists: {outputfile_EEG}")
    else:  #if file already exists, don't run below
        get_iEEG_data(username, password, iEEG_filename, start_time_usec,
                      stop_time_usec, ignore_electrodes, outputfile_EEG)
コード例 #2
0
password = sys.argv[2]

#%% Load Study Meta Data
data = pd.read_excel(ifname_EEG_times)

#%% Get iEEG data
for i in range(len(data)):
    #parsing data DataFrame to get iEEG information
    sub_ID = data.iloc[i].RID
    iEEG_filename = data.iloc[i].file
    ignore_electrodes = data.iloc[i].ignore_electrodes.split(",")
    start_time_usec = int(data.iloc[i].connectivity_start_time_seconds * 1e6)
    stop_time_usec = int(data.iloc[i].connectivity_end_time_seconds * 1e6)
    descriptor = data.iloc[i].descriptor
    #Output filename EEG
    ofpath_EEG_sub_ID = ospj(ofpath_EEG, "sub-{0}".format(sub_ID))
    if not (os.path.isdir(ofpath_EEG_sub_ID)):
        os.mkdir(ofpath_EEG_sub_ID
                 )  #if the path doesn't exists, then make the directory
    outputfile_EEG = "{0}/sub-{1}_{2}_{3}_{4}_EEG.pickle".format(
        ofpath_EEG_sub_ID, sub_ID, iEEG_filename, start_time_usec,
        stop_time_usec)
    print("\n\n\nID: {0}\nDescriptor: {1}".format(sub_ID, descriptor))
    if (os.path.exists(outputfile_EEG)):
        print("File already exists: {0}".format(outputfile_EEG))
    else:  #if file already exists, don't run below
        get_iEEG_data(username, password, iEEG_filename, start_time_usec,
                      stop_time_usec, ignore_electrodes, outputfile_EEG)

#%%
コード例 #3
0
ファイル: get_eeg.py プロジェクト: ianzyong/network-states
            if not os.path.exists(patient_directory):
                os.makedirs(eeg_directory)
            outputfile = os.path.join(
                eeg_directory,
                "sub-{}_{}_{}_{}_EEG.pickle".format(rid, iEEG_filename,
                                                    start_time_usec,
                                                    stop_time_usec))

            # download data if the file does not already exist
            if not os.path.isfile(outputfile):

                # start timer
                start = time.time()

                get_iEEG_data(username, password, iEEG_filename,
                              start_time_usec, stop_time_usec,
                              removed_channels, outputfile)

                # stop timer
                end = time.time()

                # report time elapsed
                print("Time elapsed = {}".format(
                    convertSeconds(int(end - start))))

                process_count = process_count + 1

            else:
                print("{} exists, skipping...".format(outputfile))

        total_end = time.time()
コード例 #4
0
            outputfile = os.path.join(eeg_directory,"sub-{}_{}_{}_{}_EEG.pickle".format(rid,iEEG_filename,start_time_usec,stop_time_usec))
            
            bids_root = os.path.join(parent_directory,'bids_output')            
            
            edf_filename = os.path.join(bids_root,"sub-{}".format(rid),"ses-presurgery","ieeg","sub-{}.edf".format(interval_name))

            if overwrite_files or not os.path.isfile(edf_filename):

                # download data if the file does not already exist
                #if not os.path.isfile(outputfile):

                # start timer
                start = time.time()
                    
                try:
                    true_ignore_electrodes = get_iEEG_data(username, password, iEEG_filename, start_time_usec, stop_time_usec, removed_channels, outputfile, get_all_channels = True, redownload = redownload)
                except KeyError:
                    print("Encountered KeyError: ignore_electrodes are probably named differently on ieeg.org. Skipping...")
                    continue
                except KeyboardInterrupt:
                    print('Interrupted')
                    try:
                        sys.exit()
                    except SystemExit:
                        os._exit()

                # stop timer
                end = time.time()

                # report time elapsed
                print("Time elapsed = {}".format(convertSeconds(int(end - start))))