Skip to content

Commit

Permalink
Scale by the connectivity matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
JessyD committed Jul 8, 2019
1 parent bcb7508 commit 2ddd67b
Show file tree
Hide file tree
Showing 7 changed files with 1,452 additions and 26,980 deletions.
67 changes: 50 additions & 17 deletions NeuroML2/GenerateNeuroMLlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@ def get_scaled_color(area):
print('Color for area %s: %s'%(area,c))
return c

def get_connectivity(conn, areas, ranking, conn_bin):
'''
Generate connectivity matrix
:param conn: Dictionary with the fln and sln information
:param conn_bin: binary matrix describing which region is connected to which. This is only necessary
if the fln and sln are not taken into account.
:param ranking: List of all areas with their rankings
:param areas: List of Areas under analysis (assumes that all areas have been sorted by their ranking)
:return:
conn: The connectivity matrix scalled by fln and sln
'''
if conn_bin == None:
# find fln and sln information for the 4 regions of interest
region_indexes = []
for area in areas:
region_indexes.append(ranking.loc[ranking['region'] == area].index.tolist()[0])
# Get the tuple of the combination of connectivity and obtain the correspoding fln and sln values
indexes = [i for i in product(region_indexes, repeat=2)]
fln = conn['fln'][tuple(np.array(indexes).T)].reshape(len(areas), len(areas))
# range compression for the connection weights
fln = 1.2 * np.power(fln, .30)
sln = conn['sln'][tuple(np.array(indexes).T)].reshape(len(areas), len(areas))
conn = np.multiply(fln, sln)
else:
conn = conn_bin
return conn

'''
Get name without / and not starting with digit
Expand Down Expand Up @@ -220,15 +248,15 @@ def internal_connections(pops, W, pre_pop, post_pop):
if conn[row, col] != 0:
# Add FF connection
if (row, col) in up_tri:
W[row * 4 + 0, col * 4 + 0] = 1. # FF_L2e_l2e
W[row * 4 + 0, col * 4 + 0] = 1. * conn[row, col] # FF_L2e_l2e


# Add FB connection
if (row, col) in lw_tri:
W[row *4 + 2, col * 4 + 0] = .1 # FB l5e_l2e
W[row *4 + 2, col * 4 + 3] = .5 # FB l5e_l5i
W[row *4 + 2, col * 4 + 2] = .9 # FB l5e_l5e
W[row *4 + 2, col * 4 + 1] = .5 # FB l5e_l2i
W[row *4 + 2, col * 4 + 0] = .1 * conn[row, col] # FB l5e_l2e
W[row *4 + 2, col * 4 + 3] = .5 * conn[row, col] # FB l5e_l5i
W[row *4 + 2, col * 4 + 2] = .9 * conn[row, col] # FB l5e_l5e
W[row *4 + 2, col * 4 + 1] = .5 * conn[row, col] # FB l5e_l2i

else:
raise ValueError('Connectivity matrix not defined for more than 3 regions')
Expand Down Expand Up @@ -1022,34 +1050,39 @@ def internal_connections(pops, W, pre_pop, post_pop):

else:
#Load the array with the ordered rank
from itertools import product
import pandas as pd

ranking = pd.read_csv('../Python/interareal/areas_ranking.txt')
with open('../Python/interareal/connectivity.pickle', 'rb') as handle:
conn = pickle.load(handle)



if '-3rois' in sys.argv:
areas = ['V1', 'V4', 'MT']
# Create the FB and FF connectiviy between the areas.
# Define connections between regions
# NOTE: This analysis assumes that the matrix has been organised by the areas ranking
conn = np.array([[0, 1, 0],
[1, 0, 1],
[0, 1, 0]])
conn_bin = np.array([[0, 1, 0],
[1, 0, 1],
[0, 1, 0]])
conn = get_connectivity(conn, areas, ranking, conn_bin=None)

if '-4rois' in sys.argv:
areas = ['V1', 'V4', 'MT', 'TEO']
# Create the FB and FF connectiviy between the areas.
# Define connections between regions
# NOTE: This analysis assumes that the matrix has been organised by the areas ranking
conn = np.array([[0, 1, 0, 0],
[1, 0, 1, 0],
[0, 1, 0, 0],
[0, 0, 1, 0]])
conn_bin = np.array([[0, 1, 0, 0],
[1, 0, 1, 0],
[0, 1, 0, 0],
[0, 0, 1, 0]])
conn = get_connectivity(conn, areas, ranking, conn_bin=None)

if '-30rois' in sys.argv:
areas = list(ranking['region'])
with open('../Python/interareal/connectivity.pickle', 'rb') as handle:
conn = pickle.load(handle)
# range compression for the connection weights
fln = 1.2 * np.power(conn['fln'], .30)
conn = np.multiply(fln, conn['sln'])
conn = get_connectivity(conn, areas, ranking, conn_bin=None)

net_id='Interareal_%d' %len(areas)

Expand Down
59 changes: 30 additions & 29 deletions NeuroML2/Interareal_3.net.nml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
wei = 3.5
wie = -3.25
wii = -2.5</notes>
<include href="Prototypes.xml"/>
<include href="RateBased.xml"/>
<include href="NoisyCurrentSource.xml"/>
<silentSynapse id="silentSyn_proj_V1_L23_E_V1_L23_E"/>
<silentSynapse id="silentSyn_proj_V1_L23_E_V1_L23_I"/>
<silentSynapse id="silentSyn_proj_V1_L23_E_V1_L56_E"/>
<silentSynapse id="silentSyn_proj_V1_L23_E_V4_L23_E"/>
<silentSynapse id="silentSyn_proj_V1_L23_E_MT_L23_E"/>
<silentSynapse id="silentSyn_proj_V1_L23_I_V1_L23_E"/>
<silentSynapse id="silentSyn_proj_V1_L23_I_V1_L23_I"/>
<silentSynapse id="silentSyn_proj_V1_L56_E_V1_L23_I"/>
Expand Down Expand Up @@ -45,6 +43,10 @@
<silentSynapse id="silentSyn_proj_MT_L23_E_MT_L56_E"/>
<silentSynapse id="silentSyn_proj_MT_L23_I_MT_L23_E"/>
<silentSynapse id="silentSyn_proj_MT_L23_I_MT_L23_I"/>
<silentSynapse id="silentSyn_proj_MT_L56_E_V1_L23_E"/>
<silentSynapse id="silentSyn_proj_MT_L56_E_V1_L23_I"/>
<silentSynapse id="silentSyn_proj_MT_L56_E_V1_L56_E"/>
<silentSynapse id="silentSyn_proj_MT_L56_E_V1_L56_I"/>
<silentSynapse id="silentSyn_proj_MT_L56_E_V4_L23_E"/>
<silentSynapse id="silentSyn_proj_MT_L56_E_V4_L23_I"/>
<silentSynapse id="silentSyn_proj_MT_L56_E_V4_L56_E"/>
Expand All @@ -56,10 +58,6 @@
<silentSynapse id="silentSyn_proj_MT_L56_I_MT_L56_I"/>
<pulseGenerator id="iclamp_V1_L23" delay="0ms" duration="40000.0ms" amplitude="2nA"/>
<pulseGenerator id="iclamp_V1_L56" delay="0ms" duration="40000.0ms" amplitude="4nA"/>
<pulseGenerator id="iclamp_V4_L23" delay="0ms" duration="40000.0ms" amplitude="2nA"/>
<pulseGenerator id="iclamp_V4_L56" delay="0ms" duration="40000.0ms" amplitude="4nA"/>
<pulseGenerator id="iclamp_MT_L23" delay="0ms" duration="40000.0ms" amplitude="2nA"/>
<pulseGenerator id="iclamp_MT_L56" delay="0ms" duration="40000.0ms" amplitude="4nA"/>
<network id="Interareal_3">
<notes>Testing...</notes>
<population id="V1_L23_E" component="L23_E_comp" size="1" type="populationList">
Expand Down Expand Up @@ -168,7 +166,10 @@
<continuousConnectionInstance id="0" preCell="../V1_L23_E/0/L23_E_comp" postCell="../V1_L56_E/0/L56_E_comp" preComponent="silentSyn_proj_V1_L23_E_V1_L56_E" postComponent="rs"/>
</continuousProjection>
<continuousProjection id="proj_V1_L23_E_V4_L23_E" presynapticPopulation="V1_L23_E" postsynapticPopulation="V4_L23_E">
<continuousConnectionInstance id="0" preCell="../V1_L23_E/0/L23_E_comp" postCell="../V4_L23_E/0/L23_E_comp" preComponent="silentSyn_proj_V1_L23_E_V4_L23_E" postComponent="rs"/>
<continuousConnectionInstanceW id="0" preCell="../V1_L23_E/0/L23_E_comp" postCell="../V4_L23_E/0/L23_E_comp" preComponent="silentSyn_proj_V1_L23_E_V4_L23_E" postComponent="rs" weight="0.191924412754106"/>
</continuousProjection>
<continuousProjection id="proj_V1_L23_E_MT_L23_E" presynapticPopulation="V1_L23_E" postsynapticPopulation="MT_L23_E">
<continuousConnectionInstanceW id="0" preCell="../V1_L23_E/0/L23_E_comp" postCell="../MT_L23_E/0/L23_E_comp" preComponent="silentSyn_proj_V1_L23_E_MT_L23_E" postComponent="rs" weight="0.088869494034332"/>
</continuousProjection>
<continuousProjection id="proj_V1_L23_I_V1_L23_E" presynapticPopulation="V1_L23_I" postsynapticPopulation="V1_L23_E">
<continuousConnectionInstanceW id="0" preCell="../V1_L23_I/0/L23_I_comp" postCell="../V1_L23_E/0/L23_E_comp" preComponent="silentSyn_proj_V1_L23_I_V1_L23_E" postComponent="rs" weight="-3.25"/>
Expand Down Expand Up @@ -201,7 +202,7 @@
<continuousConnectionInstance id="0" preCell="../V4_L23_E/0/L23_E_comp" postCell="../V4_L56_E/0/L56_E_comp" preComponent="silentSyn_proj_V4_L23_E_V4_L56_E" postComponent="rs"/>
</continuousProjection>
<continuousProjection id="proj_V4_L23_E_MT_L23_E" presynapticPopulation="V4_L23_E" postsynapticPopulation="MT_L23_E">
<continuousConnectionInstance id="0" preCell="../V4_L23_E/0/L23_E_comp" postCell="../MT_L23_E/0/L23_E_comp" preComponent="silentSyn_proj_V4_L23_E_MT_L23_E" postComponent="rs"/>
<continuousConnectionInstanceW id="0" preCell="../V4_L23_E/0/L23_E_comp" postCell="../MT_L23_E/0/L23_E_comp" preComponent="silentSyn_proj_V4_L23_E_MT_L23_E" postComponent="rs" weight="0.263629857446179"/>
</continuousProjection>
<continuousProjection id="proj_V4_L23_I_V4_L23_E" presynapticPopulation="V4_L23_I" postsynapticPopulation="V4_L23_E">
<continuousConnectionInstanceW id="0" preCell="../V4_L23_I/0/L23_I_comp" postCell="../V4_L23_E/0/L23_E_comp" preComponent="silentSyn_proj_V4_L23_I_V4_L23_E" postComponent="rs" weight="-3.25"/>
Expand All @@ -210,16 +211,16 @@
<continuousConnectionInstanceW id="0" preCell="../V4_L23_I/0/L23_I_comp" postCell="../V4_L23_I/0/L23_I_comp" preComponent="silentSyn_proj_V4_L23_I_V4_L23_I" postComponent="rs" weight="-2.5"/>
</continuousProjection>
<continuousProjection id="proj_V4_L56_E_V1_L23_E" presynapticPopulation="V4_L56_E" postsynapticPopulation="V1_L23_E">
<continuousConnectionInstanceW id="0" preCell="../V4_L56_E/0/L56_E_comp" postCell="../V1_L23_E/0/L23_E_comp" preComponent="silentSyn_proj_V4_L56_E_V1_L23_E" postComponent="rs" weight="0.1"/>
<continuousConnectionInstanceW id="0" preCell="../V4_L56_E/0/L56_E_comp" postCell="../V1_L23_E/0/L23_E_comp" preComponent="silentSyn_proj_V4_L56_E_V1_L23_E" postComponent="rs" weight="0.032049400124286"/>
</continuousProjection>
<continuousProjection id="proj_V4_L56_E_V1_L23_I" presynapticPopulation="V4_L56_E" postsynapticPopulation="V1_L23_I">
<continuousConnectionInstanceW id="0" preCell="../V4_L56_E/0/L56_E_comp" postCell="../V1_L23_I/0/L23_I_comp" preComponent="silentSyn_proj_V4_L56_E_V1_L23_I" postComponent="rs" weight="0.5"/>
<continuousConnectionInstanceW id="0" preCell="../V4_L56_E/0/L56_E_comp" postCell="../V1_L23_I/0/L23_I_comp" preComponent="silentSyn_proj_V4_L56_E_V1_L23_I" postComponent="rs" weight="0.160247000621429"/>
</continuousProjection>
<continuousProjection id="proj_V4_L56_E_V1_L56_E" presynapticPopulation="V4_L56_E" postsynapticPopulation="V1_L56_E">
<continuousConnectionInstanceW id="0" preCell="../V4_L56_E/0/L56_E_comp" postCell="../V1_L56_E/0/L56_E_comp" preComponent="silentSyn_proj_V4_L56_E_V1_L56_E" postComponent="rs" weight="0.9"/>
<continuousConnectionInstanceW id="0" preCell="../V4_L56_E/0/L56_E_comp" postCell="../V1_L56_E/0/L56_E_comp" preComponent="silentSyn_proj_V4_L56_E_V1_L56_E" postComponent="rs" weight="0.288444601118573"/>
</continuousProjection>
<continuousProjection id="proj_V4_L56_E_V1_L56_I" presynapticPopulation="V4_L56_E" postsynapticPopulation="V1_L56_I">
<continuousConnectionInstanceW id="0" preCell="../V4_L56_E/0/L56_E_comp" postCell="../V1_L56_I/0/L56_I_comp" preComponent="silentSyn_proj_V4_L56_E_V1_L56_I" postComponent="rs" weight="0.5"/>
<continuousConnectionInstanceW id="0" preCell="../V4_L56_E/0/L56_E_comp" postCell="../V1_L56_I/0/L56_I_comp" preComponent="silentSyn_proj_V4_L56_E_V1_L56_I" postComponent="rs" weight="0.160247000621429"/>
</continuousProjection>
<continuousProjection id="proj_V4_L56_E_V4_L23_I" presynapticPopulation="V4_L56_E" postsynapticPopulation="V4_L23_I">
<continuousConnectionInstanceW id="0" preCell="../V4_L56_E/0/L56_E_comp" postCell="../V4_L23_I/0/L23_I_comp" preComponent="silentSyn_proj_V4_L56_E_V4_L23_I" postComponent="rs" weight="0.75"/>
Expand Down Expand Up @@ -251,17 +252,29 @@
<continuousProjection id="proj_MT_L23_I_MT_L23_I" presynapticPopulation="MT_L23_I" postsynapticPopulation="MT_L23_I">
<continuousConnectionInstanceW id="0" preCell="../MT_L23_I/0/L23_I_comp" postCell="../MT_L23_I/0/L23_I_comp" preComponent="silentSyn_proj_MT_L23_I_MT_L23_I" postComponent="rs" weight="-2.5"/>
</continuousProjection>
<continuousProjection id="proj_MT_L56_E_V1_L23_E" presynapticPopulation="MT_L56_E" postsynapticPopulation="V1_L23_E">
<continuousConnectionInstanceW id="0" preCell="../MT_L56_E/0/L56_E_comp" postCell="../V1_L23_E/0/L23_E_comp" preComponent="silentSyn_proj_MT_L56_E_V1_L23_E" postComponent="rs" weight="0.032538660182559"/>
</continuousProjection>
<continuousProjection id="proj_MT_L56_E_V1_L23_I" presynapticPopulation="MT_L56_E" postsynapticPopulation="V1_L23_I">
<continuousConnectionInstanceW id="0" preCell="../MT_L56_E/0/L56_E_comp" postCell="../V1_L23_I/0/L23_I_comp" preComponent="silentSyn_proj_MT_L56_E_V1_L23_I" postComponent="rs" weight="0.162693300912796"/>
</continuousProjection>
<continuousProjection id="proj_MT_L56_E_V1_L56_E" presynapticPopulation="MT_L56_E" postsynapticPopulation="V1_L56_E">
<continuousConnectionInstanceW id="0" preCell="../MT_L56_E/0/L56_E_comp" postCell="../V1_L56_E/0/L56_E_comp" preComponent="silentSyn_proj_MT_L56_E_V1_L56_E" postComponent="rs" weight="0.292847941643034"/>
</continuousProjection>
<continuousProjection id="proj_MT_L56_E_V1_L56_I" presynapticPopulation="MT_L56_E" postsynapticPopulation="V1_L56_I">
<continuousConnectionInstanceW id="0" preCell="../MT_L56_E/0/L56_E_comp" postCell="../V1_L56_I/0/L56_I_comp" preComponent="silentSyn_proj_MT_L56_E_V1_L56_I" postComponent="rs" weight="0.162693300912796"/>
</continuousProjection>
<continuousProjection id="proj_MT_L56_E_V4_L23_E" presynapticPopulation="MT_L56_E" postsynapticPopulation="V4_L23_E">
<continuousConnectionInstanceW id="0" preCell="../MT_L56_E/0/L56_E_comp" postCell="../V4_L23_E/0/L23_E_comp" preComponent="silentSyn_proj_MT_L56_E_V4_L23_E" postComponent="rs" weight="0.1"/>
<continuousConnectionInstanceW id="0" preCell="../MT_L56_E/0/L56_E_comp" postCell="../V4_L23_E/0/L23_E_comp" preComponent="silentSyn_proj_MT_L56_E_V4_L23_E" postComponent="rs" weight="0.055275422722727"/>
</continuousProjection>
<continuousProjection id="proj_MT_L56_E_V4_L23_I" presynapticPopulation="MT_L56_E" postsynapticPopulation="V4_L23_I">
<continuousConnectionInstanceW id="0" preCell="../MT_L56_E/0/L56_E_comp" postCell="../V4_L23_I/0/L23_I_comp" preComponent="silentSyn_proj_MT_L56_E_V4_L23_I" postComponent="rs" weight="0.5"/>
<continuousConnectionInstanceW id="0" preCell="../MT_L56_E/0/L56_E_comp" postCell="../V4_L23_I/0/L23_I_comp" preComponent="silentSyn_proj_MT_L56_E_V4_L23_I" postComponent="rs" weight="0.276377113613634"/>
</continuousProjection>
<continuousProjection id="proj_MT_L56_E_V4_L56_E" presynapticPopulation="MT_L56_E" postsynapticPopulation="V4_L56_E">
<continuousConnectionInstanceW id="0" preCell="../MT_L56_E/0/L56_E_comp" postCell="../V4_L56_E/0/L56_E_comp" preComponent="silentSyn_proj_MT_L56_E_V4_L56_E" postComponent="rs" weight="0.9"/>
<continuousConnectionInstanceW id="0" preCell="../MT_L56_E/0/L56_E_comp" postCell="../V4_L56_E/0/L56_E_comp" preComponent="silentSyn_proj_MT_L56_E_V4_L56_E" postComponent="rs" weight="0.497478804504542"/>
</continuousProjection>
<continuousProjection id="proj_MT_L56_E_V4_L56_I" presynapticPopulation="MT_L56_E" postsynapticPopulation="V4_L56_I">
<continuousConnectionInstanceW id="0" preCell="../MT_L56_E/0/L56_E_comp" postCell="../V4_L56_I/0/L56_I_comp" preComponent="silentSyn_proj_MT_L56_E_V4_L56_I" postComponent="rs" weight="0.5"/>
<continuousConnectionInstanceW id="0" preCell="../MT_L56_E/0/L56_E_comp" postCell="../V4_L56_I/0/L56_I_comp" preComponent="silentSyn_proj_MT_L56_E_V4_L56_I" postComponent="rs" weight="0.276377113613634"/>
</continuousProjection>
<continuousProjection id="proj_MT_L56_E_MT_L23_I" presynapticPopulation="MT_L56_E" postsynapticPopulation="MT_L23_I">
<continuousConnectionInstanceW id="0" preCell="../MT_L56_E/0/L56_E_comp" postCell="../MT_L23_I/0/L23_I_comp" preComponent="silentSyn_proj_MT_L56_E_MT_L23_I" postComponent="rs" weight="0.75"/>
Expand All @@ -284,17 +297,5 @@
<inputList id="modulation_V1_L56_E" population="V1_L56_E" component="iclamp_V1_L56">
<input id="0" target="../V1_L56_E/0/L56_E_comp" destination="synapses"/>
</inputList>
<inputList id="modulation_V4_L23_E" population="V4_L23_E" component="iclamp_V4_L23">
<input id="0" target="../V4_L23_E/0/L23_E_comp" destination="synapses"/>
</inputList>
<inputList id="modulation_V4_L56_E" population="V4_L56_E" component="iclamp_V4_L56">
<input id="0" target="../V4_L56_E/0/L56_E_comp" destination="synapses"/>
</inputList>
<inputList id="modulation_MT_L23_E" population="MT_L23_E" component="iclamp_MT_L23">
<input id="0" target="../MT_L23_E/0/L23_E_comp" destination="synapses"/>
</inputList>
<inputList id="modulation_MT_L56_E" population="MT_L56_E" component="iclamp_MT_L56">
<input id="0" target="../MT_L56_E/0/L56_E_comp" destination="synapses"/>
</inputList>
</network>
</neuroml>
Loading

0 comments on commit 2ddd67b

Please sign in to comment.