-
Notifications
You must be signed in to change notification settings - Fork 370
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
Pynest microcircuit #451
Pynest microcircuit #451
Conversation
May 2016 | ||
|
||
## Description ## | ||
This is a PyNEST implementation of the SLI cortical microcircuit from the microcircuit model by Potjans and Diesmann (2014): The cell-type specific |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a PyNEST implementation of the microcircuit model ...
(no need to mention SLI)
👍 from me. |
'Seeds for random number generators of virtual processes: %r' | ||
% rng_seeds | ||
) | ||
print('Global random number generator seed:%i' % grng_seed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a space in front of %i
for being consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
def connect_devices(self): | ||
""" Connects the recording devices to the microcircuit.""" | ||
print('%s of 2 Devices connected' % (len(self.net_dict['rec_dev']))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It prints "1 of 2 Devices connected" if only a spike detector is used which sounds as if something was missing. I suggest to be specific and print "Spike Detector connected" or/and "Voltmeter connected".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
|
||
# Initialize the network and pass parameters to it. | ||
net = network.Network(sim_dict, net_dict, stim_dict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to time also the network initialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
t1 = time.time() | ||
net.setup() | ||
time_con = time.time()-t1 | ||
print("Time to create the connections: %.2f seconds" % time_con) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the units ms
and Hz
are printed as well, why not just writing s
instead of seconds
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
How to use the example: | ||
|
||
To run the microcircuit on a local machine, adjust the variables `N_scaling` and `K_scaling` in `network_params.py` to 0.1 and create an output directory called `data`. `N_scaling` adjusts the number of neurons and `K_scaling` the number of connections to be simulated. The full network can be run by adjusting these values to 1. If this is done, the option to print the time progress should be set to False in the file `sim_params.py`. For running, use `python example.py`. The output will be saved in the directory `data`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
and create an output directory called
data
.
since this is now done automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
""" This function simulates the microcircuit.""" | ||
nest.Simulate(self.sim_dict['t_sim']) | ||
|
||
def evaluate(self, raster_plot_time_idx, fire_rate_time_idx): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could save the generated plots directly in the output directory together with the raw data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
# Standard deviation of the postsynaptic potential (in relative units). | ||
'PSP_sd': 0.1, | ||
# Start of the thalamic input (in ms). | ||
'th_start': 700.0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to set the default stimulus intervals somewhere into the default plotting interval so that their effect is directly visible by eye.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept the thalamus stimulus interval, since this is the stimulus interval of the sli version. I therefore changed the interval of the spike raster plot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Please update the comment on the plotting interval accordingly.
else: | ||
os.mkdir(self.sim_dict['data_path']) | ||
print('data directory created') | ||
print('Data will be written to %s' % self.data_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If used with MPI such statements are currently printed once per process. Please print them only on Rank 0 unless you want to print something specific to a process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
'0 << /model /%s >> GetLocalNodes' % self.net_dict['neuron_model'] | ||
) | ||
local_nodes = nest.sli_pop() | ||
vp = nest.GetStatus(local_nodes)[0]['vp'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If run with both MPI and threads, taking the vp of the first local node is not correct. For example, with 2 MPI processes and 2 threads, one gets the MPI ranks 0 and 1, but the vps 0,1,2 and 3. For accessing the right pyrngs, I think we cannot avoid to extract all vps correponding to the local nodes. I will give a suggestion soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a possible solution to the problem:
for thread in np.arange(nest.GetKernelStatus('local_num_threads')):
local_nodes = nest.GetNodes([0], {'model': self.net_dict['neuron_model'], 'thread': thread}, local_only=True)[0]
vp = nest.GetStatus(local_nodes)[0]['vp'] # same thread on MPI proc -> same vp
nest.SetStatus(
local_nodes, 'V_m', self.pyrngs[vp].normal(
self.net_dict['neuron_params']['V0_mean'],
self.net_dict['neuron_params']['V0_sd'],
len(local_nodes)))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this, using your solution.
self.DC_amp_e = compute_DC(self.net_dict, self.w_ext) | ||
|
||
print( | ||
'The Number of neurons is scaled by a factor of: %.2f' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Number -> number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Hi, during testing with both MPI and threads, I noticed that the initialization of membrane voltages did not work correctly. I made a suggestion inline how this could be solved. Apart from this, I made some other minor comments for improvement. |
fixed initialization of membrane potentials, with provided solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks to @albada , I took another look at the code and discovered some typos. Please fix them.
# along with NEST. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
''' | ||
pynest microcicuit example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please correct to microcircuit. Also in All other files that have this typo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed this and all other typos
|
||
|
||
def get_weight(PSP_val, net_dict): | ||
""" Function computes weight to elicit a change in the membrane potential. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to "Computes" in accordance to the documentation of other functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes this and adapted this style in all other functions
) | ||
# If the network is scaled the indegrees are calculated in the same | ||
# fashion as in the original version of the circuit, which is | ||
# written in sli |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insert '.' at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
def adj_w_ext_to_K(K_full, K_scaling, w, w_from_PSP, DC, net_dict, stim_dict): | ||
""" Adjustment of weights to scaling is dine in this function. | ||
|
||
With this funtion the recurrent and external weights are adjusted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
|
||
def load_spike_times(path, name, begin, end): | ||
""" This function loads spike times of each spike detector. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to "Loads..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
# along with NEST. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
''' | ||
microcicuit simulation parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
microcircuit
microcicuit simulation parameters | ||
--------------------------------- | ||
|
||
Simulation Parameters for the microcircuit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simulation parameters
'local_num_threads': 1, | ||
# Recording interval of the membrane potential (in ms). | ||
'rec_V_int': 1.0, | ||
# If True data will be overwritten, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If True, data...
# Recording interval of the membrane potential (in ms). | ||
'rec_V_int': 1.0, | ||
# If True data will be overwritten, | ||
# if False a NESTError is raised if the files already exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If False, ...
# along with NEST. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
''' | ||
microcicuit stimulus parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
microcircuit
some typos were fixed and a comment about the initialization of the membrane potentials was changed
👍 |
@hendrikrth Thank you for porting this important model to PyNEST! @jhnnsnk @mschmidt87 Thank you for your thorough review! |
The example files of NEST are lacking a PyNEST version of the microcircuit #450. To compensate this I would like you to include my branch. As reviewers I suggest @jhnnsnk and @mschmidt87.