Brain regions beyond the visual cortex are relevant to subjective time prediction from fMRI salient events in a visual naturalistic context.
The 3 matches
- [1] § Results › Approach 1: prediction of normalized bias from salient events ↔ Robustness.ipynb, lines 301 to 362 · score 0.63 · Cingulo Opercular, Dorsal Attention, Fraction, Frontoparietal, model bias, AUD · Report a mismatch
- [2] § Methodology › Approach 2: prediction of normalized bias from bold time-series ↔ SVM_REDES+LSTM.ipynb, lines 1042 to 1095 · score 0.61 · cross validation, PyTorch, sequences, padded, batch, LSTM · Report a mismatch
- [3] § Results › Approach 1: prediction of normalized bias from salient events ↔ Robustness.ipynb, lines 301 to 362 · score 0.56 · cingulo opercular, dorsal attention, somatomotor, model bias, auditory, correlations · Report a mismatch
Paper
Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Jupyter notebook · 538 lines · 23 KB · no license · 2 matches
- # %%
- """
- Transform accumulated changes from fMRI layers into durations (s) using
- multiclass SVM
- """
- # %% [markdown]
- # # IMPORT LIBS AND DATA
- # %%
- from sklearn.svm import SVR
- import pandas as pd
- import numpy as np
- from sklearn.model_selection import KFold
- from sklearn.metrics import mean_squared_error
- from math import sqrt
- import scipy.io as sio
- import scipy.stats as stats
- import os.path as op
- import os
- from sklearn.base import clone
- import matplotlib.pyplot as plt
- import statsmodels.api as sm
- from scipy.stats import chi2
- # import pymc3 as pm
- outdir = 'D:\\ERICK\\MD\\prediction_data\\'
- datadir = 'D:\\ERICK\\MD\\'
- load_file = op.join(datadir, 'master_dataset.csv')
- data = pd.read_csv(load_file)
- # %% [markdown]
- # # SVM
- # %%
- # RESTING-STATE NETWORKS
- #create training data from salient events
- resdir = 'D:\\ERICK\\MD\\Results\\'
- excluded = [41, 45] # corrupted data
- regions = ['rNet1', 'rNet2', 'rNet3', 'rNet6', 'rNet7', 'rNet8', 'rNet11']
- netKey = {
- 'rNet1': 'vis',
- 'rNet2': 'smn',
- 'rNet3': 'cing',
- 'rNet6': 'dmn',
- 'rNet7': 'fpn',
- 'rNet8': 'aud',
- # 'rNet9': 'aud2',
- 'rNet11': 'dan',
- }
- regions = [netKey[reg] for reg in regions]
- for i, tmax in enumerate(np.linspace(0, 3, 50)):
- if tmax % 1 == 0:
- tmax = int(tmax)
- for j, tmin in enumerate(np.linspace(-3,0,50)):
- print('----------------------------------------------')
- print(f'tmax = {tmax} and tmin = {tmin}')
- if tmin % 1 == 0:
- tmin = int(tmin)
- for region in regions:
- new_id = 1
- df_region = []
- save_dir = op.join(outdir, 'Robustness', str(i+1), str(j+1))
- save_path = op.join(save_dir, '{}.csv'.format(region))
- if not op.isdir(save_dir):
- os.makedirs(save_dir)
- for subject in range(4, 45):
- if subject in excluded:
- continue
- data_net = {'subj': [], 'duration': [], 'isCity': [], 'report': [], 'humanBias': [], 'estimationError': []}
- for rd_max in range(3, 7):
- for rd_min in range(3, 7):
- text = f'tmax={np.round(tmax, rd_max)}_tmin={np.round(tmin, rd_min)}'
- datafile = op.join(resdir, str(subject), 'Robustness', region,
- f'accum_changes_{region}_{text}.mat')
- if op.isfile(datafile):
- df = sio.loadmat(datafile)
- df = df['d'][0][0]
- h = len(df[0])
- hb = data.loc[data['rawSubjID']==subject, 'humanBias']
- error = data.loc[data['rawSubjID']==subject, 'estimationError']
- data_net['subj'].extend([new_id] * h)
- data_net['duration'].extend(df[4].reshape(h))
- data_net['isCity'].extend(df[2].reshape(h))
- data_net['report'].extend(df[1].reshape(h))
- data_net['humanBias'].extend(hb)
- data_net['estimationError'].extend(error)
- data_net['acc_se'] = df[0].reshape(h)
- new_df = pd.DataFrame(data_net)
- df_region.append(new_df)
- break
- if op.isfile(datafile):
- break
- new_id = new_id + 1
- # Salvando
- df = pd.concat(df_region, ignore_index=True)
- df.to_csv(save_path, sep=',', encoding='utf-8')
- # df_visual = pd.concat(df_visual, ignore_index=True)
- # df_auditory = pd.concat(df_auditory, ignore_index=True)
- # df_somatosensory = pd.concat(df_somatosensory, ignore_index=True)
- # %%
- # HIERARCHICAL DATA
- #create training data from salient events
- load_file = op.join(datadir, 'master_dataset.csv')
- data = pd.read_csv(load_file)
- resdir = 'D:\\ERICK\\MD\\Results\\'
- excluded = [41, 45]
- regions = {'visual': ['rLOC', 'rV1', 'rVO'], 'auditory': ['rBA1', 'rBA2', 'rBA3'], 'somatosensory': ['rBA22', 'rBA41', 'rBA42']}
- layers = [1, 2, 3]
- for i, tmax in enumerate(np.linspace(0, 3, 50)):
- if tmax % 1 == 0:
- tmax = int(tmax)
- for j, tmin in enumerate(np.linspace(-3,0,50)):
- print('----------------------------------------------')
- print(f'tmax = {tmax} and tmin = {tmin}')
- if tmin % 1 == 0:
- tmin = int(tmin)
- for region in regions:
- new_id = 1
- df_region = []
- save_dir = op.join(outdir, 'Robustness', str(i+1), str(j+1))
- save_path = op.join(save_dir, '{}.csv'.format(region))
- if not op.isdir(save_dir):
- os.makedirs(save_dir)
- for subject in range(4, 45):
- if subject in excluded:
- continue
- print(subject)
- data_layers = {'subj': [], 'duration': [], 'isCity': [], 'report': [], 'humanBias': [], 'estimationError': []}
- for layer in layers:
- for rd_max in range(3, 7):
- for rd_min in range(3, 7):
- text = f'tmax={np.round(tmax, rd_max)}_tmin={np.round(tmin, rd_min)}'
- datafile = op.join(resdir, str(subject), 'Robustness', regions[region][layer-1],
- f'accum_changes_{regions[region][layer-1]}_{text}.mat')
- if op.isfile(datafile):
- df = sio.loadmat(datafile)
- df = df['d'][0][0]
- h = len(df[0])
- hb = data.loc[data['rawSubjID']==subject, 'humanBias']
- error = data.loc[data['rawSubjID']==subject, 'estimationError']
- if layer==1:
- data_layers['subj'].extend([new_id] * h)
- data_layers['duration'].extend(df[4].reshape(h))
- data_layers['isCity'].extend(df[2].reshape(h))
- data_layers['report'].extend(df[1].reshape(h))
- data_layers['humanBias'].extend(hb)
- data_layers['estimationError'].extend(error)
- data_layers['l{}'.format(layer)] = df[0].reshape(h)
- break
- if op.isfile(datafile):
- break
- new_df = pd.DataFrame(data_layers)
- df_region.append(new_df)
- new_id = new_id + 1
- # Salvando
- df = pd.concat(df_region, ignore_index=True)
- df.to_csv(save_path, sep=',', encoding='utf-8')
- # df_visual = pd.concat(df_visual, ignore_index=True)
- # df_auditory = pd.concat(df_auditory, ignore_index=True)
- # df_somatosensory = pd.concat(df_somatosensory, ignore_index=True)
- # %%
- data
- # %%
- data_type = 'hierarchical'
- if data_type == 'hierarchical':
- files = ["visual", "auditory","somatosensory"]
- elif data_type == 'rs_nets':
- files = ['vis', 'smn', 'cing', 'dmn', 'fpn', 'aud', 'dan']
- for i, tmax in enumerate(np.linspace(0, 3, 50)):
- for j, tmin in enumerate(np.linspace(-3, 0, 50)):
- print(f'tmax: {i+1} and tmin: {j+1}')
- for region in files:
- print(region)
- load_file = op.join(outdir, 'Robustness', str(i+1), str(j+1), '{}.csv'.format(region))
- save_file = op.join(outdir, 'Robustness', str(i+1), str(j+1), 'predicted_{}.csv'.format(region))
- if not op.isfile(save_file):
- print(save_file)
- data = pd.read_csv(load_file, sep=',')
- if data_type == 'hierarchical':
- accumulated_changes = np.array(pd.concat([data.l1 , data.l2, data.l3],axis=1))
- elif data_type == 'rs_nets':
- accumulated_changes = np.array(data.acc_se).reshape(-1, 1)
- duration=np.ravel(data.duration)
- regressor = SVR(kernel='rbf', C=1e3, gamma=0.0001)
- regressor.fit(accumulated_changes, duration)
- predicted = regressor.predict(accumulated_changes)
- if data_type == 'hierarchical':
- output = np.array(pd.concat([data.subj,data.duration,data.isCity,data.report, data.humanBias, data.estimationError,
- pd.Series(predicted), data.l1,data.l2,data.l3],axis=1))
- output = pd.DataFrame(output, columns=['subj', 'duration', 'isCity', 'report', 'humanBias', 'estimationError',
- 'predicted','l1', 'l2', 'l3'])
- elif data_type == 'rs_nets':
- output = np.array(pd.concat([data.subj,data.duration,data.isCity,data.report, data.humanBias,
- pd.Series(predicted), data.acc_se],axis=1))
- output = pd.DataFrame(output, columns=['subj', 'duration', 'isCity', 'report', 'humanBias', 'predicted', 'acc_se'])
- output.to_csv(save_file, sep=',', encoding='utf-8')
- # %%
- #calculate model bias for each subject
- data_type = 'hierarchical'
- if data_type == 'hierarchical':
- files = ["visual", "auditory","somatosensory"]
- elif data_type == 'rs_nets':
- files = ['vis', 'smn', 'cing', 'dmn', 'fpn', 'aud', 'dan']
- durations = [8, 12, 16, 20, 24]
- dur_dic = {8:0, 12:1, 16:2, 20:3, 24:4}
- excluded = [36, 40] #considerando novo id
- for i, tmax in enumerate(np.linspace(0, 3, 50)):
- for j, tmin in enumerate(np.linspace(-3, 0, 50)):
- print(f'tmax: {i+1} and tmin: {j+1}')
- if data_type == 'hierarchical':
- modelBias_off = {'visual':[], 'auditory':[], 'somatosensory':[]}
- modelBias_city = {'visual':[], 'auditory':[], 'somatosensory':[]}
- avgmb_diff = {'visual':[], 'auditory':[], 'somatosensory':[]}
- modelBias_all = {'visual':[], 'auditory':[], 'somatosensory':[]}
- avgmb_all = {'visual':[], 'auditory':[], 'somatosensory':[]}
- avgmb_c = {'visual':[], 'auditory':[], 'somatosensory':[]}
- avgmb_o = {'visual':[], 'auditory':[], 'somatosensory':[]}
- elif data_type == 'rs_nets':
- modelBias_off = {'vis':[], 'smn':[], 'cing':[], 'dmn':[], 'fpn':[], 'aud':[], 'dan':[]}
- modelBias_city = {'vis':[], 'smn':[], 'cing':[], 'dmn':[], 'fpn':[], 'aud':[], 'dan':[]}
- avgmb_diff = {'vis':[], 'smn':[], 'cing':[], 'dmn':[], 'fpn':[], 'aud':[], 'dan':[]}
- modelBias_all = {'vis':[], 'smn':[], 'cing':[], 'dmn':[], 'fpn':[], 'aud':[], 'dan':[]}
- avgmb_all = {'vis':[], 'smn':[], 'cing':[], 'dmn':[], 'fpn':[], 'aud':[], 'dan':[]}
- avgmb_c = {'vis':[], 'smn':[], 'cing':[], 'dmn':[], 'fpn':[], 'aud':[], 'dan':[]}
- avgmb_o = {'vis':[], 'smn':[], 'cing':[], 'dmn':[], 'fpn':[], 'aud':[], 'dan':[]}
- n = 40 # Tamanho da amostra
- # outdir = 'D:\\ERICK\\MD\\predictions (ORIGINAL)\\'
- for region in files:
- print(region)
- load_file = op.join(outdir, 'Robustness', str(i+1), str(j+1), 'predicted_{}.csv'.format(region))
- data = pd.read_csv(load_file)
- for subj in range(1, 41):
- subset_c = data.loc[(data['subj'] == subj) & (data['isCity'] == 1)]
- subset_o = data.loc[(data['subj'] == subj) & (data['isCity'] == 0)]
- subset = data.loc[(data['subj'] == subj)]
- mb_subcity = []
- mb_suboff = []
- mb_suball = []
- for dur in durations:
- mean_dur = subset.groupby('duration')['predicted'].mean().tolist()
- for ind, row in subset.iterrows():
- modelrep = row['predicted']
- md_idx = dur_dic[row['duration']]
- model_bias = 100*(modelrep-mean_dur[md_idx])/mean_dur[md_idx]
- mb_suball.append(model_bias)
- modelBias_all[region].append(model_bias)
- for ind, row in subset_c.iterrows():
- modelrep = row['predicted']
- md_idx = dur_dic[row['duration']]
- model_bias = 100*(modelrep-mean_dur[md_idx])/mean_dur[md_idx]
- mb_subcity.append(model_bias)
- modelBias_city[region].append(model_bias)
- for ind, row in subset_o.iterrows():
- modelrep = row['predicted']
- md_idx = dur_dic[row['duration']]
- model_bias = 100*(modelrep-mean_dur[md_idx])/mean_dur[md_idx]
- mb_suboff.append(model_bias)
- modelBias_off[region].append(model_bias)
- #calculate diff
- diff = np.mean(mb_subcity)-np.mean(mb_suboff)
- avgmb_diff[region].append(diff)
- avgmb_c[region].append(np.mean(mb_subcity))
- avgmb_o[region].append(np.mean(mb_suboff))
- avgmb_all[region].append(np.mean(mb_suball))
- #overwrite file
- data['modelBias'] = modelBias_all[region]
- data.to_csv(load_file, sep=',', encoding='utf-8')
- # %%
- import seaborn as sns
- import matplotlib.colors as mcolors
- # outdir = 'D:\\ERICK\\MD\\predictions (ORIGINAL)\\'
- # files = {'vis': 'visual', 'smn': 'somatomotor', 'cing': 'cingulo-opercular', 'dmn': 'default mode',
- # 'fpn': 'frontoparietal', 'aud': 'auditory', 'dan': 'dorsal-attention'}
- files = {'vis':"visual", 'aud':"auditory", 'smn':"somatosensory"}
- excluded = [40]
- sig_fraction = {}
- corrs = {}
- for region in files:
- sig_count = 0
- total_count = 0
- heatmap = {'tmax': [], 'tmin': [], 'p-value': []}
- corr_list = []
- for i, tmax in enumerate(np.linspace(0, 3, 50)):
- for j, tmin in enumerate(np.linspace(-3, 0, 50)):
- total_count += 1
- heatmap['tmax'].append(tmax)
- heatmap['tmin'].append(tmin)
- model_file = op.join(outdir, 'Robustness', str(i+1), str(j+1), 'predicted_{}.csv'.format(region))
- model_data = pd.read_csv(model_file)
- mask = model_data['subj'].isin(excluded)
- model_data = model_data[~mask]
- #Regressão => bias (human) = B0 + B1 * bias (model)
- x = model_data['modelBias']
- y = model_data['humanBias']
- rho, p = stats.pearsonr(x, y)
- modelo = sm.OLS(y, sm.add_constant(x)).fit()
- p_value = modelo.f_pvalue/2
- beta = modelo.params.iloc[1]
- if p_value < 0.001:
- p_value = 0.001
- if p_value < 0.05 and beta>0 :
- sig_count += 1
- corr_list.append(rho)
- heatmap['p-value'].append(p_value)
- hm = pd.DataFrame(heatmap)
- fig, ax = plt.subplots(figsize=(5, 3))
- tmax_vals = np.linspace(0, 3, 50)
- tmin_vals = np.linspace(-3, 0, 50)
- pvalue_matrix = np.reshape(hm['p-value'].values, (50, 50))
- contourf = ax.contourf(tmin_vals, tmax_vals, pvalue_matrix, cmap='jet_r', levels=np.logspace(-3, 0, 51), norm=mcolors.LogNorm())
- cbar = plt.colorbar(contourf)
- cbar.set_ticks([0.001, 0.01, 0.1, 1])
- ax.set_title(files[region], fontsize=15)
- ax.set_ylabel('Upper Bound (SD)', fontsize=15)
- ax.set_xlabel('Lower Bound (SD)', fontsize=15)
- plt.show()
- sig_fraction[files[region]] = sig_count/total_count
- corrs[files[region]] = corr_list
- # print('Fraction of ssig_count_countificant values:', sig_fraction)
- # %%
- fig, axs = plt.subplots(1, 2, figsize=(8, 3))
- corrs_data = [corrs[files[region]] for region in files]
- # Criar uma paleta de cores (ex: viridis com 3 cores)
- cmap = plt.cm.get_cmap('cividis', len(files))
- colors = [cmap(i) for i in range(len(files))]
- for i, region in enumerate(files):
- axs[0].bar(region, sig_fraction[files[region]], label=region, color=colors[i])
- box = axs[1].boxplot(corrs_data, labels=files, patch_artist=True)
- # Adicionar cores diferentes às caixas do boxplot
- for patch, color in zip(box['boxes'], colors):
- patch.set_facecolor(color)
- axs[0].set_ylabel('Significant $\\beta_1$ values (%)')
- axs[1].set_ylabel('Pearson-r')
- plt.subplots_adjust(wspace=0.4)
- # %%
- sig_fraction
- # %% [markdown]
- # # FIG 5
- # %%
- import warnings
- warnings.filterwarnings("ignore")
- # outdir = 'D:\\ERICK\\MD\\predictions (ORIGINAL)\\'
- files = ["visual","auditory","somatosensory"]
- columns = ['Região', 'Viés de duração', '95% IC', 'chi-quadrado', 'valor-p']
- df = pd.DataFrame(columns=columns)
- for region in files:
- print('--------------------------------')
- print(region)
- model_file = op.join(outdir, 'predicted_{}.csv'.format(region))
- model_data = pd.read_csv(model_file)
- # #plot model bias hist
- # plt.hist(model_data['modelBias'])
- # plt.show()
- #Regressão => bias (human) = B0 + B1 * bias (model)
- x = model_data['modelBias']
- y = model_data['humanBias']
- #corr
- rho,p = stats.spearmanr(x, y)
- print('Correlation between human and model bias: r = {:.2f}, p = {:.3f}'
- .format(rho, p))
- modelo = sm.OLS(y, sm.add_constant(x)).fit()
- print('Linear Regression between human and model bias: beta = {:.2f} ± {:.2f}, p = {:.3f}'
- .format(modelo.params[1], modelo.bse[1], modelo.f_pvalue))
- #EFEITO FIXO = MODEL BIAS
- vc = {'subj': '1 + C(subj)'}
- # Ajustar o modelo reduzido sem o efeito fixo
- model_reduced = sm.MixedLM.from_formula("humanBias ~ 1", vc_formula=vc, data=model_data, groups=model_data['subj'])
- result_reduced = model_reduced.fit()
- # Ajustar o modelo completo com o efeito fixo
- model_full = sm.MixedLM.from_formula("humanBias ~ 1 + modelBias", vc_formula=vc, data=model_data, groups=model_data['subj'])
- result_full = model_full.fit()
- # Calcular a diferença nas log-verossimilhanças
- llf_full = result_full.llf
- llf_reduced = result_reduced.llf
- lrt = -2 * (llf_reduced - llf_full)
- # Calcular o valor p do teste
- p_value = chi2.sf(lrt, 1)
- print('Using model bias as fixed effect: chi-sqr = {:.2f}, p = {:.3f}'
- .format(lrt, p_value))
- #EFEITO FIXO = CENA
- vc = {'subj': '1 + C(subj)'}
- # Ajustar o modelo reduzido sem o efeito fixo
- model_reduced = sm.MixedLM.from_formula("modelBias ~ 1", vc_formula=vc, data=model_data, groups=model_data['subj'])
- result_reduced = model_reduced.fit()
- # Ajustar o modelo completo com o efeito fixo
- model_full = sm.MixedLM.from_formula("modelBias ~ 1 + isCity", vc_formula=vc, data=model_data, groups=model_data['subj'])
- result_full = model_full.fit()
- # Calcular a diferença nas log-verossimilhanças
- llf_full = result_full.llf
- llf_reduced = result_reduced.llf
- lrt = np.round(-2 * (llf_reduced - llf_full), 2)
- # Calcular o valor p do teste
- p_value = np.round(chi2.sf(lrt, 1), 3)
- #calculate and print statistics
- mean = np.round(np.mean(avgmb_diff[region]), 2)
- SE = np.round(np.std(avgmb_diff[region], ddof=1)/np.sqrt(n), 2)
- z = 1.96 # Valor crítico para um intervalo de confiança de 95%
- lower_bound = np.round(mean - (z * SE), 2)
- upper_bound = np.round(mean + (z * SE), 2)
- print('Using scene as fixed effect: M±SEdiff = {:.2f} ± {:.2f} (normalized bias, %), 95% CI [{:.2f}, {:.2f}], chi-sqr = {:.2f}, p = {:.3f}'
- .format(mean, SE, lower_bound, upper_bound, lrt, p_value))
- linha = [region, '{} ± {}'.format(mean, SE), [lower_bound, upper_bound], lrt, p_value]
- df.loc[len(df)] = linha
- outFile = op.join(outdir, 'lmm_table_rep.csv')
- df.to_csv(outFile, sep=',', encoding='utf-8')
- # %%
- # import warnings
- # warnings.filterwarnings("ignore")
- # outdir = 'D:\\ERICK\\MD\\predictions (ORIGINAL)\\'
- # files = ["visual","auditory","somatosensory"]
- # columns = ['Região', 'Viés de duração', '95% IC', 'chi-quadrado', 'valor-p']
- # df = pd.DataFrame(columns=columns)
- # for region in files:
- # print(region)
- # model_file = op.join(outdir, 'predicted_{}.csv'.format(region))
- # model_data = pd.read_csv(model_file)
- # #plot model bias hist
- # plt.hist(model_data['modelBias'])
- # plt.show()
- # orig_file = op.join(datadir, 'master_dataset.csv')
- # orig = pd.read_csv(orig_file)
- # model_data['humanBias'] = orig['humanBias']
- # #EFEITO FIXO = MODEL BIAS
- # vc = {'subj': '1 + C(subj)'}
- # # Ajustar o modelo reduzido sem o efeito fixo
- # model_reduced = sm.MixedLM.from_formula("humanBias ~ 1", vc_formula=vc, data=model_data, groups=model_data['subj'])
- # result_reduced = model_reduced.fit()
- # # Ajustar o modelo completo com o efeito fixo
- # model_full = sm.MixedLM.from_formula("humanBias ~ 1 + modelBias", vc_formula=vc, data=model_data, groups=model_data['subj'])
- # result_full = model_full.fit()
- # # Calcular a diferença nas log-verossimilhanças
- # llf_full = result_full.llf
- # llf_reduced = result_reduced.llf
- # lrt = -2 * (llf_reduced - llf_full)
- # # Calcular o valor p do teste
- # p_value = chi2.sf(lrt, 1)
- # #calculate and print statistics
- # mean = np.mean(avgmb_all[region])
- # SE = np.std(avgmb_all[region], ddof=1)/np.sqrt(n)
- # z = 1.96 # Valor crítico para um intervalo de confiança de 95%
- # lower_bound = mean - (z * SE)
- # upper_bound = mean + (z * SE)
- # print('Using model bias as fixed effect: M±SEdiff = {:.2f} ± {:.2f} (normalized bias, %), 95% CI [{:.2f}, {:.2f}], chi-sqr = {:.2f}, p = {:.3f}'
- # .format(mean, SE, lower_bound, upper_bound, lrt, p_value))
- # #EFEITO FIXO = CENA
- # vc = {'subj': '1 + C(subj)'}
- # # Ajustar o modelo reduzido sem o efeito fixo
- # model_reduced = sm.MixedLM.from_formula("modelBias ~ 1", vc_formula=vc, data=model_data, groups=model_data['subj'])
- # result_reduced = model_reduced.fit()
- # # Ajustar o modelo completo com o efeito fixo
- # model_full = sm.MixedLM.from_formula("modelBias ~ 1 + isCity", vc_formula=vc, data=model_data, groups=model_data['subj'])
- # result_full = model_full.fit()
- # # Calcular a diferença nas log-verossimilhanças
- # llf_full = result_full.llf
- # llf_reduced = result_reduced.llf
- # lrt = np.round(-2 * (llf_reduced - llf_full), 2)
- # # Calcular o valor p do teste
- # p_value = np.round(chi2.sf(lrt, 1), 3)
- # #calculate and print statistics
- # mean = np.round(np.mean(avgmb_diff[region]), 2)
- # SE = np.round(np.std(avgmb_diff[region], ddof=1)/np.sqrt(n), 2)
- # z = 1.96 # Valor crítico para um intervalo de confiança de 95%
- # lower_bound = np.round(mean - (z * SE), 2)
- # upper_bound = np.round(mean + (z * SE), 2)
- # print('Using scene as fixed effect: M±SEdiff = {:.2f} ± {:.2f} (normalized bias, %), 95% CI [{:.2f}, {:.2f}], chi-sqr = {:.2f}, p = {:.3f}'
- # .format(mean, SE, lower_bound, upper_bound, lrt, p_value))
- # linha = [region, '{} ± {}'.format(mean, SE), [lower_bound, upper_bound], lrt, p_value]
- # df.loc[len(df)] = linha
- # outFile = op.join(outdir, 'lmm_table_original.csv')
- # df.to_csv(outFile, sep=',', encoding='utf-8')
Robustness.ipynb at commit 3d40efc, no license · at the source
Overview
- InBrain, Department of Physics, FFCLRP, University of São Paulo, Ribeirão Preto, Brazil
- Department of Medical Imaging, Hematology and Clinical Oncology, FMRP, University of São Paulo, Ribeirão Preto, Brazil
Abstract
Time perception is an essential part of human experience and can be distorted by features of daily stimuli, causing variations relative to actual time. This study aimed to test the hypothesis that subjective time results from the accumulation of salient events and investigate the neural bases of this perceptual processing, while using a publicly available dataset obtained and analyzed in a previous study. Three approaches were used with fMRI data from participants who watched and estimated the duration of silent videos in an MRI scanner. In the first approach, using a functional parcellation of 360 cortical regions, we showed that salient events in functional networks beyond the visual one also had a significant association with subjective time (normalized bias): the dorsal attention network, the cingulo-opercular network, and the somatomotor network. In the second approach, using an Long-Short Term Memory (LSTM) deep learning model, it was not possible to predict normalized bias from fMRI trial-by-trial time series within any functional network. In the last approach, functional connectivity between the 360 cortical regions and within the visual network showed no consistent association with subjective time. The results suggest that regions in additional functional networks may be important for duration quantification in the context of visual stimulation, although the approach based on salient events still requires further validation. Furthermore, features such as functional connectivity and fMRI time-series did not show direct association with the normalized bias.
Supplementary Information: The online version contains supplementary material available at 10.1007/
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 3 matches between paragraphs and lines of code.
inbrainlab/time_perception_fMRI
3d40efcd8698f284840cc4142ea88d9e3822ba6c, 6 June 2025Availability: 1 check, the latest on 30 September 2026: the link answers
- 30 September 2026: the link answers
14 files
- Robustness.ipynb, Jupyter, 538 lines, 2 matches
- SVM-REDES-FC.ipynb, Jupyter, 887 lines
- SVM.ipynb, Jupyter, 1,127 lines
- SVM_REDES+LSTM.ipynb, Jupyter, 1,816 lines, 1 match
- extract_ED_and_SD_from_m
ask.m , MATLAB, 224 lines - extract_ED_and_SD_from_m
ask_RANDOM.m , MATLAB, 201 lines - extract_TS_from_mask.m, MATLAB, 179 lines
- get_accumulated_changes.
m , MATLAB, 198 lines - get_accumulated_changes_
RANDOM.m , MATLAB, 182 lines - get_accumulated_changes_
ROBUSTNESS.m , MATLAB, 196 lines - get_accumulated_changes_
net.m , MATLAB, 179 lines - script_extract.m, MATLAB, 58 lines
- time_corr.m, MATLAB, 63 lines
- README.md, Text, 2 lines
Code availability
All analysis scripts are available at https://
Reproduced under the paper's license (CC BY), from the paper cited above.
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;
- 13 scripts, each with its path and the digest of its content;
- 3 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- 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
Datasets cited
Data availability
The dataset used in this study was provided by Sherman et al. (2022) and is available for download at the OSF repository https://
Reproduced under the paper's license (CC BY), from the paper cited above.
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, 2 authors, 4 keywords, 15 MeSH terms, 3 funders, 35 references.
Cite
This paper
de Souza, E. A., & Salmon, C. E. G. (2026). Brain regions beyond the visual cortex are relevant to subjective time prediction from fMRI salient events in a visual naturalistic context. Brain imaging and behavior, 20(2), 58. https://
BibTeX
@article{desouza2026brai
author = {de Souza, Erick Almeida and Salmon, Carlos Ernesto Garrido},
title = {{Brain regions beyond the visual cortex are relevant to subjective time prediction from fMRI salient events in a visual naturalistic context}},
journal = {Brain imaging and behavior},
year = {2026},
month = mar,
volume = {20},
number = {2},
pages = {58},
publisher = {Springer Science+Business Media},
issn = {1931-7557},
doi = {10.1007/
url = {https://
pmid = {41863592},
pmcid = {PMC13005859}
}
RIS
TY - JOUR
AU - de Souza, Erick Almeida
AU - Salmon, Carlos Ernesto Garrido
TI - Brain regions beyond the visual cortex are relevant to subjective time prediction from fMRI salient events in a visual naturalistic context
T2 - Brain imaging and behavior
J2 - Brain Imaging Behav
PY - 2026
DA - 2026/
VL - 20
IS - 2
SP - 58
SN - 1931-7557
PB - Springer Science+Business Media
DO - 10.1007/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1007/
"type": "article-journal",
"title": "Brain regions beyond the visual cortex are relevant to subjective time prediction from fMRI salient events in a visual naturalistic context",
"container-title": "Brain imaging and behavior",
"author": [
{
"family": "de Souza",
"given": "Erick Almeida"
},
{
"family": "Salmon",
"given": "Carlos Ernesto Garrido"
}
],
"container-title-short":
"volume": "20",
"issue": "2",
"page": "58",
"DOI": "10.1007/
"PMID": "41863592",
"PMCID": "PMC13005859",
"ISSN": "1931-7557",
"publisher": "Springer Science+Business Media",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
21
]
]
}
}
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.21203/rs.3.rs-9326213/v1 [code]
- Multi-task fMRI outperforms resting-state fMRI for revealing task-invariant organization of the human brainJournal: Research Square (preprint)In common: Nilearn, SPM, NiBabel, 7 other tools, fMRI, cognitive, 3 references
- [2] doi:10.64898/2026.03.09.710558 [code]
- Multi-task fMRI outperforms resting-state fMRI for revealing task-invariant organization of the human brainJournal: bioRxiv (preprint)In common: Nilearn, SPM, NiBabel, 7 other tools, fMRI, cognitive, 3 references
- [3] doi:10.1016/j.neuroimage.2023.120044 [code]
- Comparison between gradients and parcellations for functional connectivity prediction of behavior.Journal: NeuroImageIn common: Nilearn, SPM, NiBabel, 6 other tools, fMRI, 3 references
- [4] doi:10.1016/j.nicl.2022.103139 [code]
- Altered brain network topology in children with auditory processing disorder: A resting-state multi-echo fMRI study.Journal: NeuroImage. ClinicalIn common: Nilearn, SPM, NiBabel, 7 other tools, fMRI, 2 references
- [5] doi:10.1016/j.isci.2025.114212 [code]
- Alpha power indexes working memory load for durations.Journal: iScienceIn common: Nilearn, statsmodels, NiBabel, 6 other tools, cognitive, 2 references
- [6] doi:10.1038/s42003-026-09900-8 [code]
- A multidimensional framework for dissociating the neuroplasticity of auditory and early language deprivation.Journal: Communications biologyIn common: Nilearn, statsmodels, NiBabel, 6 other tools, cognitive, 2 references
- [7] doi:10.1371/journal.pbio.3003704
- Neuronal populations across the cortex underlie discrete, categorical, and subjective representations of visual durations.Journal: PLoS biologyIn common: fMRI, 7 references
- [8] doi:10.34133/bmef.0231 [code]
- Digital Twin Brain: Generating Multitask Behavior from Connectomes for Personalized Therapy.Journal: BME frontiersIn common: Nilearn, statsmodels, PyTorch, 6 other tools, fMRI, 2 references
- [9] doi:10.1002/hbm.26415 [code]
- Accounting for temporal variability in functional magnetic resonance imaging improves prediction of intelligence.Journal: Human brain mappingIn common: PyTorch, pandas, SciPy, 2 other tools, fMRI, 4 references
- [10] doi:10.1371/journal.pbio.3002937 [code]
- The thalamus encodes and updates context representations during hierarchical cognitive control.Journal: PLoS biologyIn common: Nilearn, statsmodels, NiBabel, 6 other tools, cognitive, 1 reference
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, 13 scripts, and 3 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:e31b691ef68a65ba…
Add the badge to the code's README
If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.
Markdown
<!-- oscr-badge:start -->
[](https://openscicode.org/badge/doi/10.1007/s11682-026-01128-8)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.1007/s11682-026-01128-8.svg
:target: https://openscicode.org/badge/doi/10.1007/s11682-026-01128-8
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1007/s11682-026-01128-8"><img src="https://openscicode.org/badge/doi/10.1007/s11682-026-01128-8.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".
If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.
Report a mismatch between the code and the paper · Report a code error (signed in)
Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.
Report a reproduction failure (signed in)
Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
