Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multilayer #4

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2fe6fd5
Import main multilayer code
fnobregasantos Jun 30, 2020
b4184e2
Delete Multilayer
fnobregasantos Jun 30, 2020
adfd102
Created a readme file to guide the users
fnobregasantos Jun 30, 2020
2a737ca
Main codes and a training matrix with MST
fnobregasantos Jun 30, 2020
722bc9f
Included docstrings of some functions
fnobregasantos Jul 8, 2020
50d43a1
Included missing docstrings
fnobregasantos Jul 9, 2020
aae3ebb
Included degree centrality
fnobregasantos Jul 9, 2020
47dcbf9
Included clustering
fnobregasantos Jul 10, 2020
a8ff514
Proofread the code (checking for typos, etc.)
fnobregasantos Jul 30, 2020
18fb13b
Fixing some typos
fnobregasantos Jul 30, 2020
5ca4c7d
Fixing some typos
fnobregasantos Jul 30, 2020
0dee748
Merge branch 'master' into Multilayer
multinetlab Sep 3, 2020
14bad19
Rephrasing
eduardacenteno Sep 7, 2020
58678f9
Correcting style // typos
eduardacenteno Sep 8, 2020
a4bb726
Delete Multilayer_Main_code.py
fnobregasantos Oct 1, 2020
9b06641
Improved code - Now only with main functions
fnobregasantos Oct 1, 2020
07ef534
Preliminary version of the Multilayer_user code
fnobregasantos Oct 1, 2020
95fcfd4
lucas review and readme of fernando's code
lcbreedt Nov 19, 2020
d9f810b
lucas/fernando review and revision of the code
lcbreedt Nov 25, 2020
2c1a130
lucas/fernando review and revision of the code
lcbreedt Nov 25, 2020
523c82f
lucas revision of readme.md
lcbreedt Nov 26, 2020
1e7dc75
lucas revision of readme.md - fixed ToC
lcbreedt Nov 26, 2020
327878a
lucas revision of readme.md - fixed ToC
lcbreedt Nov 26, 2020
c59de00
lucas revision of readme.md - fixed ToC + added sections
lcbreedt Nov 26, 2020
902e848
lucas revision of readme.md - fixed ToC + added sections
lcbreedt Nov 26, 2020
82e4f3c
fixed typo in dataframe
fnobregasantos Sep 9, 2021
a3e7051
The code also reads 2d arrays (not only 3d arrays)
fnobregasantos Oct 13, 2021
2e29a19
The code also accepts 2d arrays as input
fnobregasantos Oct 14, 2021
cbc218d
Comment 1
fnobregasantos Apr 13, 2022
af6dc55
Comment 2
fnobregasantos Apr 13, 2022
2627833
Comment 3
fnobregasantos Apr 13, 2022
4fd7c7f
Comment 4
fnobregasantos Apr 13, 2022
266bf10
Revert old commit
fnobregasantos Apr 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixing some typos
fnobregasantos authored Jul 30, 2020
commit 18fb13be5f6700bd7799145f753f6df7018ea669
58 changes: 39 additions & 19 deletions Multilayer/Multilayer_Main_code.py
Original file line number Diff line number Diff line change
@@ -306,7 +306,7 @@ def MVaggregate(multiple_layers_list, number_layers):



def Group_eingenvector_centrality(Data,list_of_single_layers):
def Group_eigenvector_centrality(Data,list_of_single_layers):

"""Returns a flat list with the aggregate output for EC, given a Data, and a list_of_single_layers

@@ -330,7 +330,7 @@ def Group_eingenvector_centrality(Data,list_of_single_layers):

number_of_individuals=Data[name].shape[2]

Group_eingenvector=[]
Group_eigenvector=[]
for individual in range(number_of_individuals):
temp=multlayerG(individual,Data,list_of_single_layers)

@@ -341,14 +341,34 @@ def Group_eingenvector_centrality(Data,list_of_single_layers):
temp2=MVaggregate(temp1, len(list_of_single_layers))
#temp2=aggregate(temp1,len(list_of_single_layers))
# This is a list of lists with all centralities for all individuals
Group_eingenvector.append(temp2)
Group_eigenvector.append(temp2)
# since we want to buid a flat list
flat_list = [item for sublist in Group_eingenvector for item in sublist]
flat_list = [item for sublist in Group_eigenvector for item in sublist]

return flat_list

def Group_clustering(Data,list_of_single_layers):
"This list will save all the clustering for all individuals"
"""Returns a flat list with the aggregate output for Group clustering, given a Data, and a list_of_single_layers

Parameters
----------
Data : A preloaded .mat - Ex: Supra_MST


list_of_layers: a list of numbers corresponding to the Multilayer you want to create -
Ex: If you want a Multilayer with fmri, pli_delta, pli theta, and pli beta using the tags: 0=fmri', '1=pli delta', '2= pli theta','5 = pli beta'
list_of_layers = [0,1,2,5]

Returns
-------
out: An aggregate list which is the mean of the values of the Clustering per node in each layer

"""





name=list(Data.keys())[-1]

number_of_individuals=Data[name].shape[2]
@@ -476,14 +496,14 @@ def Group_bet_centrality(Data,list_of_single_layers):

"Here comes the mean and standard deviations from all metrics we analized"

def Group_eingenvector_centrality_mean(Data,list_of_single_layers):
def Group_eigenvector_centrality_mean(Data,list_of_single_layers):
#m=multlayerGNew(3,Supra_MST,[0,5,1])
"This list will save all the eigenvector centralities means for all individuals"
name=list(Data.keys())[-1]

number_of_individuals=Data[name].shape[2]

Group_eingenvector_mean=[]
Group_eigenvector_mean=[]
for individual in range(number_of_individuals):
temp=multlayerG(individual,Data,list_of_single_layers)

@@ -494,20 +514,20 @@ def Group_eingenvector_centrality_mean(Data,list_of_single_layers):
temp2=MVaggregate(temp1, len(list_of_single_layers))
#temp2=aggregate(temp1,len(list_of_single_layers))

Group_eingenvector_mean.append(np.mean(temp2))
Group_eigenvector_mean.append(np.mean(temp2))

return (Group_eingenvector_mean)
return (Group_eigenvector_mean)





def Group_eingenvector_centrality_std(Data,list_of_single_layers):
def Group_eigenvector_centrality_std(Data,list_of_single_layers):
"This list will save all the eigenvector centralities stds for all individuals"
name=list(Data.keys())[-1]

number_of_individuals=Data[name].shape[2]
Group_eingenvector_std=[]
Group_eigenvector_std=[]
for individual in range(number_of_individuals):
temp=multlayerG(individual,Data,list_of_single_layers)
m=mx.eigenvector_centrality_numpy(temp)
@@ -517,9 +537,9 @@ def Group_eingenvector_centrality_std(Data,list_of_single_layers):
temp2=MVaggregate(temp1, len(list_of_single_layers)) # This is MV aggregate - we can change then later for something else
#temp2=aggregate(temp1,len(list_of_single_layers))

Group_eingenvector_std.append(np.std(temp2))
Group_eigenvector_std.append(np.std(temp2))

return (Group_eingenvector_std)
return (Group_eigenvector_std)


###############################
@@ -551,7 +571,7 @@ def Plot_Group_EC(Data,list_of_single_layers):

print('layers =',[layer_tags[i] for i in list_of_single_layers])

temp=Group_eingenvector_centrality(Data,list_of_single_layers)
temp=Group_eigenvector_centrality(Data,list_of_single_layers)
plt.figure(figsize=(8,5))
plt.hist(temp)
# We can edit here the output if we have a vector with the name of the layers
@@ -622,7 +642,7 @@ def Plot_EC(individual,Data,list_of_single_layers):



def eingenvectorcentrality(individual,Data,list_of_single_layers):
def eigenvectorcentrality(individual,Data,list_of_single_layers):
print('layers =',[layer_tags[i] for i in list_of_single_layers])
#multlayerG(individual,Data,list_of_single_layers)
m=mx.eigenvector_centrality_numpy(multlayerG(individual,Data,list_of_single_layers))
@@ -723,7 +743,7 @@ def Function_output(function,Data,filename,colname,layers):
# colname='Rando,_No_Mask_Group_MST_Mono_layer_real_'+Layer_dic[i]+'_tag_'+str(i)
# print(filename)
# print(colname)
# function=Group_eingenvector_centrality
# function=Group_eigenvector_centrality
# Data=Supra_MST
# Function_output(function,Data,filename,colname,[i])
# print('we did it')
@@ -739,7 +759,7 @@ def Function_output(function,Data,filename,colname,layers):
# colname='EC_No_Mask_Group_MST_Mono_layer_random_'+Layer_dic[i]+'_tag_'+str(i)
# print(filename)
# print(colname)
# function=Group_eingenvector_centrality
# function=Group_eigenvector_centrality
# Data=Supra_MST_random
# Function_output(function,Data,filename,colname,[i])
# print('we did it')
@@ -751,7 +771,7 @@ def Function_output(function,Data,filename,colname,layers):
#colname='EC_No_Mask_Group_MST_Multi_layer_real_'#+Layer_dic[i]+'_tag_'+str(i)
#print(filename)
#print(colname)
#function=Group_eingenvector_centrality
#function=Group_eigenvector_centrality
#Data=Supra_MST
#Function_output(function,Data,filename,colname,list(range(8)))
#print('we did it')
@@ -762,7 +782,7 @@ def Function_output(function,Data,filename,colname,layers):
#colname='EC_No_Mask_Group_MST_Multi_layer_random_'#+Layer_dic[i]+'_tag_'+str(i)
#print(filename)
#print(colname)
#function=Group_eingenvector_centrality
#function=Group_eigenvector_centrality
#Data=Supra_MST_random
#Function_output(function,Data,filename,colname,list(range(8)))
#print('we did it')