forked from dagush/WholeBrain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDecoEtAl2018_Prepro_fgain_Neuro.py
78 lines (67 loc) · 3.79 KB
/
DecoEtAl2018_Prepro_fgain_Neuro.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# ==========================================================================
# ==========================================================================
# Computes the Functional Connectivity Dynamics (FCD)
#
# From the original code:
# --------------------------------------------------------------------------
# OPTIMIZATION GAIN
#
# Taken from the code (fgain_Neuro.m) from:
#
# [DecoEtAl_2018] Deco,G., Cruzat,J., Cabral, J., Knudsen,G.M., Carhart-Harris,R.L., Whybrow,P.C., Logothetis,N.K. & Kringelbach,M.L.
# Whole-brain multimodal neuroimaging model using serotonin receptor maps explain non-linear functional effects of LSD
# (2018) Current Biology
# https://www.cell.com/current-biology/pdfExtended/S0960-9822(18)31045-5
#
# Translated to Python & refactoring by Gustavo Patow
# ==========================================================================
# ==========================================================================
# --------------------------------------------------------------------------
# Begin setup...
# --------------------------------------------------------------------------
from DecoEtAl2018_Setup import *
# --------------------------------------------------------------------------
# End setup...
# --------------------------------------------------------------------------
# ==========================================================================
# ==========================================================================
# ==========================================================================
# IMPORTANT: This function was created to reproduce Deco et al.'s 2018 code for Figure 3A.
# Actually, this only performs the fitting which gives the value of we (we in the original
# code, G in the paper) to use for further computations (e.g., plotting Figure 3A)
def prepro_G_Optim():
# %%%%%%%%%%%%%%% Set General Model Parameters
outFilePath = 'Data_Produced/SC90'
J_fileNames = outFilePath + "/J_Balance_we{}.mat"
distanceSettings = {'FC': (FC, False), 'swFCD': (swFCD, True)}
wStart = 0.
step = 0.1 # 0.025
wEnd = 2.5 + step
WEs = np.arange(wStart, wEnd, step) # 100 values values for constant G. Originally was np.arange(0,2.5,0.025)
# Model Simulations
# ------------------------------------------
BalanceFIC.verbose = True
balancedParms = BalanceFIC.Balance_AllJ9(C, WEs, baseName=J_fileNames)
modelParms = [balancedParms[i] for i in balancedParms]
# Now, optimize all we (G) values: determine optimal G to work with
print("\n\n###################################################################")
print("# Compute G_Optim")
print("###################################################################\n")
fitting = optim1D.distanceForAll_Parms(tc_transf_PLA, WEs, modelParms, NumSimSubjects=NumSubjects,
distanceSettings=distanceSettings,
parmLabel='we',
outFilePath=outFilePath, fileNameSuffix='')
optimal = {sd: distanceSettings[sd][0].findMinMax(fitting[sd]) for sd in distanceSettings}
print("Optimal:\n", optimal)
filePath = outFilePath + '/DecoEtAl2018_fneuro.mat'
sio.savemat(filePath, #{'JI': JI})
{'we': WEs,
'fitting_PLA': fitting['FC'], # fitting_PLA,
'FCDfitt_PLA': fitting['swFCD'], # FCDfitt_PLA
}) # save('fneuro.mat','WE','fitting2','fitting5','FCDfitt2','FCDfitt5');
print(f"DONE!!! (file: {filePath})")
if __name__ == '__main__':
prepro_G_Optim()
# ==========================================================================
# ==========================================================================
# ==========================================================================EOF