[SOLVED] Accessing neurons' connections from TFs


#1

Hello,
I am trying to get a list of neurons’ connections and their parameters from a transfer function.
Essentially, I would like to get the values I would normally get with
nest.GetConnections(neurons_pre, neurons_post) and nest.GetStatus(connections, "weight") if I was in the brain file.

I would be grateful for your help.
Best regards,
Mikołaj Miękus


#2

Hello Mikołaj,

Inside the body of a TF, you can indeed access the module of the brain script with nrp.config.brain_root .

I’d suggest you to keep any brain-related code in the brain script and then accessing it, from the body of a TF, with nrp.config.brain_root.foo()

Cheers


#4

Thank you. I must have been doing something wrong when I tried it previously, then. Now it works. Sorry for the trouble.
Cheers


#5

Unfortunately, when I try to run the the code in a TF

nrp.config.brain_root.pp.get_connections()

while having the following function defined in a pp's class in the brain file:

def get_connections(self): 
        return nest.GetConnections(self.columns_pre, self.columns)

where the class attributes are simply

self.columns_pre = nest.Create("iaf_cond_exp", 1200, params=cell_params)
self.columns = nest.Create("iaf_cond_exp", 1200, params=cell_params)

the simulation in online NRP 3.2.0 slows down so much, that it seems that it freezes (even the real time and timout counters stop). One step of the CLE takes almost two minutes. There are around 16 000 connections between the two populations but I have already used the nest.GetConnections() function on these populations within the brain file (without TFs) and the initialisation of the simulation did not take so long. Is such a slowing down when using TFs inevitable?


#6

Running it in a TF, shouldn’t be intrinsically slower that running it at brain file loading time.

In a TF only code that is time-dependent should be executed: in fact, one of the arguments of a TF is t, the current simulation time, everything else should be outside of the main loop. In your case, do connections changes at every time step? Can you remove it from the loop, and calling it only once at TF loading time?

If that is the case, you could call at the top level, i.e. before the definition of your TF, outside of its body then mapping the value to a variable with the @MapVariable decorator


#7

The connections itself do not change, but with every timestep I am computing which neurons’ connections I am interested in.

I realised that I can just import nest in the TF’s definition, and that allows me to run nest’s functions from there. This works:

nest.GetConnections(neurons, nrp.config.brain_root.pp.columns)

where neurons is a list of neurons’ IDs computed in the TF.

But this command (and I suppose my previous approach too) gets significantly slower with increasing number of neurons. It works well for like 5 IDs in neurons. But every timestep I get approx. 800 IDs, which give me around 10000 connections. And that takes a long time.

When I spam similar lines of code outside the TF’s definition or in the brain file, the simulation initializes quickly.


#8

Where do you run those functions doesn’t affect their execution time.
Some of them are computationally demanding whether you run them in a TF or not.

Have you tried caching the results? On average, it will save you some time.

Anything defined at the top level, will be executed at TF loading time, i.e. when you launch the simulation or when applying an edited TF.


#9

No, how can I do this?


#10

Save the results in a dictionary like data structure or use python’s cache decorator. Beware of the amount of memory used, though.