-
Notifications
You must be signed in to change notification settings - Fork 371
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
Arbitrarily nested neuron groups with per-group iterator #3322
Comments
Great step that you open this tread. One or more extensions/suggestions/corrections to your comment:
To better understand, we can make a usecase: lets say
|
Actually, we don't need anything new in NEST (almost ...) to make this happen: We can get it for free from Pandas DataFrames! The following code generates something like the neural populations of the multi-area model, but with three interneuron populations per layer, randomly selected neuron numbers and each population assigned randomly one of three neuron models and stores them in a Pandas dataframe: import nest
import pandas as pd
import random
random.seed(123)
areas = ['V1', 'V2', 'VP', 'V3', 'V3A', 'MT', 'V4t', 'V4', 'VOT', 'MSTd',
'PIP', 'PO', 'DP', 'MIP', 'MDP', 'VIP', 'LIP', 'PITv', 'PITd',
'MSTl', 'CITv', 'CITd', 'FEF', 'TF', 'AITv', 'FST', '7a', 'STPp',
'STPa', '46', 'AITd', 'TH']
layers = ['L23', 'L4', 'L5', 'L6']
pops = ['Pyr', 'SOM', 'VIP', 'PV']
models = ['iaf_psc_alpha', 'aeif_psc_alpha', 'iaf_psc_delta']
d = pd.DataFrame.from_records(
{'Area': a, 'Layer': l, 'Population': p,
'NC': nest.Create(random.choice(models), n=random.randint(1, 2000))}
for a in areas for l in layers for p in pops
) Using the multilevel indexing features of Pandas, we can then create nice tables: df = d.set_index(['Area', 'Layer', 'Population']).unstack(1).unstack().droplevel(0, axis=1)
df.style.format('{:5}') will give (requires small patch to and to pick L5 from two areas df.loc[['46', 'AITd'], 'L5'].style.format('{:5}') We can do much more with Pandas multi-level indexing and table reshaping tools. Everything we select are collections of node collections, so by just summing over values, we can pass things to Connect commands. For example, to connect all L5 populations of areas 46 and AITd to all populations in L4 and L6 of area 7a, we can just do src = df.loc[['46', 'AITd'], 'L5']
tgt = df.loc['7a', ['L4', 'L6']].to_frame().T
srcn = src.sum().sum()
tgtn = tgt.sum().sum()
nest.Connect(srcn, tgtn, {'rule': 'fixed_indegree', 'indegree': 10}) The double summing is needed to sum over rows and columns of data frames. There are still some hickups, in particular to |
Issue automatically marked stale! |
(Discussed during Bernstein conference with @babsey @heplesser @terhorstd @poojanbabu)
In the future it may be desirable to support creating arbitrary nested groups of populations in NEST the way it is currently proposed for NEST Desktop on a Python level by @babsey. This would allow applying connection rules and e.g. weight values on a per-group-item level via a group item aware iterator as opposed to strictly flattened across all neuron in a NodeCollection.
Syntax brainstorming:
nest.Group
but some method or operator overload is needed to distinguish from the defaultn1 + n2
flattened collection addition.The text was updated successfully, but these errors were encountered: