Distinguishing between response conflict and error expectancy in inhibitory error processing: the role of the presupplementary motor cortex.
Paper
Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Jupyter notebook · 1,795 lines · 102 KB · no license
- # %%
- import pandas as pd
- import numpy as np
- import re
- import os
- import math
- import scipy.signal
- from sklearn import metrics
- import statsmodels.api as sm
- import sklearn.preprocessing
- import statsmodels.api as sm
- import statsmodels.formula.api as smf
- import scipy.io
- import nibabel as nib
- import matplotlib.pyplot as plt
- from scipy.interpolate import interp1d
- # %% [markdown]
- # # General directory operations
- # %%
- def create_list_directories(main_directory):
- #input: directory to the folder with log files
- #output: list of directories with log files
- return([main_directory + x for x in os.listdir(main_directory) if x[-3:]!='mat'])
- # %%
- def create_dict_values(main_directory):
- #input: directory to the folder with log files
- #output: dictionary with directory of a single log file as keys and basic SST statistics
- return({one_directory:collect_all_data(create_df_single_directory(one_directory)) for one_directory in create_list_directories(main_directory)})
- # %%
- def create_dict_values_trial_wise(main_directory):
- #input: directory to the folder with log files
- #output: dictionary with directory of a single log file as keys and data frames
- return({one_directory:create_df_single_directory(one_directory) for one_directory in create_list_directories(main_directory)})
- # %%
- def create_df_single_directory(given_directory):
- # Input: path to a single log file
- # Output: data frame with data from log files
- one_file = open(given_directory) # Open the log file
- wholesome_data = [] # Initialize list to store data rows
- for num, i in enumerate(one_file.readlines()):
- # Skip lines that contain metadata or are empty
- if i.split('\t')[0] != 'Nothing' and i.split('\t')[0] != 'Event Type' and i.split('\t')[0] != 'Picture' and i.split('\t')[0] != '\n':
- if num == 3:
- name_column = i.split('\t') # Line 4 contains column headers
- elif num > 4:
- data_row = i.split('\t') # Starting from line 5, get data rows
- # Pad missing values with 'NaN' to match header length
- if len(data_row) < len(name_column):
- zeros_row = np.zeros(len(name_column) - len(data_row))
- for j in zeros_row:
- data_row.append('NaN')
- wholesome_data.append(data_row) # Add cleaned row to list
- df = pd.DataFrame(wholesome_data) # Create DataFrame from data
- df.columns = name_column # Assign column names
- return df # Return the constructed DataFrame
- # %% [markdown]
- # # Necessary functions to compute general behavioral measures in performance
- # %%
- def num_trials(df):
- #input: data frame with logs data
- #output: the number of all trials
- return(num_go_trials(df) + num_stop_trials(df))
- # %%
- def num_go_trials(df):
- #input: data frame with logs data
- #output: the number of go trials
- return(len(select_go_trials(df)))
- # %%
- def select_go_trials(df):
- #input: data frame with logs data
- #output: list of all go trials with indices
- return(select_go_correct_trials(df)+select_go_incorrect_trials(df))
- # %%
- def num_stop_trials(df):
- #input: data frame with logs data
- #output: list of all stop trials with indices
- return(len(select_stop_trials(df)))
- # %%
- def select_go_correct_trials(df):
- #input: data frame with logs data
- #output: list of all go trials performed correclty with indices
- return([(num, one_stim_type) for num, one_stim_type in enumerate(df['Stim Type']) if one_stim_type=='hit'])
- # %%
- def select_go_incorrect_trials(df):
- #input: data frame with logs data
- #output: list of all go trials performed incorrectly with indices
- return([(num, one_stim_type) for num, one_stim_type in enumerate(df['Stim Type']) if one_stim_type=='incorrect' or one_stim_type=='miss'])
- # %%
- def compute_percent_go_correct(df):
- #input: data frame with logs data
- #output: percentage of go trials correctly performed
- return(float(len(select_go_correct_trials(df)))/float(len(select_go_trials(df))))
- # %%
- def compute_percent_go_incorrect(df):
- #input: data frame with logs data
- #output: percentage of go trials incorrectly performed
- return((float(len(select_go_trials(df))) - float(len(select_go_correct_trials(df))))/float(len(select_go_trials(df))))
- # %%
- def select_stop_trials(df):
- #input: data frame with logs data
- #output: list of all stop trials with indices
- return(select_stop_correct_trials(df)+select_stop_incorrect_trials(df))
- # %%
- def select_stop_correct_trials(df):
- #input: data frame with logs data
- #output: list of all stop trials with indices performed correctly (inhibited) with indices
- return([(num, one_stim_type) for num, one_stim_type in enumerate(df['Stim Type']) if one_stim_type=='other' and df['Event Type'][num]=='Nothing'])
- # %%
- def select_stop_incorrect_trials(df):
- #input: data frame with logs data
- #output: list of all stop trials with indices performed incorrectly (uninhibited) with indices
- return([(num, one_stim_type) for num, one_stim_type in enumerate(df['Stim Type']) if one_stim_type=='false_alarm'])
- # %%
- def compute_percent_stop_correct(df):
- #input: data frame with logs data
- #output: percentage of go trials incorrectly performed
- return(float(len(select_stop_correct_trials(df)))/float(len(select_stop_trials(df))))
- # %%
- def select_go_rt(df):
- #input: data frame with logs data
- #output: list of reaction times in go trials (if miss - reaction time is equal to 0)
- return([float(df['TTime'][num_trial+1])/10000 if type_trial!='miss' else 0 for num_trial, type_trial in select_go_trials(df)])
- # %%
- def select_go_correct_rt(df):
- #input: data frame with logs data
- #output: list of reaction times in go correct trials
- return([(num_trial, float(df['TTime'][num_trial+1])/10000) for num_trial, type_trial in select_go_correct_trials(df)])
- # %%
- def select_go_incorrect_rt(df):
- #input: data frame with logs data
- #output: list of reaction times in go incorrect trials
- return([(num_trial, float(df['TTime'][num_trial+1])/10000) if type_trial=='incorrect' else (num_trial, 0) for num_trial, type_trial in select_go_incorrect_trials(df)])
- # %%
- def compute_mean_rt_go_correct(df):
- #input: data frame with logs data
- #output: list of mean reaction times in go correct trials
- return(np.mean(np.array(select_go_correct_rt(df))[:,1]))
- # %%
- def compute_mean_rt_stop_incorrect(df):
- #input: data frame with logs data
- #output: list of mean reaction times in go incorrect trials
- return(np.mean(select_stop_incorrect_rt(df)))
- # %%
- def select_stop_incorrect_rt(df):
- #input: data frame with logs data
- #output: list of reaction times in stop incorrect trials
- return([float(df['TTime'][num_trial+1])/10000 for num_trial, type_trial in select_stop_incorrect_trials(df)])
- # %%
- def select_stop_correct_ssd(df):
- #input: data frame with logs data
- #output: list of stop signal delays in stop correct trials
- return([float(re.findall(r'\d{2,3}',df['Code'][num_trial])[0])/1000 for num_trial, stim_type in select_stop_correct_trials(df)])
- # %%
- def select_stop_incorrect_ssd(df):
- #input: data frame with logs data
- #output: list of stop signal delays in stop incorrect trials
- return([float(re.findall(r'\d{2,3}',df['Code'][num_trial])[0])/1000 for num_trial, stim_type in select_stop_incorrect_trials(df)])
- # %%
- def select_stop_ssd(df):
- #input: data frame with logs data
- #output: list of stop signal delays in stop trials
- return(select_stop_correct_ssd(df) + select_stop_incorrect_ssd(df))
- # %%
- def compute_mean_ssd(df):
- #input: data frame with logs data
- #output: list of mean stop signal delays in stop trials
- return(np.mean(select_stop_ssd(df)))
- # %%
- def compute_SSRT(df):
- #input: data frame with logs data
- #output: Stop Signal Reaction Time for a given run
- return(sorted(select_go_correct_rt(df))[round((1.-compute_percent_stop_correct(df))*len(select_go_correct_trials(df)))][1] - compute_mean_ssd(df))
- # %%
- def collect_all_data(df):
- #input: data frame with logs data
- #output: basic statistics in a given run
- return([num_trials(df),
- num_stop_trials(df),
- compute_percent_go_correct(df),
- compute_percent_go_incorrect(df),
- compute_percent_stop_correct(df),
- compute_mean_rt_go_correct(df),
- compute_mean_rt_stop_incorrect(df),
- compute_mean_ssd(df),
- compute_SSRT(df)])
- # %% [markdown]
- # # Create logfiles
- # %%
- def pulse_time_end(df):
- #input: data frame with logs data
- #output: time of the first event after turning on mri scanner
- return((float(df['Time'][[num for num, i in enumerate(df['Event Type']) if i=='Picture'][-1]]))/10000)
- # %%
- def select_go_correct_times(df):
- #input: data frame with logs data
- #output: list of presentation times of go signal in correctly performed trials
- return([float(df['Time'][num])/10000 - pulse_time_end(df) for num, one_stim_type in enumerate(df['Stim Type']) if one_stim_type=='hit'])
- # %%
- def select_go_correct_execution_times(df):
- #input: data frame with logs data
- #output: list of times of making decision in correctly performed go trials
- return([(float(df['Time'][num])/10000 - pulse_time_end(df))+float(df['TTime'][num+1])/10000 for num, one_stim_type in enumerate(df['Stim Type']) if one_stim_type=='hit'])
- # %%
- def select_go_incorrect_times(df):
- #input: data frame with logs data
- #output: list of presentation times of go signal in incorrectly performed trials
- return([float(df['Time'][num])/10000 - pulse_time_end(df) for num, one_stim_type in enumerate(df['Stim Type']) if one_stim_type=='incorrect' or one_stim_type=='miss'])
- # %%
- def select_stop_correct_signal_times(df):
- #input: data frame with logs data
- #output: list of presentation times of stop signal in correctly performed trials
- return([(float(df['Time'][num])/10000 - pulse_time_end(df))+float(re.findall(r'\d{2,3}',df['Code'][num])[0])/1000 for num, one_stim_type in enumerate(df['Stim Type']) if one_stim_type=='other' and df['Event Type'][num]=='Nothing'])
- # %%
- def select_stop_incorrect_signal_times(df):
- #input: data frame with logs data
- #output: list of presentation times of go signal in incorrectly performed trials
- return([(float(df['Time'][num])/10000 - pulse_time_end(df))+float(re.findall(r'\d{2,3}',df['Code'][num])[0])/1000 for num, one_stim_type in enumerate(df['Stim Type']) if one_stim_type=='false_alarm'])
- # %%
- def select_stop_incorrect_rt(df):
- #input: data frame with logs data
- #output: list of reaction times in stop incorrect trials
- return([float(df['TTime'][num+1])/10000 for num, one_stim_type in enumerate(df['Stim Type']) if one_stim_type=='false_alarm'])
- # %%
- def create_pmod_model_new_model(main_directory, out_dir, names):
- #Creating log files for spm analsysi
- #input: directory with log files folder, where to save, names of regressors
- for one_dir in create_list_directories(main_directory):
- print(one_dir)
- subj = re.findall(r'sub-\d{2}', one_dir)[0]
- run = re.findall(r'run-\d{2}', one_dir)[0]
- onsets=[sorted(select_go_correct_times(create_df_single_directory(one_dir)) + select_go_incorrect_times(create_df_single_directory(one_dir)) + select_stop_correct_times(create_df_single_directory(one_dir)) + select_stop_incorrect_times(create_df_single_directory(one_dir))),
- select_go_correct_execution_times(create_df_single_directory(one_dir)),
- select_stop_correct_signal_times(create_df_single_directory(one_dir)),
- select_stop_incorrect_signal_times(create_df_single_directory(one_dir))]
- durations = [list(np.zeros(len(i))) for i in onsets]
- pmods = [select_stop_incorrect_rt(create_df_single_directory(one_dir))]
- pmods_names = ['si_rt']
- dict_to_save = {'names':names, 'onsets':onsets, 'durations':durations, 'pmods':pmods, 'pmods_names':pmods_names}
- scipy.io.savemat(out_dir + subj+'_'+run+'.mat', dict_to_save)
- # %%
- create_pmod_model_new_model('C:/Users/443218/Documents/ProjektSSTError/logi_rejected/', 'C:/Users/443218/Documents/ProjektSSTError/new_mat_logs/', ['go_presentation','go_c','stop_c','stop_ic'])
- # %% [markdown]
- # # Summarize behavioral measures
- # %%
- def create_summary_df(main_directory):
- #input: directory to the folder with log files
- #output: data frame with basic statistics in each run
- return(pd.DataFrame(create_dict_values(main_directory)).transpose())
- # %%
- all_data_behavioral_summary = create_summary_df(<directory_to_logs_files>)
- # %%
- all_data_behavioral_summary.columns = ['n_trials', 'n_stop', 'percent_correct_GO', 'percent_incorrect_go', 'percent_correct_stop', 'mean_rtGo', 'mean_rtStop', 'mean_SSD', 'IRM', 'SSRT']
- # %%
- np.mean(all_data_behavioral_summary)
- # %% [markdown]
- # # Computing Post Error Adjustment
- # %%
- def take_pea_sri_2(one_df):
- #input: data frame with logs
- # output: events with times before and after committing an error, stop response interval and ssd
- list_of_delayed_events = []
- for num, list_events in enumerate(create_list_events_times(one_df)):
- if num!=0 and num+1!=len(create_list_events_times(one_df)) and list_events[0]=='stop_incorrect' and create_list_events_times(one_df)[num-1][0]=='go_correct' and create_list_events_times(one_df)[num+1][0]=='go_correct':
- list_of_delayed_events.append((create_list_events_times(one_df)[num-1][2], create_list_events_times(one_df)[num+1][2], list_events[2]-float(re.findall(r'\d{2,3}', list_events[3])[0])/1000, float(re.findall(r'\d{2,3}', list_events[3])[0])/1000))
- elif num!=0 and num+1!=len(create_list_events_times(one_df)) and list_events[0]=='stop_incorrect' and create_list_events_times(one_df)[num-1][0]=='go_correct' and create_list_events_times(one_df)[num+1][0]=='stop_incorrect':
- x=1
- while num+x!=len(create_list_events_times(one_df)) and create_list_events_times(one_df)[num+x][0]!='go_correct':
- if create_list_events_times(one_df)[num+x][0]=='stop_correct':
- break
- elif create_list_events_times(one_df)[num+x][0]=='stop_incorrect':
- x+=1
- else:
- break
- if num+x!=len(create_list_events_times(one_df)) and create_list_events_times(one_df)[num+x][0]=='go_correct':
- list_of_delayed_events.append((create_list_events_times(one_df)[num-1][2], create_list_events_times(one_df)[num+x][2], list_events[2]-float(re.findall(r'\d{2,3}', list_events[3])[0])/1000, float(re.findall(r'\d{2,3}', list_events[3])[0])/1000))
- elif num!=0 and num+1!=len(create_list_events_times(one_df)) and list_events[0]=='stop_incorrect' and create_list_events_times(one_df)[num-1][0]=='stop_incorrect' and create_list_events_times(one_df)[num+1][0]=='go_correct':
- x=1
- while num-x!=0 and create_list_events_times(one_df)[num-x][0]!='go_correct':
- if create_list_events_times(one_df)[num-x][0]=='stop_correct':
- break
- elif create_list_events_times(one_df)[num-x][0]=='stop_incorrect':
- x+=1
- else:
- break
- if num-x!=0 and create_list_events_times(one_df)[num-x][0]=='go_correct':
- list_of_delayed_events.append((create_list_events_times(one_df)[num-x][2], create_list_events_times(one_df)[num+1][2], list_events[2]-float(re.findall(r'\d{2,3}', list_events[3])[0])/1000, float(re.findall(r'\d{2,3}', list_events[3])[0])/1000))
- elif num!=0 and num+1!=len(create_list_events_times(one_df)) and list_events[0]=='stop_incorrect' and create_list_events_times(one_df)[num-1][0]=='stop_incorrect' and create_list_events_times(one_df)[num+1][0]=='stop_incorrect':
- x=1
- y=1
- while num-x!=0 and create_list_events_times(one_df)[num-x][0]!='go_correct':
- if create_list_events_times(one_df)[num-x][0]=='stop_correct':
- break
- elif create_list_events_times(one_df)[num-x][0]=='stop_incorrect':
- x+=1
- else:
- break
- while num+y!=len(create_list_events_times(one_df)) and create_list_events_times(one_df)[num+y][0]!='go_correct':
- if create_list_events_times(one_df)[num+y][0]=='stop_correct':
- break
- elif create_list_events_times(one_df)[num+y][0]=='stop_incorrect':
- y+=1
- else:
- break
- if num-x!=0 and num+y!=len(create_list_events_times(one_df)) and create_list_events_times(one_df)[num-x][0]=='go_correct' and create_list_events_times(one_df)[num+y][0]=='go_correct':
- list_of_delayed_events.append((create_list_events_times(one_df)[num-x][2], create_list_events_times(one_df)[num+y][2], list_events[2]-float(re.findall(r'\d{2,3}', list_events[3])[0])/1000, float(re.findall(r'\d{2,3}', list_events[3])[0])/1000))
- elif num!=0 and num+1!=len(create_list_events_times(one_df)) and list_events[0]=='stop_incorrect' and create_list_events_times(one_df)[num-1][0]=='miss' and create_list_events_times(one_df)[num+1][0]=='stop_incorrect':
- continue
- elif num!=0 and num+1!=len(create_list_events_times(one_df)) and list_events[0]=='stop_incorrect' and create_list_events_times(one_df)[num-1][0]=='miss' and create_list_events_times(one_df)[num+1][0]=='stop_incorrect':
- continue
- indices=[num for num, (pre,post, sri, ssd) in enumerate(list_of_delayed_events) for num2, (pre2,post2, sri2, ssd) in enumerate(list_of_delayed_events[num+1:]) if num!=num2 and pre==pre2 and post==post2]
- z=0
- print(indices)
- for num2, i in enumerate(indices):
- del(list_of_delayed_events[i+1-z])
- z+=1
- return(list_of_delayed_events)
- # %%
- def compute_pea_sri(df):
- #input date frame with logs
- #output: creating an array with post error times, relative difference post and pre error times, sri and ssd in stop incorrect trials
- return(np.array([[post,post-pre, sri,ssd] for (pre,post, sri, ssd) in take_pea_sri_2(df)]))
- # %%
- def array_list_pea_sri(main_directory):
- #input directory to folder with log files
- #output: dictionary with log files directories as kets and post error slowing measures as values
- return({one_run:compute_pea_sri(create_df_single_directory(one_run)) for one_run in [main_directory + one_dir for one_dir in os.listdir(main_directory)]})
- # %%
- def create_list_events_times(df):
- #input: data Frame with logs
- #output: list of sequence of go and stop events in order of appearing and their timings
- return([i for num2, i in enumerate([('go_correct', float(df['Time'][num])/10000 - pulse_time_end(df), float(df['TTime'][num+1])/10000) if event_type=='hit' else ('go_incorrect', float(df['Time'][num])/10000- pulse_time_end(df), float(df['TTime'][num+1])/10000) if event_type=='incorrect' else ('stop_correct', float(df['Time'][num])/10000- pulse_time_end(df), 0, df['Code'][num]) if event_type=='other' else ('stop_incorrect', float(df['Time'][num])/10000 - pulse_time_end(df), float(df['TTime'][num+1])/10000, df['Code'][num]) if event_type=='false_alarm' else 0 for num, event_type in enumerate(df['Stim Type'])]) if i!=0][1:])
- # %%
- all_data_pea_sri = array_list_pea_sri(<directory_to_folder_with_log_data>)
- # %%
- all_data_pea_sri_fmri={keys:values for keys, values in all_data_pea_sri.items() if keys[-26:] in os.listdir(<directory_to_folder_with_log_data_in_fmri>)}
- # %%
- all_sri_observations = [sri for logs, array_data in all_data_pea_sri.items() for [post,pea, sri,ssd] in array_data]
- mri_sri_observations = [sri for logs, array_data in all_data_pea_sri_fmri.items() for [post,pea, sri,ssd] in array_data]
- # %%
- dict_subj_sri_all = {}
- for log_key, array_data in all_data_pea_sri.items():
- if re.findall(r'sub-\d{2}',log_key)[0] not in dict_subj_sri_all:
- dict_subj_sri_all[re.findall(r'sub-\d{2}',log_key)[0]]=[array_data[:,2]]
- else:
- dict_subj_sri_all[re.findall(r'sub-\d{2}',log_key)[0]].append(array_data[:,2])
- dict_subj_sri_all_corrected = {}
- for subj, values in dict_subj_sri_all.items():
- if len(values)==1:
- dict_subj_sri_all_corrected[subj]=values
- else:
- dict_subj_sri_all_corrected[subj]=[one_sri for one_array in values for one_sri in one_array]
- dict_subj_sri_all_mean = {subj:[np.mean(list_sri), np.std(list_sri)] for subj, list_sri in dict_subj_sri_all_corrected.items()}
- mean_sri_all_subj = np.mean([mean_sri for subj, [mean_sri, std_sri] in dict_subj_sri_all_mean.items()])
- # %% [markdown]
- # # Regression of SRI on PEA¶
- # %%
- #list of all subjects
- subj_list = np.unique([re.findall(r'sub-\d{2}', i)[0] for i in os.listdir(<directory_to_folder_with_log_data>)])
- # %%
- #Computing the dict with post reaction times and sri
- dict_post_sri_4={log_name2:np.array([array_2[:,0],array_2[:,2],array_2[:,3]]) for log_name2, array_2 in all_data_pea_sri_fmri.items() if len(array_2)!=0} # and log_name not in list_pre_post_irm_not
- # %%
- #creating data frame with data for model
- df_post_sri = pd.DataFrame([[one_sub, post, array_pea_sri[1][num], array_pea_sri[2][num]] for one_sub in subj_list for log_name, array_pea_sri in dict_post_sri_4.items() for num, post in enumerate(array_pea_sri[0]) if re.findall(r'sub-\d{2}',log_name)[0]==one_sub])
- df_post_sri.columns = ['subject', 'post', 'sri', 'ssd']
- # %%
- #Mixed model without excluding
- md = smf.mixedlm("post ~ sri + ssd", df_post_sri.iloc[:,1:], groups=df_post_sri["subject"])
- mdf = md.fit()
- print(mdf.summary())
- # %% [markdown]
- # # Compute Time Series and SRI relations
- # %%
- #taking
- # %%
- main_directory_preprocessed = #<directory to preprocessed data>
- dict_sub_run_files={str(re.findall(r'sub-\d{2}', one_run)[0]) + '_' + str(re.findall(r'run-\d{2}',one_run)[0]):main_directory_preprocessed+one_run for one_run in os.listdir(main_directory_preprocessed)}
- # %%
- #taking MNI coordinates of ROIs from MRI analysis
- # %%
- mask_file_SFG = #<directory to ROI from SFG
- mask_array_SFG = nib.load(mask_file_SFG).get_data()
- coordinates_mask_SFG = [(x_coor, y_coor, z_coor) for (x_coor, x_data) in enumerate(mask_array_SFG)
- for (y_coor, y_data) in enumerate(x_data)
- for (z_coor, z_data) in enumerate(y_data) if z_data!=0]
- # %%
- mask_file_left_insula = #<directory to ROI from left insula
- mask_array_left_insula = nib.load(mask_file_left_insula).get_data()
- coordinates_mask_left_insula = [(x_coor, y_coor, z_coor) for (x_coor, x_data) in enumerate(mask_array_left_insula)
- for (y_coor, y_data) in enumerate(x_data)
- for (z_coor, z_data) in enumerate(y_data) if z_data!=0]
- # %%
- mask_file_left_SPR = #directory to ROI from left supramarginal gyrus cluster 1
- mask_array_left_SPR = nib.load(mask_file_left_SFG).get_data()
- coordinates_mask_left_SPR = [(x_coor, y_coor, z_coor) for (x_coor, x_data) in enumerate(mask_array_left_SPR)
- for (y_coor, y_data) in enumerate(x_data)
- for (z_coor, z_data) in enumerate(y_data) if z_data!=0]
- # %%
- mask_file_left_supramarginal = #directory to ROI from left supramarginal gyrus cluster 2
- mask_array_left_supramarginal = nib.load(mask_file_left_supramarginal).get_data()
- coordinates_mask_left_supramarginal = [(x_coor, y_coor, z_coor) for (x_coor, x_data) in enumerate(mask_array_left_supramarginal)
- for (y_coor, y_data) in enumerate(x_data)
- for (z_coor, z_data) in enumerate(y_data) if z_data!=0]
- # %%
- mask_file_right_insula= #directory to ROI from right insula
- mask_array_right_insula = nib.load(mask_file_right_insula).get_data()
- coordinates_mask_right_insula = [(x_coor, y_coor, z_coor) for (x_coor, x_data) in enumerate(mask_array_right_insula)
- for (y_coor, y_data) in enumerate(x_data)
- for (z_coor, z_data) in enumerate(y_data) if z_data!=0]
- # %%
- mask_file_right_lingual= #directory to ROI from right lingual gyrus
- mask_array_right_lingual = nib.load(mask_file_right_lingual).get_data()
- coordinates_mask_right_lingual = [(x_coor, y_coor, z_coor) for (x_coor, x_data) in enumerate(mask_array_right_lingual)
- for (y_coor, y_data) in enumerate(x_data)
- for (z_coor, z_data) in enumerate(y_data) if z_data!=0]
- # %%
- mask_file_right_supramarginal= #directory to ROI from right supramarginal gyrus
- mask_array_right_supramarginal = nib.load(mask_file_right_supramarginal).get_data()
- coordinates_mask_right_supramarginal = [(x_coor, y_coor, z_coor) for (x_coor, x_data) in enumerate(mask_array_right_supramarginal)
- for (y_coor, y_data) in enumerate(x_data)
- for (z_coor, z_data) in enumerate(y_data) if z_data!=0]
- # %%
- #creating average value of time series in given ROIs
- # %%
- dict_averaged_ts_in_roi_SFG = {}
- for (id_sub_run, directory) in dict_sub_run_files.items():
- print(id_sub_run)
- file_directory=nib.load(directory)
- mean_ts = np.mean([file_directory.get_data()[x,y,z,:] for (x,y,z) in coordinates_mask_SFG], axis = 0)
- dict_averaged_ts_in_roi_SFG[id_sub_run]=mean_ts
- # %%
- dict_averaged_ts_in_roi_left_insula = {}
- for (id_sub_run, directory) in dict_sub_run_files.items():
- print(id_sub_run)
- file_directory=nib.load(directory)
- mean_ts = np.mean([file_directory.get_data()[x,y,z,:] for (x,y,z) in coordinates_mask_left_insula], axis = 0)
- dict_averaged_ts_in_roi_left_insula[id_sub_run]=mean_ts
- # %%
- dict_averaged_ts_in_roi_left_supramarginal = {}
- for (id_sub_run, directory) in dict_sub_run_files.items():
- print(id_sub_run)
- file_directory=nib.load(directory)
- mean_ts = np.mean([file_directory.get_data()[x,y,z,:] for (x,y,z) in coordinates_mask_left_supramarginal], axis = 0)
- dict_averaged_ts_in_roi_left_supramarginal[id_sub_run]=mean_ts
- # %%
- dict_averaged_ts_in_roi_left_SPR = {}
- for (id_sub_run, directory) in dict_sub_run_files.items():
- print(id_sub_run)
- file_directory=nib.load(directory)
- mean_ts = np.mean([file_directory.get_data()[x,y,z,:] for (x,y,z) in coordinates_mask_left_SPR], axis = 0)
- dict_averaged_ts_in_roi_left_SPR[id_sub_run]=mean_ts
- # %%
- dict_averaged_ts_in_roi_right_insula = {}
- for (id_sub_run, directory) in dict_sub_run_files.items():
- print(id_sub_run)
- file_directory=nib.load(directory)
- mean_ts = np.mean([file_directory.get_data()[x,y,z,:] for (x,y,z) in coordinates_mask_right_insula], axis = 0)
- dict_averaged_ts_in_roi_right_insula[id_sub_run]=mean_ts
- # %%
- dict_averaged_ts_in_roi_right_lingual = {}
- for (id_sub_run, directory) in dict_sub_run_files.items():
- print(id_sub_run)
- file_directory=nib.load(directory)
- mean_ts = np.mean([file_directory.get_data()[x,y,z,:] for (x,y,z) in coordinates_mask_right_lingual], axis = 0)
- dict_averaged_ts_in_roi_right_lingual[id_sub_run]=mean_ts
- # %%
- dict_averaged_ts_in_roi_right_supramarginal = {}
- for (id_sub_run, directory) in dict_sub_run_files.items():
- print(id_sub_run)
- file_directory=nib.load(directory)
- mean_ts = np.mean([file_directory.get_data()[x,y,z,:] for (x,y,z) in coordinates_mask_right_supramarginal], axis = 0)
- dict_averaged_ts_in_roi_right_supramarginal[id_sub_run]=mean_ts
- # %%
- #making interpolation of time series in given ROIs
- # %%
- dict_interpolated_ts_SFG = {}
- for id_sub_run, ts in dict_averaged_ts_in_roi_SFG.items():
- original_time_points = np.arange(0, len(ts) * 1.8, 1.8)
- original_values = ts # Your original values here
- # New time points for interpolation sampled every 100 ms
- new_time_points = np.arange(0, original_time_points[-1], 0.1)
- # Perform linear interpolation
- f = interp1d(original_time_points, original_values, kind='linear')
- # Interpolate values at new time points
- interpolated_values = f(new_time_points)
- # Output the interpolated time series
- dict_interpolated_ts_SFG[id_sub_run] = interpolated_values
- # %%
- dict_interpolated_ts_left_insula = {}
- for id_sub_run, ts in dict_averaged_ts_in_roi_left_insula.items():
- original_time_points = np.arange(0, len(ts) * 1.8, 1.8)
- original_values = ts # Your original values here
- # New time points for interpolation sampled every 100 ms
- new_time_points = np.arange(0, original_time_points[-1], 0.1)
- # Perform linear interpolation
- f = interp1d(original_time_points, original_values, kind='linear')
- # Interpolate values at new time points
- interpolated_values = f(new_time_points)
- # Output the interpolated time series
- dict_interpolated_ts_left_insula[id_sub_run] = interpolated_values
- # %%
- dict_interpolated_ts_left_SPR = {}
- for id_sub_run, ts in dict_averaged_ts_in_roi_left_SPR.items():
- original_time_points = np.arange(0, len(ts) * 1.8, 1.8)
- original_values = ts # Your original values here
- # New time points for interpolation sampled every 100 ms
- new_time_points = np.arange(0, original_time_points[-1], 0.1)
- # Perform linear interpolation
- f = interp1d(original_time_points, original_values, kind='linear')
- # Interpolate values at new time points
- interpolated_values = f(new_time_points)
- # Output the interpolated time series
- dict_interpolated_ts_left_SPR[id_sub_run] = interpolated_values
- # %%
- dict_interpolated_ts_left_supramarginal = {}
- for id_sub_run, ts in dict_averaged_ts_in_roi_left_supramarginal.items():
- original_time_points = np.arange(0, len(ts) * 1.8, 1.8)
- original_values = ts # Your original values here
- # New time points for interpolation sampled every 100 ms
- new_time_points = np.arange(0, original_time_points[-1], 0.1)
- # Perform linear interpolation
- f = interp1d(original_time_points, original_values, kind='linear')
- # Interpolate values at new time points
- interpolated_values = f(new_time_points)
- # Output the interpolated time series
- dict_interpolated_ts_left_supramarginal[id_sub_run] = interpolated_values
- # %%
- dict_interpolated_ts_right_insula = {}
- for id_sub_run, ts in dict_averaged_ts_in_roi_right_insula.items():
- original_time_points = np.arange(0, len(ts) * 1.8, 1.8)
- original_values = ts # Your original values here
- # New time points for interpolation sampled every 100 ms
- new_time_points = np.arange(0, original_time_points[-1], 0.1)
- # Perform linear interpolation
- f = interp1d(original_time_points, original_values, kind='linear')
- # Interpolate values at new time points
- interpolated_values = f(new_time_points)
- # Output the interpolated time series
- dict_interpolated_ts_right_insula[id_sub_run] = interpolated_values
- # %%
- dict_interpolated_ts_right_lingual = {}
- for id_sub_run, ts in dict_averaged_ts_in_roi_right_lingual.items():
- original_time_points = np.arange(0, len(ts) * 1.8, 1.8)
- original_values = ts # Your original values here
- # New time points for interpolation sampled every 100 ms
- new_time_points = np.arange(0, original_time_points[-1], 0.1)
- # Perform linear interpolation
- f = interp1d(original_time_points, original_values, kind='linear')
- # Interpolate values at new time points
- interpolated_values = f(new_time_points)
- # Output the interpolated time series
- dict_interpolated_ts_right_lingual[id_sub_run] = interpolated_values
- # %%
- dict_interpolated_ts_right_supramarginal = {}
- for id_sub_run, ts in dict_averaged_ts_in_roi_right_supramarginal.items():
- original_time_points = np.arange(0, len(ts) * 1.8, 1.8)
- original_values = ts # Your original values here
- # New time points for interpolation sampled every 100 ms
- new_time_points = np.arange(0, original_time_points[-1], 0.1)
- # Perform linear interpolation
- f = interp1d(original_time_points, original_values, kind='linear')
- # Interpolate values at new time points
- interpolated_values = f(new_time_points)
- # Output the interpolated time series
- dict_interpolated_ts_right_supramarginal[id_sub_run] = interpolated_values
- # %%
- #taking onsets of stop correct and incorrect timings
- # %%
- dict_onsets = {}
- for one_dir in create_list_directories('C:/Users/443218/Documents/ProjektSSTError/logi_rejected/'):
- one_df=create_df_single_directory(one_dir)
- dict_stop_onsets={'stop_incorrect':[select_stop_incorrect_times(one_df), select_ssd_notinhibited(one_df), select_stop_incorrect_rt(one_df)],
- 'stop_correct':[select_stop_correct_times(one_df), select_ssd_inhibited(one_df)]}
- dict_onsets[str(re.findall(r'sub-\d{2}',one_dir)[0])+'_'+str(re.findall(r'run-\d{2}', one_dir)[0])]=dict_stop_onsets
- # %%
- #extending timings to fit interpolated time series
- # %%
- dict_onsets_100 = {id_s_r:{stop_id:[[one_elem/.1 for one_elem in one_list] for one_list in list_onsets] for stop_id, list_onsets in dict_values.items()} for id_s_r, dict_values in dict_onsets.items()}
- # %%
- #annotating BOLD values in given rois in given onset timings
- # %%
- dict_ts_s_ic_SFG = {}
- for id_ts, ts in dict_interpolated_ts_SFG.items():
- list_ts = []
- if id_ts in list(dict_onsets_100.keys()):
- for num,ind_s_i in enumerate(dict_onsets_100[id_ts]['stop_incorrect'][0]):
- indeks_before=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])-40)
- indeks_after=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])+140)
- if indeks_before>0 and indeks_after<len(ts):
- list_ts.append([ts[indeks_before:indeks_after], dict_onsets_100[id_ts]['stop_incorrect'][1], dict_onsets_100[id_ts]['stop_incorrect'][2]])
- dict_ts_s_ic_SFG[id_ts]=list_ts
- # %%
- dict_ts_s_ic_left_insula = {}
- for id_ts, ts in dict_interpolated_ts_left_insula.items():
- list_ts = []
- if id_ts in list(dict_onsets_100.keys()):
- for num,ind_s_i in enumerate(dict_onsets_100[id_ts]['stop_incorrect'][0]):
- indeks_before=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])-40)
- indeks_after=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])+140)
- if indeks_before>0 and indeks_after<len(ts):
- list_ts.append([ts[indeks_before:indeks_after], dict_onsets_100[id_ts]['stop_incorrect'][1], dict_onsets_100[id_ts]['stop_incorrect'][2]])
- dict_ts_s_ic_left_insula[id_ts]=list_ts
- # %%
- dict_ts_s_ic_left_SPR = {}
- for id_ts, ts in dict_interpolated_ts_left_SPR.items():
- list_ts = []
- if id_ts in list(dict_onsets_100.keys()):
- for num,ind_s_i in enumerate(dict_onsets_100[id_ts]['stop_incorrect'][0]):
- indeks_before=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])-40)
- indeks_after=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])+140)
- if indeks_before>0 and indeks_after<len(ts):
- list_ts.append([ts[indeks_before:indeks_after], dict_onsets_100[id_ts]['stop_incorrect'][1], dict_onsets_100[id_ts]['stop_incorrect'][2]])
- dict_ts_s_ic_left_SPR[id_ts]=list_ts
- # %%
- dict_ts_s_ic_left_supramarginal = {}
- for id_ts, ts in dict_interpolated_ts_left_supramarginal.items():
- list_ts = []
- if id_ts in list(dict_onsets_100.keys()):
- for num,ind_s_i in enumerate(dict_onsets_100[id_ts]['stop_incorrect'][0]):
- indeks_before=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])-40)
- indeks_after=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])+140)
- if indeks_before>0 and indeks_after<len(ts):
- list_ts.append([ts[indeks_before:indeks_after], dict_onsets_100[id_ts]['stop_incorrect'][1], dict_onsets_100[id_ts]['stop_incorrect'][2]])
- dict_ts_s_ic_left_supramarginal[id_ts]=list_ts
- # %%
- dict_ts_s_ic_right_insula = {}
- for id_ts, ts in dict_interpolated_ts_right_insula.items():
- list_ts = []
- if id_ts in list(dict_onsets_100.keys()):
- for num,ind_s_i in enumerate(dict_onsets_100[id_ts]['stop_incorrect'][0]):
- indeks_before=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])-40)
- indeks_after=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])+140)
- if indeks_before>0 and indeks_after<len(ts):
- list_ts.append([ts[indeks_before:indeks_after], dict_onsets_100[id_ts]['stop_incorrect'][1], dict_onsets_100[id_ts]['stop_incorrect'][2]])
- dict_ts_s_ic_right_insula[id_ts]=list_ts
- # %%
- dict_ts_s_ic_right_lingual = {}
- for id_ts, ts in dict_interpolated_ts_right_lingual.items():
- list_ts = []
- if id_ts in list(dict_onsets_100.keys()):
- for num,ind_s_i in enumerate(dict_onsets_100[id_ts]['stop_incorrect'][0]):
- indeks_before=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])-40)
- indeks_after=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])+140)
- if indeks_before>0 and indeks_after<len(ts):
- list_ts.append([ts[indeks_before:indeks_after], dict_onsets_100[id_ts]['stop_incorrect'][1], dict_onsets_100[id_ts]['stop_incorrect'][2]])
- dict_ts_s_ic_right_lingual[id_ts]=list_ts
- # %%
- dict_ts_s_ic_right_supramarginal = {}
- for id_ts, ts in dict_interpolated_ts_right_supramarginal.items():
- list_ts = []
- if id_ts in list(dict_onsets_100.keys()):
- for num,ind_s_i in enumerate(dict_onsets_100[id_ts]['stop_incorrect'][0]):
- indeks_before=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])-40)
- indeks_after=int(np.round(ind_s_i+dict_onsets_100[id_ts]['stop_incorrect'][1][num])+140)
- if indeks_before>0 and indeks_after<len(ts):
- list_ts.append([ts[indeks_before:indeks_after], dict_onsets_100[id_ts]['stop_incorrect'][1], dict_onsets_100[id_ts]['stop_incorrect'][2]])
- dict_ts_s_ic_right_supramarginal[id_ts]=list_ts
- # %%
- #creating averaged waves in given ROIs
- # %%
- x_time = np.arange(-40,140,1)
- given_ts_SFG = np.mean([one_ts[0] for id_ts, list_array in dict_ts_s_ic_SFG.items() for one_ts in list_array], axis=0)
- std_ts_SFG = np.std([one_ts[0] for id_ts, list_array in dict_ts_s_ic_SFG.items() for one_ts in list_array], axis=0)
- down_border_SFG = given_ts_SFG - 1.96*(std_ts_SFG/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_SFG.items() for one_ts in list_array])))
- up_border_SFG = given_ts_SFG + 1.96*(std_ts_SFG/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_SFG.items() for one_ts in list_array])))
- # %%
- x_time = np.arange(-40,140,1)
- given_ts_SPR = np.mean([one_ts[0] for id_ts, list_array in dict_ts_s_ic_SFG.items() for one_ts in list_array], axis=0)
- std_ts_SFG = np.std([one_ts[0] for id_ts, list_array in dict_ts_s_ic_SFG.items() for one_ts in list_array], axis=0)
- down_border_SFG = given_ts_SFG - 1.96*(std_ts_SFG/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_SFG.items() for one_ts in list_array])))
- up_border_SFG = given_ts_SFG + 1.96*(std_ts_SFG/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_SFG.items() for one_ts in list_array])))
- # %%
- x_time = np.arange(-40,140,1)
- given_ts_left_SPR = np.mean([one_ts[0] for id_ts, list_array in dict_ts_s_ic_left_SPR.items() for one_ts in list_array], axis=0)
- std_ts_left_SPR = np.std([one_ts[0] for id_ts, list_array in dict_ts_s_ic_left_SPR.items() for one_ts in list_array], axis=0)
- down_border_left_SPR = given_ts_left_SFG - 1.96*(std_ts_left_SPR/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_left_SPR.items() for one_ts in list_array])))
- up_border_left_SPR = given_ts_left_SPR + 1.96*(std_ts_left_SPR/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_left_SPR.items() for one_ts in list_array])))
- # %%
- x_time = np.arange(-40,140,1)
- given_ts_left_supramarginal = np.mean([one_ts[0] for id_ts, list_array in dict_ts_s_ic_left_supramarginal.items() for one_ts in list_array], axis=0)
- std_ts_left_supramarginal = np.std([one_ts[0] for id_ts, list_array in dict_ts_s_ic_left_supramarginal.items() for one_ts in list_array], axis=0)
- down_border_left_supramarginal = given_ts_left_supramarginal - 1.96*(std_ts_left_supramarginal/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_left_supramarginal.items() for one_ts in list_array])))
- up_border_left_supramarginal = given_ts_left_supramarginal + 1.96*(std_ts_left_supramarginal/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_left_supramarginal.items() for one_ts in list_array])))
- # %%
- x_time = np.arange(-40,140,1)
- given_ts_right_insula = np.mean([one_ts[0] for id_ts, list_array in dict_ts_s_ic_right_insula.items() for one_ts in list_array], axis=0)
- std_ts_right_insula = np.std([one_ts[0] for id_ts, list_array in dict_ts_s_ic_right_insula.items() for one_ts in list_array], axis=0)
- down_border_right_insula = given_ts_right_insula - 1.96*(std_ts_right_insula/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_right_insula.items() for one_ts in list_array])))
- up_border_right_insula = given_ts_right_insula + 1.96*(std_ts_right_insula/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_right_insula.items() for one_ts in list_array])))
- # %%
- x_time = np.arange(-40,140,1)
- given_ts_right_lingual = np.mean([one_ts[0] for id_ts, list_array in dict_ts_s_ic_right_lingual.items() for one_ts in list_array], axis=0)
- std_ts_right_lingual = np.std([one_ts[0] for id_ts, list_array in dict_ts_s_ic_right_lingual.items() for one_ts in list_array], axis=0)
- down_border_right_lingual = given_ts_right_lingual - 1.96*(std_ts_right_lingual/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_right_lingual.items() for one_ts in list_array])))
- up_border_right_lingual = given_ts_right_lingual + 1.96*(std_ts_right_lingual/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_right_lingual.items() for one_ts in list_array])))
- # %%
- x_time = np.arange(-40,140,1)
- given_ts_right_lingual = np.mean([one_ts[0] for id_ts, list_array in dict_ts_s_ic_right_lingual.items() for one_ts in list_array], axis=0)
- std_ts_right_lingual = np.std([one_ts[0] for id_ts, list_array in dict_ts_s_ic_right_lingual.items() for one_ts in list_array], axis=0)
- down_border_right_lingual = given_ts_right_lingual - 1.96*(std_ts_right_lingual/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_right_lingual.items() for one_ts in list_array])))
- up_border_right_lingual = given_ts_right_lingual + 1.96*(std_ts_right_lingual/np.sqrt(len([one_ts[0] for id_ts, list_array in dict_ts_s_ic_right_lingual.items() for one_ts in list_array])))
- # %%
- #plotting the average waves for stop incorrect trials in given ROIs
- # %%
- plt.figure(figsize=(20,10))
- plt.rcParams["figure.facecolor"] = "w"
- plt.plot(x_time/10, given_ts_SFG, color = 'blue', label='Averaged Signal', linewidth = 2.5)
- plt.fill_between(x_time/10, down_border_SFG, up_border_SFG, color ='lightblue', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 36)
- # %%
- plt.figure(figsize=(20,10))
- plt.rcParams["figure.facecolor"] = "w"
- plt.plot(x_time/10, given_ts_left_insula, color = 'blue', label='Averaged Signal', linewidth = 2.5)
- plt.fill_between(x_time/10, down_border_left_insula, up_border_left_insula, color ='lightblue', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 36)
- # %%
- plt.figure(figsize=(20,10))
- plt.rcParams["figure.facecolor"] = "w"
- plt.plot(x_time/10, given_ts_left_SPR, color = 'blue', label='Averaged Signal', linewidth = 2.5)
- plt.fill_between(x_time/10, down_border_left_SPR, up_border_left_SPR, color ='lightblue', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 36)
- # %%
- plt.figure(figsize=(20,10))
- plt.rcParams["figure.facecolor"] = "w"
- plt.plot(x_time/10, given_ts_left_supramarginal, color = 'blue', label='Averaged Signal', linewidth = 2.5)
- plt.fill_between(x_time/10, down_border_left_supramarginal, up_border_left_supramarginal, color ='lightblue', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 36)
- # %%
- plt.figure(figsize=(20,10))
- plt.rcParams["figure.facecolor"] = "w"
- plt.plot(x_time/10, given_ts_right_insula, color = 'blue', label='Averaged Signal', linewidth = 2.5)
- plt.fill_between(x_time/10, down_border_right_insula, up_border_right_insula, color ='lightblue', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 36)
- # %%
- plt.figure(figsize=(20,10))
- plt.rcParams["figure.facecolor"] = "w"
- plt.plot(x_time/10, given_ts_right_insula, color = 'blue', label='Averaged Signal', linewidth = 2.5)
- plt.fill_between(x_time/10, down_border_right_insula, up_border_right_insula, color ='lightblue', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 36)
- # %%
- plt.figure(figsize=(20,10))
- plt.rcParams["figure.facecolor"] = "w"
- plt.plot(x_time/10, given_ts_right_supramarginal, color = 'blue', label='Averaged Signal', linewidth = 2.5)
- plt.fill_between(x_time/10, down_border_right_supramarginal, up_border_right_supramarginal, color ='lightblue', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 36)
- # %%
- #subtracting the stop correct waves from stop incorrect waves matched with SSD in given rOis
- # %%
- dict_subtraction_SFG = {}
- for id_s_r, dict_values_stop in dict_onsets_100.items():
- if id_s_r in dict_interpolated_ts_SFG:
- stop_incorrect_ssds=np.unique(dict_values_stop['stop_incorrect'][1])
- stop_correct_ssds = np.unique(dict_values_stop['stop_correct'][1])
- ssds=[ssd_ic for ssd_ic in stop_incorrect_ssds if ssd_ic in stop_correct_ssds]
- dict_waves_ic = {}
- dict_waves_c = {}
- for num_one, one_ssd in enumerate(ssds):
- for num,ssd_ic_pri in enumerate(dict_values_stop['stop_incorrect'][1]):
- if one_ssd==ssd_ic_pri:
- indeks_before_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)-40)
- indeks_after_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)+140)
- if indeks_before_ic>0 and indeks_after_ic<len(dict_interpolated_ts_SFG[id_s_r]):
- if one_ssd not in dict_waves_ic:
- dict_waves_ic[one_ssd]=[(dict_interpolated_ts_SFG[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num])]
- else:
- dict_waves_ic[one_ssd].append((dict_interpolated_ts_SFG[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num]))
- for num2,ssd_c_pri in enumerate(dict_values_stop['stop_correct'][1]):
- if one_ssd==ssd_c_pri:
- indeks_before_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)-40)
- indeks_after_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)+140)
- if indeks_after_c<len(dict_interpolated_ts_SFG[id_s_r]) and indeks_before_c>0:
- if one_ssd not in dict_waves_c:
- dict_waves_c[one_ssd]=[dict_interpolated_ts_SFG[id_s_r][indeks_before_c:indeks_after_c]]
- else:
- dict_waves_c[one_ssd].append(dict_interpolated_ts_SFG[id_s_r][indeks_before_c:indeks_after_c])
- new_dict_waves_c={ssd_s_ic:dict_waves_c[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- new_dict_waves_ic={ssd_s_ic:dict_waves_ic[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- dict_subtraction_SFG[id_s_r]=[new_dict_waves_ic, new_dict_waves_c]
- # %%
- dict_subtraction_left_insula = {}
- for id_s_r, dict_values_stop in dict_onsets_100.items():
- if id_s_r in dict_interpolated_ts_left_insula:
- stop_incorrect_ssds=np.unique(dict_values_stop['stop_incorrect'][1])
- stop_correct_ssds = np.unique(dict_values_stop['stop_correct'][1])
- ssds=[ssd_ic for ssd_ic in stop_incorrect_ssds if ssd_ic in stop_correct_ssds]
- dict_waves_ic = {}
- dict_waves_c = {}
- for num_one, one_ssd in enumerate(ssds):
- for num,ssd_ic_pri in enumerate(dict_values_stop['stop_incorrect'][1]):
- if one_ssd==ssd_ic_pri:
- indeks_before_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)-40)
- indeks_after_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)+140)
- if indeks_before_ic>0 and indeks_after_ic<len(dict_interpolated_ts_left_insula[id_s_r]):
- if one_ssd not in dict_waves_ic:
- dict_waves_ic[one_ssd]=[(dict_interpolated_ts_left_insula[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num])]
- else:
- dict_waves_ic[one_ssd].append((dict_interpolated_ts_left_insula[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num]))
- for num2,ssd_c_pri in enumerate(dict_values_stop['stop_correct'][1]):
- if one_ssd==ssd_c_pri:
- indeks_before_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)-40)
- indeks_after_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)+140)
- if indeks_after_c<len(dict_interpolated_ts_left_insula[id_s_r]) and indeks_before_c>0:
- if one_ssd not in dict_waves_c:
- dict_waves_c[one_ssd]=[dict_interpolated_ts_left_insula[id_s_r][indeks_before_c:indeks_after_c]]
- else:
- dict_waves_c[one_ssd].append(dict_interpolated_ts_left_insula[id_s_r][indeks_before_c:indeks_after_c])
- new_dict_waves_c={ssd_s_ic:dict_waves_c[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- new_dict_waves_ic={ssd_s_ic:dict_waves_ic[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- dict_subtraction_left_insula[id_s_r]=[new_dict_waves_ic, new_dict_waves_c]
- # %%
- dict_subtraction_left_SFG = {}
- for id_s_r, dict_values_stop in dict_onsets_100.items():
- if id_s_r in dict_interpolated_ts_left_SFG:
- stop_incorrect_ssds=np.unique(dict_values_stop['stop_incorrect'][1])
- stop_correct_ssds = np.unique(dict_values_stop['stop_correct'][1])
- ssds=[ssd_ic for ssd_ic in stop_incorrect_ssds if ssd_ic in stop_correct_ssds]
- dict_waves_ic = {}
- dict_waves_c = {}
- for num_one, one_ssd in enumerate(ssds):
- for num,ssd_ic_pri in enumerate(dict_values_stop['stop_incorrect'][1]):
- if one_ssd==ssd_ic_pri:
- indeks_before_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)-40)
- indeks_after_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)+140)
- if indeks_before_ic>0 and indeks_after_ic<len(dict_interpolated_ts_left_SFG[id_s_r]):
- if one_ssd not in dict_waves_ic:
- dict_waves_ic[one_ssd]=[(dict_interpolated_ts_left_SFG[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num])]
- else:
- dict_waves_ic[one_ssd].append((dict_interpolated_ts_left_SFG[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num]))
- for num2,ssd_c_pri in enumerate(dict_values_stop['stop_correct'][1]):
- if one_ssd==ssd_c_pri:
- indeks_before_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)-40)
- indeks_after_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)+140)
- if indeks_after_c<len(dict_interpolated_ts_left_SFG[id_s_r]) and indeks_before_c>0:
- if one_ssd not in dict_waves_c:
- dict_waves_c[one_ssd]=[dict_interpolated_ts_left_SFG[id_s_r][indeks_before_c:indeks_after_c]]
- else:
- dict_waves_c[one_ssd].append(dict_interpolated_ts_left_SFG[id_s_r][indeks_before_c:indeks_after_c])
- new_dict_waves_c={ssd_s_ic:dict_waves_c[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- new_dict_waves_ic={ssd_s_ic:dict_waves_ic[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- dict_subtraction_left_SFG[id_s_r]=[new_dict_waves_ic, new_dict_waves_c]
- # %%
- dict_subtraction_left_SPR = {}
- for id_s_r, dict_values_stop in dict_onsets_100.items():
- if id_s_r in dict_interpolated_ts_left_SPR:
- stop_incorrect_ssds=np.unique(dict_values_stop['stop_incorrect'][1])
- stop_correct_ssds = np.unique(dict_values_stop['stop_correct'][1])
- ssds=[ssd_ic for ssd_ic in stop_incorrect_ssds if ssd_ic in stop_correct_ssds]
- dict_waves_ic = {}
- dict_waves_c = {}
- for num_one, one_ssd in enumerate(ssds):
- for num,ssd_ic_pri in enumerate(dict_values_stop['stop_incorrect'][1]):
- if one_ssd==ssd_ic_pri:
- indeks_before_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)-40)
- indeks_after_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)+140)
- if indeks_before_ic>0 and indeks_after_ic<len(dict_interpolated_ts_left_SFG[id_s_r]):
- if one_ssd not in dict_waves_ic:
- dict_waves_ic[one_ssd]=[(dict_interpolated_ts_left_SPR[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num])]
- else:
- dict_waves_ic[one_ssd].append((dict_interpolated_ts_left_SPR[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num]))
- for num2,ssd_c_pri in enumerate(dict_values_stop['stop_correct'][1]):
- if one_ssd==ssd_c_pri:
- indeks_before_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)-40)
- indeks_after_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)+140)
- if indeks_after_c<len(dict_interpolated_ts_left_SFG[id_s_r]) and indeks_before_c>0:
- if one_ssd not in dict_waves_c:
- dict_waves_c[one_ssd]=[dict_interpolated_ts_left_SPR[id_s_r][indeks_before_c:indeks_after_c]]
- else:
- dict_waves_c[one_ssd].append(dict_interpolated_ts_left_SPR[id_s_r][indeks_before_c:indeks_after_c])
- new_dict_waves_c={ssd_s_ic:dict_waves_c[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- new_dict_waves_ic={ssd_s_ic:dict_waves_ic[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- dict_subtraction_left_SFG[id_s_r]=[new_dict_waves_ic, new_dict_waves_c]
- # %%
- dict_subtraction_right_insula = {}
- for id_s_r, dict_values_stop in dict_onsets_100.items():
- if id_s_r in dict_interpolated_ts_right_insula:
- stop_incorrect_ssds=np.unique(dict_values_stop['stop_incorrect'][1])
- stop_correct_ssds = np.unique(dict_values_stop['stop_correct'][1])
- ssds=[ssd_ic for ssd_ic in stop_incorrect_ssds if ssd_ic in stop_correct_ssds]
- dict_waves_ic = {}
- dict_waves_c = {}
- for num_one, one_ssd in enumerate(ssds):
- for num,ssd_ic_pri in enumerate(dict_values_stop['stop_incorrect'][1]):
- if one_ssd==ssd_ic_pri:
- indeks_before_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)-40)
- indeks_after_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)+140)
- if indeks_before_ic>0 and indeks_after_ic<len(dict_interpolated_ts_right_insula[id_s_r]):
- if one_ssd not in dict_waves_ic:
- dict_waves_ic[one_ssd]=[(dict_interpolated_ts_right_insula[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num])]
- else:
- dict_waves_ic[one_ssd].append((dict_interpolated_ts_right_insula[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num]))
- for num2,ssd_c_pri in enumerate(dict_values_stop['stop_correct'][1]):
- if one_ssd==ssd_c_pri:
- indeks_before_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)-40)
- indeks_after_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)+140)
- if indeks_after_c<len(dict_interpolated_ts_right_insula[id_s_r]) and indeks_before_c>0:
- if one_ssd not in dict_waves_c:
- dict_waves_c[one_ssd]=[dict_interpolated_ts_right_insula[id_s_r][indeks_before_c:indeks_after_c]]
- else:
- dict_waves_c[one_ssd].append(dict_interpolated_ts_right_insula[id_s_r][indeks_before_c:indeks_after_c])
- new_dict_waves_c={ssd_s_ic:dict_waves_c[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- new_dict_waves_ic={ssd_s_ic:dict_waves_ic[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- dict_subtraction_right_insula[id_s_r]=[new_dict_waves_ic, new_dict_waves_c]
- # %%
- dict_subtraction_right_lingual = {}
- for id_s_r, dict_values_stop in dict_onsets_100.items():
- if id_s_r in dict_interpolated_ts_right_lingual:
- stop_incorrect_ssds=np.unique(dict_values_stop['stop_incorrect'][1])
- stop_correct_ssds = np.unique(dict_values_stop['stop_correct'][1])
- ssds=[ssd_ic for ssd_ic in stop_incorrect_ssds if ssd_ic in stop_correct_ssds]
- dict_waves_ic = {}
- dict_waves_c = {}
- for num_one, one_ssd in enumerate(ssds):
- for num,ssd_ic_pri in enumerate(dict_values_stop['stop_incorrect'][1]):
- if one_ssd==ssd_ic_pri:
- indeks_before_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)-40)
- indeks_after_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)+140)
- if indeks_before_ic>0 and indeks_after_ic<len(dict_interpolated_ts_right_lingual[id_s_r]):
- if one_ssd not in dict_waves_ic:
- dict_waves_ic[one_ssd]=[(dict_interpolated_ts_right_lingual[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num])]
- else:
- dict_waves_ic[one_ssd].append((dict_interpolated_ts_right_lingual[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num]))
- for num2,ssd_c_pri in enumerate(dict_values_stop['stop_correct'][1]):
- if one_ssd==ssd_c_pri:
- indeks_before_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)-40)
- indeks_after_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)+140)
- if indeks_after_c<len(dict_interpolated_ts_right_lingual[id_s_r]) and indeks_before_c>0:
- if one_ssd not in dict_waves_c:
- dict_waves_c[one_ssd]=[dict_interpolated_ts_right_lingual[id_s_r][indeks_before_c:indeks_after_c]]
- else:
- dict_waves_c[one_ssd].append(dict_interpolated_ts_right_lingual[id_s_r][indeks_before_c:indeks_after_c])
- new_dict_waves_c={ssd_s_ic:dict_waves_c[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- new_dict_waves_ic={ssd_s_ic:dict_waves_ic[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- dict_subtraction_right_lingual[id_s_r]=[new_dict_waves_ic, new_dict_waves_c]
- # %%
- dict_subtraction_right_supramarginal = {}
- for id_s_r, dict_values_stop in dict_onsets_100.items():
- if id_s_r in dict_interpolated_ts_right_supramarginal:
- stop_incorrect_ssds=np.unique(dict_values_stop['stop_incorrect'][1])
- stop_correct_ssds = np.unique(dict_values_stop['stop_correct'][1])
- ssds=[ssd_ic for ssd_ic in stop_incorrect_ssds if ssd_ic in stop_correct_ssds]
- dict_waves_ic = {}
- dict_waves_c = {}
- for num_one, one_ssd in enumerate(ssds):
- for num,ssd_ic_pri in enumerate(dict_values_stop['stop_incorrect'][1]):
- if one_ssd==ssd_ic_pri:
- indeks_before_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)-40)
- indeks_after_ic=int(np.round(dict_values_stop['stop_incorrect'][0][num]+one_ssd)+140)
- if indeks_before_ic>0 and indeks_after_ic<len(dict_interpolated_ts_right_supramarginal[id_s_r]):
- if one_ssd not in dict_waves_ic:
- dict_waves_ic[one_ssd]=[(dict_interpolated_ts_right_supramarginal[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num])]
- else:
- dict_waves_ic[one_ssd].append((dict_interpolated_ts_right_supramarginal[id_s_r][indeks_before_ic:indeks_after_ic],dict_values_stop['stop_incorrect'][2][num]))
- for num2,ssd_c_pri in enumerate(dict_values_stop['stop_correct'][1]):
- if one_ssd==ssd_c_pri:
- indeks_before_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)-40)
- indeks_after_c=int(np.round(dict_values_stop['stop_correct'][0][num2]+one_ssd)+140)
- if indeks_after_c<len(dict_interpolated_ts_right_supramarginal[id_s_r]) and indeks_before_c>0:
- if one_ssd not in dict_waves_c:
- dict_waves_c[one_ssd]=[dict_interpolated_ts_right_supramarginal[id_s_r][indeks_before_c:indeks_after_c]]
- else:
- dict_waves_c[one_ssd].append(dict_interpolated_ts_right_supramarginal[id_s_r][indeks_before_c:indeks_after_c])
- new_dict_waves_c={ssd_s_ic:dict_waves_c[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- new_dict_waves_ic={ssd_s_ic:dict_waves_ic[ssd_s_ic] for ssd_s_ic in dict_waves_ic if ssd_s_ic in dict_waves_c}
- dict_subtraction_right_supramarginal[id_s_r]=[new_dict_waves_ic, new_dict_waves_c]
- # %%
- #averaging subtraction waves in given ROis
- # %%
- dict_subtraction_mean_SFG = {id_s_r:[list_dicts_stops[0],{ssd:np.mean(list_ts,axis=0) for ssd, list_ts in list_dicts_stops[1].items()}] for id_s_r, list_dicts_stops in dict_subtraction_SFG.items()}
- # %%
- dict_subtraction_mean_left_insula = {id_s_r:[list_dicts_stops[0],{ssd:np.mean(list_ts,axis=0) for ssd, list_ts in list_dicts_stops[1].items()}] for id_s_r, list_dicts_stops in dict_subtraction_left_insula.items()}
- # %%
- dict_subtraction_mean_left_SPR = {id_s_r:[list_dicts_stops[0],{ssd:np.mean(list_ts,axis=0) for ssd, list_ts in list_dicts_stops[1].items()}] for id_s_r, list_dicts_stops in dict_subtraction_left_SPR.items()}
- # %%
- dict_subtraction_mean_left_supramarginal = {id_s_r:[list_dicts_stops[0],{ssd:np.mean(list_ts,axis=0) for ssd, list_ts in list_dicts_stops[1].items()}] for id_s_r, list_dicts_stops in dict_subtraction_left_supramarginal.items()}
- # %%
- dict_subtraction_mean_right_insula = {id_s_r:[list_dicts_stops[0],{ssd:np.mean(list_ts,axis=0) for ssd, list_ts in list_dicts_stops[1].items()}] for id_s_r, list_dicts_stops in dict_subtraction_right_insula.items()}
- # %%
- dict_subtraction_mean_right_lingual = {id_s_r:[list_dicts_stops[0],{ssd:np.mean(list_ts,axis=0) for ssd, list_ts in list_dicts_stops[1].items()}] for id_s_r, list_dicts_stops in dict_subtraction_right_lingual.items()}
- # %%
- dict_subtraction_mean_right_supramarginal = {id_s_r:[list_dicts_stops[0],{ssd:np.mean(list_ts,axis=0) for ssd, list_ts in list_dicts_stops[1].items()}] for id_s_r, list_dicts_stops in dict_subtraction_right_supramarginal.items()}
- # %%
- # preapring subtraction waves for visualization
- # %%
- dict_subtraction_wave_SFG = {id_s_r:{ssd_s_ic:[(one_ts[0] - list_dics_stop[1][ssd_s_ic],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_SFG.items()}
- dict_subtraction_wave2_SFG = {id_s_r:{ssd_s_ic:[([one_ts[0],list_dics_stop[1][ssd_s_ic]],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_SFG.items()}
- list_subtraction_all_waves_SFG = [one_ts[0] for id_s_r, dict_ssd in dict_subtraction_wave_SFG.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- list_subtraction_all_waves2_SFG = [[one_ts[0][0],one_ts[0][1]] for id_s_r, dict_ssd in dict_subtraction_wave2_SFG.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- # %%
- dict_subtraction_wave_left_insula = {id_s_r:{ssd_s_ic:[(one_ts[0] - list_dics_stop[1][ssd_s_ic],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_left_insula.items()}
- dict_subtraction_wave2_left_insula = {id_s_r:{ssd_s_ic:[([one_ts[0],list_dics_stop[1][ssd_s_ic]],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_left_insula.items()}
- list_subtraction_all_waves_left_insula = [one_ts[0] for id_s_r, dict_ssd in dict_subtraction_wave_left_insula.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- list_subtraction_all_waves2_left_insula = [[one_ts[0][0],one_ts[0][1]] for id_s_r, dict_ssd in dict_subtraction_wave2_left_insula.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- # %%
- dict_subtraction_wave_left_SPR = {id_s_r:{ssd_s_ic:[(one_ts[0] - list_dics_stop[1][ssd_s_ic],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_left_SPR.items()}
- dict_subtraction_wave2_left_SPR = {id_s_r:{ssd_s_ic:[([one_ts[0],list_dics_stop[1][ssd_s_ic]],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_left_SPR.items()}
- list_subtraction_all_waves_left_SPR = [one_ts[0] for id_s_r, dict_ssd in dict_subtraction_wave_left_SPR.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- list_subtraction_all_waves2_left_SPR = [[one_ts[0][0],one_ts[0][1]] for id_s_r, dict_ssd in dict_subtraction_wave2_left_SPR.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- # %%
- dict_subtraction_wave_left_supramarginal = {id_s_r:{ssd_s_ic:[(one_ts[0] - list_dics_stop[1][ssd_s_ic],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_left_supramarginal.items()}
- dict_subtraction_wave2_left_supramarginal = {id_s_r:{ssd_s_ic:[([one_ts[0],list_dics_stop[1][ssd_s_ic]],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_left_supramarginal.items()}
- list_subtraction_all_waves_left_supramarginal = [one_ts[0] for id_s_r, dict_ssd in dict_subtraction_wave_left_supramarginal.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- list_subtraction_all_waves2_left_supramarginal = [[one_ts[0][0],one_ts[0][1]] for id_s_r, dict_ssd in dict_subtraction_wave2_left_supramarginal.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- # %%
- dict_subtraction_wave_right_insula = {id_s_r:{ssd_s_ic:[(one_ts[0] - list_dics_stop[1][ssd_s_ic],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_right_insula.items()}
- dict_subtraction_wave2_right_insula = {id_s_r:{ssd_s_ic:[([one_ts[0],list_dics_stop[1][ssd_s_ic]],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_right_insula.items()}
- list_subtraction_all_waves_right_insula = [one_ts[0] for id_s_r, dict_ssd in dict_subtraction_wave_right_insula.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- list_subtraction_all_waves2_right_insula = [[one_ts[0][0],one_ts[0][1]] for id_s_r, dict_ssd in dict_subtraction_wave2_right_insula.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- # %%
- dict_subtraction_wave_right_lingual = {id_s_r:{ssd_s_ic:[(one_ts[0] - list_dics_stop[1][ssd_s_ic],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_right_lingual.items()}
- dict_subtraction_wave2_right_lingual = {id_s_r:{ssd_s_ic:[([one_ts[0],list_dics_stop[1][ssd_s_ic]],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_right_lingual.items()}
- list_subtraction_all_waves_right_lingual = [one_ts[0] for id_s_r, dict_ssd in dict_subtraction_wave_right_lingual.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- list_subtraction_all_waves2_right_lingual = [[one_ts[0][0],one_ts[0][1]] for id_s_r, dict_ssd in dict_subtraction_wave2_right_lingual.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- # %%
- dict_subtraction_wave_right_supramarginal = {id_s_r:{ssd_s_ic:[(one_ts[0] - list_dics_stop[1][ssd_s_ic],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_right_supramarginal.items()}
- dict_subtraction_wave2_right_supramarginal = {id_s_r:{ssd_s_ic:[([one_ts[0],list_dics_stop[1][ssd_s_ic]],one_ts[1]) for one_ts in list_ts] for (ssd_s_ic, list_ts) in list_dics_stop[0].items()} for id_s_r, list_dics_stop in dict_subtraction_mean_right_supramarginal.items()}
- list_subtraction_all_waves_right_supramarginal = [one_ts[0] for id_s_r, dict_ssd in dict_subtraction_wave_right_supramarginal.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- list_subtraction_all_waves2_right_supramarginal = [[one_ts[0][0],one_ts[0][1]] for id_s_r, dict_ssd in dict_subtraction_wave2_right_supramarginal.items() for ssd, list_ts in dict_ssd.items() for one_ts in list_ts]
- # %%
- #additional measurments of subtraction waves
- # %%
- mean_ts_SFG = np.mean(list_subtraction_all_waves_SFG,axis=0)
- std_ts_SFG = np.std(list_subtraction_all_waves_SFG,axis=0)
- down_ts_SFG = mean_ts_SFG - 1.96*(std_ts_SFG/np.sqrt(len(list_subtraction_all_waves_SFG)))
- up_ts_SFG = mean_ts_SFG + 1.96*(std_ts_SFG/np.sqrt(len(list_subtraction_all_waves_SFG)))
- # %%
- mean_ts_left_insula = np.mean(list_subtraction_all_waves_left_insula,axis=0)
- std_ts_left_insula = np.std(list_subtraction_all_waves_left_insula,axis=0)
- down_ts_left_insula = mean_ts_left_insula - 1.96*(std_ts_left_insula/np.sqrt(len(list_subtraction_all_waves_left_insula)))
- up_ts_left_insula = mean_ts_left_insula + 1.96*(std_ts_left_insula/np.sqrt(len(list_subtraction_all_waves_left_insula)))
- # %%
- mean_ts_left_SPR = np.mean(list_subtraction_all_waves_left_SPR,axis=0)
- std_ts_left_SPR = np.std(list_subtraction_all_waves_left_SPR,axis=0)
- down_ts_left_SPR = mean_ts_left_SPR - 1.96*(std_ts_left_SPR/np.sqrt(len(list_subtraction_all_waves_left_SPR)))
- up_ts_left_SPR = mean_ts_left_SPr + 1.96*(std_ts_left_SPR/np.sqrt(len(list_subtraction_all_waves_left_SPR)))
- # %%
- mean_ts_left_supramarginal = np.mean(list_subtraction_all_waves_left_supramarginal,axis=0)
- std_ts_left_supramarginal = np.std(list_subtraction_all_waves_left_supramarginal,axis=0)
- down_ts_left_supramarginal = mean_ts_left_supramarginal - 1.96*(std_ts_left_supramarginal/np.sqrt(len(list_subtraction_all_waves_left_supramarginal)))
- up_ts_left_supramarginal = mean_ts_left_supramarginal + 1.96*(std_ts_left_supramarginal/np.sqrt(len(list_subtraction_all_waves_left_supramarginal)))
- # %%
- mean_ts_right_insula = np.mean(list_subtraction_all_waves_right_insula,axis=0)
- std_ts_right_insula = np.std(list_subtraction_all_waves_right_insula,axis=0)
- down_ts_right_insula = mean_ts_right_insula - 1.96*(std_ts_right_insula/np.sqrt(len(list_subtraction_all_waves_right_insula)))
- up_ts_right_insula = mean_ts_right_insula + 1.96*(std_ts_right_insula/np.sqrt(len(list_subtraction_all_waves_right_insula)))
- # %%
- mean_ts_right_lingual = np.mean(list_subtraction_all_waves_right_lingual,axis=0)
- std_ts_right_lingual = np.std(list_subtraction_all_waves_right_lingual,axis=0)
- down_ts_right_lingual = mean_ts_right_lingual - 1.96*(std_ts_right_lingual/np.sqrt(len(list_subtraction_all_waves_right_lingual)))
- up_ts_right_lingual = mean_ts_right_lingual + 1.96*(std_ts_right_lingual/np.sqrt(len(list_subtraction_all_waves_right_lingual)))
- # %%
- mean_ts_right_supramarginal = np.mean(list_subtraction_all_waves_right_supramarginal,axis=0)
- std_ts_right_supramarginal = np.std(list_subtraction_all_waves_right_supramarginal,axis=0)
- down_ts_right_supramarginal = mean_ts_right_supramarginal - 1.96*(std_ts_right_supramarginal/np.sqrt(len(list_subtraction_all_waves_right_supramarginal)))
- up_ts_right_supramarginal = mean_ts_right_supramarginal + 1.96*(std_ts_right_supramarginal/np.sqrt(len(list_subtraction_all_waves_right_supramarginal)))
- # %%
- #stop incorrect and correct waves
- # %%
- mean_ts_sic_SFG = np.mean(np.array(list_subtraction_all_waves2_SFG)[:,0,:], axis=0)
- std_ts_sic_SFG = np.std(np.array(list_subtraction_all_waves2_SFG)[:,0,:], axis=0)
- down_ts_sic_SFG = mean_ts_sic_SFG - 1.96*(std_ts_sic_SFG/np.sqrt(len(list_subtraction_all_waves2_SFG)))
- up_ts_sic_SFG = mean_ts_sic_SFG + 1.96*(std_ts_sic_SFG/np.sqrt(len(list_subtraction_all_waves2_SFG)))
- mean_ts_sc_SFG = np.mean(np.array(list_subtraction_all_waves2_SFG)[:,1,:], axis=0)
- std_ts_sc_SFG = np.std(np.array(list_subtraction_all_waves2_SFG)[:,1,:], axis=0)
- down_ts_sc_SFG = mean_ts_sc_SFG - 1.96*(std_ts_sc_SFG/np.sqrt(len(list_subtraction_all_waves2_SFG)))
- up_ts_sc_SFG = mean_ts_sc_SFG + 1.96*(std_ts_sc_SFG/np.sqrt(len(list_subtraction_all_waves2_SFG)))
- # %%
- mean_ts_sic_left_insula = np.mean(np.array(list_subtraction_all_waves2_left_insula)[:,0,:], axis=0)
- std_ts_sic_left_insula = np.std(np.array(list_subtraction_all_waves2_left_insula)[:,0,:], axis=0)
- down_ts_sic_left_insula = mean_ts_sic_left_insula - 1.96*(std_ts_sic_left_insula/np.sqrt(len(list_subtraction_all_waves2_left_insula)))
- up_ts_sic_left_insula = mean_ts_sic_left_insula + 1.96*(std_ts_sic_left_insula/np.sqrt(len(list_subtraction_all_waves2_left_insula)))
- mean_ts_sc_left_insula = np.mean(np.array(list_subtraction_all_waves2_left_insula)[:,1,:], axis=0)
- std_ts_sc_left_insula = np.std(np.array(list_subtraction_all_waves2_left_insula)[:,1,:], axis=0)
- down_ts_sc_left_insula = mean_ts_sc_left_insula - 1.96*(std_ts_sc_left_insula/np.sqrt(len(list_subtraction_all_waves2_left_insula)))
- up_ts_sc_left_insula = mean_ts_sc_left_insula + 1.96*(std_ts_sc_left_insula/np.sqrt(len(list_subtraction_all_waves2_left_insula)))
- # %%
- mean_ts_sic_left_SPR = np.mean(np.array(list_subtraction_all_waves2_left_SPR)[:,0,:], axis=0)
- std_ts_sic_left_SPR = np.std(np.array(list_subtraction_all_waves2_left_SPR)[:,0,:], axis=0)
- down_ts_sic_left_SPR = mean_ts_sic_left_SPR - 1.96*(std_ts_sic_left_SPR/np.sqrt(len(list_subtraction_all_waves2_left_SPR)))
- up_ts_sic_left_SPR = mean_ts_sic_left_SPR + 1.96*(std_ts_sic_left_SPR/np.sqrt(len(list_subtraction_all_waves2_left_SPR)))
- mean_ts_sc_left_SPR = np.mean(np.array(list_subtraction_all_waves2_left_SPR)[:,1,:], axis=0)
- std_ts_sc_left_SPR = np.std(np.array(list_subtraction_all_waves2_left_SPr)[:,1,:], axis=0)
- down_ts_sc_left_SPR = mean_ts_sc_left_SPR - 1.96*(std_ts_sc_left_SPR/np.sqrt(len(list_subtraction_all_waves2_left_SPR)))
- up_ts_sc_left_SPR = mean_ts_sc_left_SPr + 1.96*(std_ts_sc_left_SPR/np.sqrt(len(list_subtraction_all_waves2_left_SPR)))
- # %%
- mean_ts_sic_left_supramarginal = np.mean(np.array(list_subtraction_all_waves2_left_supramarginal)[:,0,:], axis=0)
- std_ts_sic_left_supramarginal = np.std(np.array(list_subtraction_all_waves2_left_supramarginal)[:,0,:], axis=0)
- down_ts_sic_left_supramarginal = mean_ts_sic_left_supramarginal - 1.96*(std_ts_sic_left_supramarginal/np.sqrt(len(list_subtraction_all_waves2_left_supramarginal)))
- up_ts_sic_left_supramarginal = mean_ts_sic_left_supramarginal + 1.96*(std_ts_sic_left_supramarginal/np.sqrt(len(list_subtraction_all_waves2_left_supramarginal)))
- mean_ts_sc_left_supramarginal = np.mean(np.array(list_subtraction_all_waves2_left_supramarginal)[:,1,:], axis=0)
- std_ts_sc_left_supramarginal = np.std(np.array(list_subtraction_all_waves2_left_supramarginal)[:,1,:], axis=0)
- down_ts_sc_left_supramarginal = mean_ts_sc_left_supramarginal - 1.96*(std_ts_sc_left_supramarginal/np.sqrt(len(list_subtraction_all_waves2_left_supramarginal)))
- up_ts_sc_left_supramarginal = mean_ts_sc_left_supramarginal + 1.96*(std_ts_sc_left_supramarginal/np.sqrt(len(list_subtraction_all_waves2_left_supramarginal)))
- # %%
- mean_ts_sic_right_insula = np.mean(np.array(list_subtraction_all_waves2_right_insula)[:,0,:], axis=0)
- std_ts_sic_right_insula = np.std(np.array(list_subtraction_all_waves2_right_insula)[:,0,:], axis=0)
- down_ts_sic_right_insula = mean_ts_sic_right_insula - 1.96*(std_ts_sic_right_insula/np.sqrt(len(list_subtraction_all_waves2_right_insula)))
- up_ts_sic_right_insula = mean_ts_sic_right_insula + 1.96*(std_ts_sic_right_insula/np.sqrt(len(list_subtraction_all_waves2_right_insula)))
- mean_ts_sc_right_insula = np.mean(np.array(list_subtraction_all_waves2_right_insula)[:,1,:], axis=0)
- std_ts_sc_right_insula = np.std(np.array(list_subtraction_all_waves2_right_insula)[:,1,:], axis=0)
- down_ts_sc_right_insula = mean_ts_sc_right_insula - 1.96*(std_ts_sc_right_insula/np.sqrt(len(list_subtraction_all_waves2_right_insula)))
- up_ts_sc_right_insula = mean_ts_sc_right_insula + 1.96*(std_ts_sc_right_insula/np.sqrt(len(list_subtraction_all_waves2_right_insula)))
- # %%
- mean_ts_sic_right_lingual = np.mean(np.array(list_subtraction_all_waves2_right_lingual)[:,0,:], axis=0)
- std_ts_sic_right_lingual = np.std(np.array(list_subtraction_all_waves2_right_lingual)[:,0,:], axis=0)
- down_ts_sic_right_lingual = mean_ts_sic_right_lingual - 1.96*(std_ts_sic_right_lingual/np.sqrt(len(list_subtraction_all_waves2_right_lingual)))
- up_ts_sic_right_lingual = mean_ts_sic_right_lingual + 1.96*(std_ts_sic_right_lingual/np.sqrt(len(list_subtraction_all_waves2_right_lingual)))
- mean_ts_sc_right_lingual = np.mean(np.array(list_subtraction_all_waves2_right_lingual)[:,1,:], axis=0)
- std_ts_sc_right_lingual = np.std(np.array(list_subtraction_all_waves2_right_lingual)[:,1,:], axis=0)
- down_ts_sc_right_lingual = mean_ts_sc_right_lingual - 1.96*(std_ts_sc_right_lingual/np.sqrt(len(list_subtraction_all_waves2_right_lingual)))
- up_ts_sc_right_lingual = mean_ts_sc_right_lingual + 1.96*(std_ts_sc_right_lingual/np.sqrt(len(list_subtraction_all_waves2_right_lingual)))
- # %%
- mean_ts_sic_right_supramarginal = np.mean(np.array(list_subtraction_all_waves2_right_supramarginal)[:,0,:], axis=0)
- std_ts_sic_right_supramarginal = np.std(np.array(list_subtraction_all_waves2_right_supramarginal)[:,0,:], axis=0)
- down_ts_sic_right_supramarginal = mean_ts_sic_right_supramarginal - 1.96*(std_ts_sic_right_supramarginal/np.sqrt(len(list_subtraction_all_waves2_right_supramarginal)))
- up_ts_sic_right_supramarginal = mean_ts_sic_right_supramarginal + 1.96*(std_ts_sic_right_supramarginal/np.sqrt(len(list_subtraction_all_waves2_right_supramarginal)))
- mean_ts_sc_right_supramarginal = np.mean(np.array(list_subtraction_all_waves2_right_supramarginal)[:,1,:], axis=0)
- std_ts_sc_right_supramarginal = np.std(np.array(list_subtraction_all_waves2_right_supramarginal)[:,1,:], axis=0)
- down_ts_sc_right_supramarginal = mean_ts_sc_right_supramarginal - 1.96*(std_ts_sc_right_supramarginal/np.sqrt(len(list_subtraction_all_waves2_right_supramarginal)))
- up_ts_sc_right_supramarginal = mean_ts_sc_right_supramarginal + 1.96*(std_ts_sc_right_supramarginal/np.sqrt(len(list_subtraction_all_waves2_right_supramarginal)))
- # %%
- #plotting difference wave
- # %%
- plt.figure(figsize=(20,10), facecolor = 'white')
- plt.plot(x_time/10, mean_ts_SFG, color = 'green', label='Mean difference', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_SFG, up_ts_SFG, color ='lightgreen', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.axvspan(5, 7, alpha=0.1, color='blue', label = 'target activity')
- plt.legend(fontsize = 36)
- # %%
- plt.figure(figsize=(20,10))
- plt.plot(x_time/10, mean_ts_left_insula, color = 'green', label='Mean difference', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_left_insula, up_ts_left_insula, color ='lightgreen', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.axvspan(5, 7, alpha=0.1, color='blue', label = 'target activity')
- plt.legend(fontsize = 36)
- # %%
- plt.figure(figsize=(20,10))
- plt.plot(x_time/10, mean_ts_left_SPR, color = 'green', label='Mean difference', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_left_SPR, up_ts_left_SPR, color ='lightgreen', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.axvspan(5, 7, alpha=0.1, color='blue', label = 'target activity')
- plt.legend(fontsize = 36)
- # %%
- plt.figure(figsize=(20,10))
- plt.plot(x_time/10, mean_ts_left_supramarginal, color = 'green', label='Mean difference', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_left_supramarginal, up_ts_left_supramarginal, color ='lightgreen', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.axvspan(5, 7, alpha=0.1, color='blue', label = 'target activity')
- plt.legend(fontsize = 36)
- # %%
- plt.figure(figsize=(20,10))
- plt.plot(x_time/10, mean_ts_right_insula, color = 'green', label='Mean difference', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_right_insula, up_ts_right_insula, color ='lightgreen', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.axvspan(5, 7, alpha=0.1, color='blue', label = 'target activity')
- plt.legend(fontsize = 36)
- # %%
- plt.figure(figsize=(20,10))
- plt.plot(x_time/10, mean_ts_right_insula, color = 'green', label='Mean difference', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_right_insula, up_ts_right_insula, color ='lightgreen', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.axvspan(5, 7, alpha=0.1, color='blue', label = 'target activity')
- plt.legend(fontsize = 36)
- # %%
- plt.figure(figsize=(20,10))
- plt.plot(x_time/10, mean_ts_right_supramarginal, color = 'green', label='Mean difference', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_right_supramarginal, up_ts_right_supramarginal, color ='lightgreen', label='95% confidence interval')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.axvspan(5, 7, alpha=0.1, color='blue', label = 'target activity')
- plt.legend(fontsize = 36)
- # %%
- #plotting stop correct and stop incorrect waves
- # %%
- plt.figure(figsize=(20,10), facecolor='white')
- plt.plot(x_time/10, mean_ts_sic_SFG, color = 'blue', label ='averaged time series of stop incorrect', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sic_SFG, up_ts_sic_SFG, color='lightblue', label = '95% confidence interval of stop incorrect trials')
- plt.plot(x_time/10, mean_ts_sc_SFG, color = '#DD4800', label = ' averaged time series of stop correct', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sc_SFG, up_ts_sc_SFG, color=(1.0, 0.5, 0.0, 0.5), label = '95% confidence interval of stop correct trials')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 24)
- plt.rcParams["figure.facecolor"] = "w"
- # %%
- plt.figure(figsize=(20,10))
- plt.plot(x_time/10, mean_ts_sic_left_insula, color = 'blue', label ='averaged time series of stop incorrect', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sic_left_insula, up_ts_sic_left_insula, color='lightblue', label = '95% confidence interval of stop incorrect trials')
- plt.plot(x_time/10, mean_ts_sc_left_insula, color = '#DD4800', label = ' averaged time series of stop correct', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sc_left_insula, up_ts_sc_left_insula, color=(1.0, 0.5, 0.0, 0.5), label = '95% confidence interval of stop correct trials')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 24)
- # %%
- plt.figure(figsize=(20,10))
- plt.plot(x_time/10, mean_ts_sic_left_SPR, color = 'blue', label ='averaged time series of stop incorrect', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sic_left_SPR, up_ts_sic_left_SPR, color='lightblue', label = '95% confidence interval of stop incorrect trials')
- plt.plot(x_time/10, mean_ts_sc_left_SPR, color = '#DD4800', label = ' averaged time series of stop correct', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sc_left_SPR, up_ts_sc_left_SPR, color=(1.0, 0.5, 0.0, 0.5), label = '95% confidence interval of stop correct trials')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 24)
- # %%
- plt.figure(figsize=(20,10))
- plt.plot(x_time/10, mean_ts_sic_left_supramarginal, color = 'blue', label ='averaged time series of stop incorrect', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sic_left_supramarginal, up_ts_sic_left_supramarginal, color='lightblue', label = '95% confidence interval of stop incorrect trials')
- plt.plot(x_time/10, mean_ts_sc_left_supramarginal, color = '#DD4800', label = ' averaged time series of stop correct', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sc_left_supramarginal, up_ts_sc_left_supramarginal, color=(1.0, 0.5, 0.0, 0.5), label = '95% confidence interval of stop correct trials')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 24)
- # %%
- plt.figure(figsize=(20,10))
- plt.plot(x_time/10, mean_ts_sic_right_insula, color = 'blue', label ='averaged time series of stop incorrect', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sic_right_insula, up_ts_sic_right_insula, color='lightblue', label = '95% confidence interval of stop incorrect trials')
- plt.plot(x_time/10, mean_ts_sc_right_insula, color = '#DD4800', label = ' averaged time series of stop correct', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sc_right_insula, up_ts_sc_right_insula, color=(1.0, 0.5, 0.0, 0.5), label = '95% confidence interval of stop correct trials')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 24)
- # %%
- plt.figure(figsize=(20,10))
- plt.plot(x_time/10, mean_ts_sic_right_lingual, color = 'blue', label ='averaged time series of stop incorrect', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sic_right_lingual, up_ts_sic_right_lingual, color='lightblue', label = '95% confidence interval of stop incorrect trials')
- plt.plot(x_time/10, mean_ts_sc_right_lingual, color = '#DD4800', label = ' averaged time series of stop correct', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sc_right_lingual, up_ts_sc_right_lingual, color=(1.0, 0.5, 0.0, 0.5), label = '95% confidence interval of stop correct trials')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 18)
- # %%
- plt.figure(figsize=(20,10))
- plt.plot(x_time/10, mean_ts_sic_right_supramarginal, color = 'blue', label ='averaged time series of stop incorrect', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sic_right_supramarginal, up_ts_sic_right_supramarginal, color='lightblue', label = '95% confidence interval of stop incorrect trials')
- plt.plot(x_time/10, mean_ts_sc_right_supramarginal, color = '#DD4800', label = ' averaged time series of stop correct', linewidth = 2.5)
- plt.fill_between(x_time/10, down_ts_sc_right_supramarginal, up_ts_sc_right_supramarginal, color=(1.0, 0.5, 0.0, 0.5), label = '95% confidence interval of stop correct trials')
- plt.xlabel('time around stop signal', fontsize=36)
- plt.xticks(fontsize = 36)
- plt.ylabel('BOLD units \n difference between conditions', fontsize=36)
- plt.yticks(fontsize = 36)
- plt.axvline(x=0, color='red' ,linewidth='4')
- plt.legend(fontsize = 24)
- # %%
- # testing difference between stop incorrect and stop correct waves
- # %%
- scipy.stats.ttest_rel(np.mean(np.array(list_subtraction_all_waves2_SFG)[:,0,:][:,90:110], axis = 1), np.mean(np.array(list_subtraction_all_waves2_SFG)[:,1,:][:,90:110], axis = 1))
- # %%
- scipy.stats.ttest_rel(np.mean(np.array(list_subtraction_all_waves2_left_insula)[:,0,:][:,90:110], axis = 1), np.mean(np.array(list_subtraction_all_waves2_left_insula)[:,1,:][:,90:110], axis = 1))
- # %%
- scipy.stats.ttest_rel(np.mean(np.array(list_subtraction_all_waves2_left_supramarginal)[:,0,:][:,90:110], axis = 1), np.mean(np.array(list_subtraction_all_waves2_left_supramarginal)[:,1,:][:,90:110], axis = 1))
- # %%
- scipy.stats.ttest_rel(np.mean(np.array(list_subtraction_all_waves2_left_SPR)[:,0,:][:,90:110], axis = 1), np.mean(np.array(list_subtraction_all_waves2_left_SPR)[:,1,:][:,90:110], axis = 1))
- # %%
- scipy.stats.ttest_rel(np.mean(np.array(list_subtraction_all_waves2_right_insula)[:,0,:][:,90:110], axis = 1), np.mean(np.array(list_subtraction_all_waves2_right_insula)[:,1,:][:,90:110], axis = 1))
- # %%
- scipy.stats.ttest_rel(np.mean(np.array(list_subtraction_all_waves2_right_supramarginal)[:,0,:][:,90:110], axis = 1), np.mean(np.array(list_subtraction_all_waves2_right_supramarginal)[:,1,:][:,90:110], axis = 1))
- # %%
- scipy.stats.ttest_rel(np.mean(np.array(list_subtraction_all_waves2_right_lingual)[:,0,:][:,90:110], axis = 1), np.mean(np.array(list_subtraction_all_waves2_right_lingual)[:,1,:][:,90:110], axis = 1))
- # %%
- #Computing variables for models of relationship between BOLD and sri and sst
- # %%
- def create_df_for_region(dict_region,dict_interpolated_ts_region, start_time, stop_time, baseline_long_start, baseline_long_end, SSRT_dict, directory_save):
- all_events_list_region = []
- for id_s_r, dict_ssd_subtract_wave in dict_region.items():
- for ssd_value, list_ts in dict_ssd_subtract_wave.items():
- for num, (ts, rt) in enumerate(list_ts):
- indices_peaks = [x for x in scipy.signal.find_peaks(ts)[0] if x>start_time and x<stop_time]
- peak_value=[sorted([ts[y] for y in indices_peaks])[0] if len(indices_peaks)>0 else []][0]
- print([abs((start_time + (start_time-stop_time)/2)-y) for y in indices_peaks])
- peak_value_closest=[ts[sorted([int(abs((start_time + (start_time-stop_time)/2)-y)) for y in indices_peaks])[0]] if len(indices_peaks)>0 else []][0]
- general_baseline = np.mean((dict_interpolated_ts_region[id_s_r]))
- valueBOLD = np.mean(ts[start_time:stop_time])
- amplitudeBOLD = valueBOLD - np.mean(ts[baseline_long_start:baseline_long_end])
- amplitudeBOLD_peak = peak_value -np.mean(ts[baseline_long_start:baseline_long_end])
- amplitudeBOLD_peak_closest = peak_value_closest -np.mean(ts[baseline_long_start:baseline_long_end])
- amplitudeBOLD2 = valueBOLD - general_baseline
- amplitudeBOLD2_peak = peak_value - general_baseline
- amplitudeBOLD2_peak_closest = peak_value_closest - general_baseline
- list_events = [re.findall(r'sub-\d{2}', id_s_r)[0], re.findall(r'run-\d{2}', id_s_r)[0], ssd_value, rt, valueBOLD, np.mean(ts[:40]), general_baseline, amplitudeBOLD, amplitudeBOLD2, amplitudeBOLD_peak, amplitudeBOLD2_peak, amplitudeBOLD_peak_closest, amplitudeBOLD2_peak_closest, rt - ssd_value]
- all_events_list_region.append(list_events)
- df_data_region = pd.DataFrame(all_events_list_region)
- df_data_region.columns = ['subject', 'run', 'ssd', 'rt', 'BOLD_value_in_peak', 'baseline1', 'general_baseline','amplitude_eeg', 'amplitude_general', 'amplitude_eeg_peak', 'amplitude_general_peak', 'amplitude_eeg_peak_closest', 'amplitude_general_peak_closest', 'sri']
- df_data_region['SSRT'] = [SSRT_dict[one_sub + '_' + df_data_region['run'][num]]*10 for num, one_sub in enumerate(list(df_data_region['subject']))]
- df_data_region['rtSSRT'] = df_data_region['rt']-df_data_region['SSRT']
- df_data_region['slower_than_SSRT'] = df_data_region['rt']>df_data_region['SSRT']
- df_data_region.to_csv(directory_save)
- # %%
- def create_files_with_data(dict_directories, start_time, stop_time, baseline_start, baseline_stop, SSRT_dict):
- for keys, values in dict_directories.items():
- create_df_for_region(values[0], values[1], start_time, stop_time, baseline_start, baseline_stop, SSRT_dict, keys+'_'+str(start_time)+'_'+str(stop_time)+'_'+str(baseline_start)+'_'+str(baseline_stop)+'.csv')
- # %%
- dvs=['amplitude_general']
- ivs=['sri' ,'ssd', 'sri+ssd']
- # %%
- def create_model(dv,iv, df_data, variant):
- import statsmodels.api as sm
- import statsmodels.formula.api as smf
- if variant == 1:
- pd.to_numeric(df_data[iv])
- pd.to_numeric(df_data[dv])
- df_data[dv] = [float(i) for i in df_data[dv]]
- md = smf.mixedlm(dv + "~" + iv, df_data, groups=df_data["subject"])
- mdf = md.fit()
- print(mdf.summary())
- plt.scatter(df_data[iv]*100, df_data[dv], color='blue')
- plt.xticks(fontsize = 20, rotation = 90)
- plt.yticks(fontsize = 20)
- iv_vals = np.linspace(df_data[iv].min(), df_data[iv].max(), 100)
- intercept = mdf.params['Intercept']
- slope = mdf.params[iv]
- regression_line = intercept + slope * iv_vals
- plt.plot(iv_vals*100, regression_line, color='red', label='Regression line', linewidth = 6)
- plt.xlabel('stop response interval (SRI)', fontsize = 20) # Replace with your x-axis label
- plt.ylabel('BOLD amplitude', fontsize = 20) # Replace with your y-axis label
- plt.title('Relationship between BOLD and SRI', fontsize = 20)
- plt.show()
- elif variant==2:
- iv_1=re.findall(r'sri',iv)[0]
- iv_2=re.findall(r'ssd',iv)[0]
- pd.to_numeric(df_data[dv])
- pd.to_numeric(df_data[iv_1])
- pd.to_numeric(df_data[iv_2])
- df_data[dv] = [float(i) for i in df_data[dv]]
- md = smf.mixedlm(dv + "~" + iv, df_data, groups=df_data["subject"])
- mdf = md.fit()
- print(mdf.summary())
- elif variant==3:
- iv_1=re.findall(r'rtSSRT',iv)[0]
- iv_2=re.findall(r'ssd',iv)[0]
- pd.to_numeric(df_data[dv])
- pd.to_numeric(df_data[iv_1])
- pd.to_numeric(df_data[iv_2])
- df_data[dv] = [float(i) for i in df_data[dv]]
- md = smf.mixedlm(dv + "~" + iv, df_data, groups=df_data["subject"])
- mdf = md.fit()
- print(mdf.summary())
- elif variant==4:
- iv_1=re.findall(r'ssd',iv)[0]
- iv_2=re.findall(r'STAI',iv)[0]
- pd.to_numeric(df_data[dv])
- pd.to_numeric(df_data[iv_1])
- pd.to_numeric(df_data[iv_2])
- df_data[dv] = [float(i) for i in df_data[dv]]
- md = smf.mixedlm(dv + "~" + iv, df_data, groups=df_data["subject"])
- mdf = md.fit()
- print(mdf.summary())
- # %%
- def create_models(directory_data, dvs, ivs, both_rtSSRT):
- for one_dir in [directory_data + i for i in os.listdir(directory_data) if i[0]!='c']:
- for one_dv in dvs:
- df_data_region=pd.read_csv(one_dir)
- df_data_region['STAI']=[dict_STAI[x] for num, x in enumerate(df_data_region['subject'])]
- print(one_dv)
- if one_dv == 'amplitude_eeg_peak':
- df_data_region = df_data_region.iloc[[num for num, i in enumerate(df_data_region['amplitude_eeg_peak']) if len(re.findall(r'\[',i))==0]]
- elif one_dv == 'amplitude_general_peak':
- df_data_region = df_data_region.iloc[[num for num, i in enumerate(df_data_region['amplitude_general_peak']) if len(re.findall(r'\[',i))==0]]
- elif one_dv == 'amplitude_eeg_peak_closest':
- df_data_region = df_data_region.iloc[[num for num, i in enumerate(df_data_region['amplitude_eeg_peak_closest']) if len(re.findall(r'\[',i))==0]]
- elif one_dv == 'amplitude_general_peak_closest':
- df_data_region = df_data_region.iloc[[num for num, i in enumerate(df_data_region['amplitude_general_peak_closest']) if len(re.findall(r'\[',i))==0]]
- for one_iv in ivs:
- print(one_dir)
- if one_iv == 'sri':
- df_data_region = df_data_region.iloc[[num for num, i in enumerate(list(df_data_region['sri'])) if i<9],:]
- create_model(one_dv, one_iv, df_data_region,1)
- elif one_iv == 'ssd':
- df_data_region = df_data_region.iloc[[num for num, i in enumerate(list(df_data_region['ssd'])) if i<6],:] #abs(i - np.mean(list(df_data_region['ssd'])))<3*np.std(list(df_data_region['ssd']))],:] #
- create_model(one_dv, one_iv, df_data_region,1)
- elif one_iv =='rtSSRT' and both_rtSSRT == True:
- df_data_region_rtSSRT_whole = df_data_region.iloc[[num for num, i in enumerate(list(df_data_region['rtSSRT'])) if i<7.5 and i>-4],:]
- df_data_region_rtSSRT_non_zero = df_data_region.iloc[[num for num, i in enumerate(list(df_data_region['rtSSRT'])) if i>0 and i<7.5],:]
- print("Whole rtSSRT")
- create_model(one_dv, one_iv, df_data_region_rtSSRT_whole,1)
- print("Non zero rtSSRT")
- create_model(one_dv, one_iv, df_data_region_rtSSRT_non_zero,1)
- elif one_iv =='rtSSRT' and both_rtSSRT == False:
- df_data_region_rtSSRT_non_zero = df_data_region.iloc[[num for num, i in enumerate(list(df_data_region['rtSSRT'])) if i>0 and i<7.5],:]
- print("Non zero rtSSRT")
- create_model(one_dv, one_iv, df_data_region_rtSSRT_non_zero,1)
- elif len(re.findall(r'sri',one_iv))!=0 and re.findall(r'sri',one_iv)[0]=='sri' and re.findall(r'ssd',one_iv)[0]=='ssd':
- df_data_region = df_data_region.iloc[[num for num, i in enumerate(list(df_data_region['sri'])) if i<9 and list(df_data_region['ssd'])[num]<6],:]
- create_model(one_dv, one_iv, df_data_region, 2)
- elif len(re.findall(r'rtSSRT',one_iv))!=0 and re.findall(r'rtSSRT',one_iv)[0]=='rtSSRT' and re.findall(r'ssd',one_iv)[0]=='ssd':
- df_data_region = df_data_region.iloc[[num for num, i in enumerate(list(df_data_region['rtSSRT'])) if i>0 and i<7.5 and i>-4 and list(df_data_region['ssd'])[num]>0 and list(df_data_region['ssd'])[num]<6],:]
- create_model(one_dv, one_iv, df_data_region, 3)
- elif len(re.findall(r'ssd',one_iv))!=0 and re.findall(r'ssd',one_iv)[0]=='ssd' and re.findall(r'STAI',one_iv)[0]=='STAI':
- print('tutaj')
- df_data_region = df_data_region.iloc[[num for num, i in enumerate(list(df_data_region['ssd'])) if abs(i - np.mean(list(df_data_region['ssd'])))<3*np.std(list(df_data_region['ssd']))],:]
- df_data_region = df_data_region.iloc[[num for num, i in enumerate(df_data_region['STAI']) if math.isnan(i)==False],:]
- create_model(one_dv, one_iv, df_data_region, 4)
- # %%
- dict_STAI={'sub-01':float('NaN'),
- 'sub-02':float('NaN'),
- 'sub-03':float('NaN'),
- 'sub-04':float('NaN'),
- 'sub-05':float('NaN'),
- 'sub-06':float('NaN'),
- 'sub-07':33,
- 'sub-08':43,
- 'sub-09':49,
- 'sub-10':31,
- 'sub-11':30,
- 'sub-12':35,
- 'sub-13':38,
- 'sub-14':44,
- 'sub-15':42,
- 'sub-16':57,
- 'sub-17':24,
- 'sub-18':39,
- 'sub-19':49,
- 'sub-20':33,
- 'sub-21':40,
- 'sub-22':37,
- 'sub-23':52,
- 'sub-24':42,
- 'sub-25':46,
- 'sub-26':42,
- 'sub-27':44,
- 'sub-28':65,
- 'sub-29':35,
- 'sub-30':32,
- 'sub-31':29,
- 'sub-32':34,
- 'sub-33':43,
- 'sub-34':55,
- 'sub-35':39,
- 'sub-36':50,
- 'sub-37':35,
- 'sub-38':50,
- 'sub-39':43,
- 'sub-40':38,
- 'sub-41':38,
- 'sub-42':35,
- 'sub-43':32,
- 'sub-44':40,
- 'sub-45':36,
- 'sub-46':36,
- 'sub-47':34,
- 'sub-48':33,
- 'sub-49':50,
- 'sub-50':49}
- # %%
- dict_STAI={'sub-01':float('NaN'),
- 'sub-02':float('NaN'),
- 'sub-03':float('NaN'),
- 'sub-04':float('NaN'),
- 'sub-05':float('NaN'),
- 'sub-06':float('NaN'),
- 'sub-07':33,
- 'sub-08':43,
- 'sub-09':49,
- 'sub-10':31,
- 'sub-11':30,
- 'sub-12':35,
- 'sub-13':38,
- 'sub-14':44,
- 'sub-15':42,
- 'sub-16':57,
- 'sub-17':24,
- 'sub-18':39,
- 'sub-19':49,
- 'sub-20':33,
- 'sub-21':40,
- 'sub-22':37,
- 'sub-23':52,
- 'sub-24':42,
- 'sub-25':46,
- 'sub-26':42,
- 'sub-27':44,
- 'sub-28':65,
- 'sub-29':35,
- 'sub-30':32,
- 'sub-31':29,
- 'sub-32':34,
- 'sub-33':43,
- 'sub-34':55,
- 'sub-35':39,
- 'sub-36':50,
- 'sub-37':35,
- 'sub-38':50,
- 'sub-39':43,
- 'sub-40':38,
- 'sub-41':38,
- 'sub-42':35,
- 'sub-43':32,
- 'sub-44':40,
- 'sub-45':36,
- 'sub-46':36,
- 'sub-47':34,
- 'sub-48':33,
- 'sub-49':50,
- 'sub-50':49}
- # %%
- create_models(<directory_to_ROIS results>n, dvs, ivs, True)
Behavioral & fMRI analysis.ipynb, no license · at the source
Overview
- Institute of Psychology, Jagiellonian University, 6 Ingarden Street, 30-060 Cracow, Poland
- Doctoral School of Social Sciences, Jagiellonian University, 34 Main Square, 31-010 Cracow, Poland
- Department of Psychology, SWPS University, 39a Jan Paweł II Avenue, 31-864 Cracow, Poland
- Centre for Cognitive Science, Jagiellonian University, 3 Ingarden Street, 30-060 Cracow, Poland
Abstract
The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.
Repository
Its files are read in the Code ↔ Paper reader above.
OSF aum96
Availability: 1 check, the latest on 30 September 2026: the link answers (HTTP 200)
- 30 September 2026: the link answers (HTTP 200)
4 files
- scripts/
Behavioral & fMRI analysis.ipynb , Jupyter, 1,795 lines - scripts/
contrasts.m , MATLAB, 91 lines - scripts/
first_level_modified.m , MATLAB, 111 lines - scripts/
second_level.m , MATLAB, 86 lines
The paper's code and data availability statement is in the Data section.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 4 scripts, each with its path and the digest of its content;
- no match between paragraphs and code yet;
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
No dataset and no data link were found in the paper.
Code and data availability statement
The paper has a code and data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- it points to the authors' code: OSF aum96
Read it in the paper: doi.org/10.1038/s41598-026-42784-6.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 30 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 4 authors, 7 keywords, 11 MeSH terms, 2 funders, 59 references.
Cite
This paper
Bielski, K., Wichary, S., Nęcka, E., & Senderecka, M. (2026). Distinguishing between response conflict and error expectancy in inhibitory error processing: the role of the presupplementary motor cortex. Scientific reports, 16(1), 12321. https://
BibTeX
@article{bielski2026dist
author = {Bielski, Krzysztof and Wichary, Szymon and Nęcka, Edward and Senderecka, Magdalena},
title = {{Distinguishing between response conflict and error expectancy in inhibitory error processing: the role of the presupplementary motor cortex}},
journal = {Scientific reports},
year = {2026},
month = mar,
volume = {16},
number = {1},
pages = {12321},
publisher = {Nature Publishing Group},
issn = {2045-2322},
doi = {10.1038/
url = {https://
pmid = {41792218},
pmcid = {PMC13079758}
}
RIS
TY - JOUR
AU - Bielski, Krzysztof
AU - Wichary, Szymon
AU - Nęcka, Edward
AU - Senderecka, Magdalena
TI - Distinguishing between response conflict and error expectancy in inhibitory error processing: the role of the presupplementary motor cortex
T2 - Scientific reports
J2 - Sci Rep
PY - 2026
DA - 2026/
VL - 16
IS - 1
SP - 12321
SN - 2045-2322
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Distinguishing between response conflict and error expectancy in inhibitory error processing: the role of the presupplementary motor cortex",
"container-title": "Scientific reports",
"author": [
{
"family": "Bielski",
"given": "Krzysztof"
},
{
"family": "Wichary",
"given": "Szymon"
},
{
"family": "Nęcka",
"given": "Edward"
},
{
"family": "Senderecka",
"given": "Magdalena"
}
],
"container-title-short":
"volume": "16",
"issue": "1",
"page": "12321",
"DOI": "10.1038/
"PMID": "41792218",
"PMCID": "PMC13079758",
"ISSN": "2045-2322",
"publisher": "Nature Publishing Group",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
6
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1371/journal.pbio.3003856 [code]
- Aging and metabolism contribute separately to brain-body health.Journal: PLoS biologyIn common: SPM, NiBabel, statsmodels, 5 other tools, 1 reference
- [2] doi:10.1038/s41467-026-76452-0 [code]
- Music evokes shared neural representations of imagined narratives across sensory modalities.Journal: Nature communicationsIn common: SPM, NiBabel, statsmodels, 5 other tools, 1 reference
- [3] doi:10.1038/s41467-026-71963-2 [code]
- Spinal cord structural and functional architecture and its shared organization with the brain across the adult lifespan.Journal: Nature communicationsIn common: SPM, NiBabel, statsmodels, 5 other tools, 1 reference
- [4] doi:10.1038/s41467-026-71568-9 [code]
- Convergent and selective representations of pain, appetitive processes, aversive processes, and cognitive control in the insula.Journal: Nature communicationsIn common: SPM, NiBabel, statsmodels, 5 other tools, 1 reference
- [5] doi:10.1038/s41467-026-71151-2 [code]
- Common and distinct neural correlates of social interaction processing and theory of mind in narratives.Journal: Nature communicationsIn common: SPM, NiBabel, statsmodels, 5 other tools, 1 reference
- [6] doi:10.1016/j.neuron.2026.04.011 [code]
- Precision fMRI reveals densely interdigitated network patches with conserved motifs in the lateral prefrontal cortex.Journal: NeuronIn common: SPM, NiBabel, scikit-learn, 3 other tools, fMRI, 2 references
- [7] doi:10.1038/s41598-026-56688-y [code]
- On the value of radiomics in addition to clinical measures in emotional conflict fMRI for predicting sertraline response in major depressive disorder.Journal: Scientific reportsIn common: SPM, NiBabel, statsmodels, 5 other tools, fMRI
- [8] doi:10.1016/j.nicl.2026.104012 [code]
- Structural-functional multilayer brain network properties and outcome of combined repetitive transcranial magnetic stimulation and psychotherapy for obsessive-compulsive disorder.Journal: NeuroImage. ClinicalIn common: SPM, NiBabel, statsmodels, 5 other tools, fMRI
- [9] doi:10.1038/s41597-026-07377-y [code]
- An open-access multi-site fMRI dataset for investigating conscious visual perception.Journal: Scientific dataIn common: SPM, NiBabel, statsmodels, 5 other tools, fMRI
- [10] doi:10.7554/elife.107933 [code]
- Modality-agnostic decoding of vision and language from fMRI.Journal: eLifeIn common: SPM, NiBabel, statsmodels, 5 other tools, fMRI
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 4 scripts, and 0 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:c48f7fee47095010…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[.
Discussion, reproductions, activity
Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.
Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
