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

Minor improvement to microcircuit example #2087

Merged
merged 6 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions examples/nest/Potjans_2014/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ Files:
Simulation script

- run_microcircuit.sh
Bash script. Creates sim_script.sh and submits it to the queue
Bash script. Runs the simulation in the current machine, HPC might be needed.

- spike_analysis.py
Python script for basic analysis

The bash script is designed for a cluster with a queuing system that uses qsub.
The actual simulation script 'microcircuit.sli' does not need to be changed.


Expand Down
34 changes: 15 additions & 19 deletions examples/nest/Potjans_2014/run_microcircuit.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,32 @@
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.

# Create output folder (if it does not exist yet) and sim_script.sh
# and submit to the queue. Adapt to your system as necessary
# Create output folder (if it does not exist yet) and run the simulation
# Adapt this file to your HPC queueing system as needed

OUTPUT_PATH=$(grep '/output_path' sim_params.sli | cut -d'(' -f2 | cut -d ')' -f1)
OUTPUT_PATH=$(cd $OUTPUT_PATH; pwd)

# Use these variables to submit your job
N_COMPUTE_NODES=$(grep '/n_compute_nodes' sim_params.sli | cut -d' ' -f2)
N_MPI_PER_COMPUTE_NODE=$(grep '/n_mpi_procs_per_compute_node' sim_params.sli | cut -d' ' -f2)
WALLTIME_LIMIT=$(grep '/walltime_limit' sim_params.sli | cut -d'(' -f2 | cut -d ')' -f1)
MEMORY_LIMIT=$(egrep '/memory_limit' sim_params.sli | cut -d'(' -f2 | cut -d ')' -f1)

NEST_PATH=$(grep '/nest_path' sim_params.sli | cut -d '(' -f2 | cut -d ')' -f1)
STDOUT=$(grep '/std_out' sim_params.sli | cut -d'(' -f2 | cut -d')' -f1)
STDERR=$(grep '/std_err' sim_params.sli | cut -d'(' -f2 | cut -d')' -f1)

# Resolve paths
OUTPUT_PATH=$(grep '/output_path' sim_params.sli | cut -d'(' -f2 | cut -d ')' -f1)
OUTPUT_PATH=$(cd $OUTPUT_PATH; pwd)
NEST_PATH=$(grep '/nest_path' sim_params.sli | cut -d '(' -f2 | cut -d ')' -f1)

# Prepare output directory
mkdir -p $OUTPUT_PATH
cp 'sim_params.sli' $OUTPUT_PATH
cp 'network_params.sli' $OUTPUT_PATH
cp 'microcircuit.sli' $OUTPUT_PATH
cd $OUTPUT_PATH

echo > sim_script.sh
chmod 755 sim_script.sh

echo "#PBS -o $OUTPUT_PATH/$STDOUT" >> sim_script.sh
echo "#PBS -e $OUTPUT_PATH/$STDERR" >> sim_script.sh
echo "#PBS -l walltime=$WALLTIME_LIMIT" >> sim_script.sh
echo "#PBS -l mem=$MEMORY_LIMIT" >> sim_script.sh
echo ". $NEST_PATH/bin/nest_vars.sh" >> sim_script.sh
echo "NEST_DATA_PATH=$OUTPUT_PATH" >> sim_script.sh
echo "mpirun -machinefile \$PBS_NODEFILE nest $OUTPUT_PATH/microcircuit.sli" >> sim_script.sh
echo "unset NEST_DATA_PATH" >> sim_script.sh

echo qsub -l nodes=$N_COMPUTE_NODES:ppn=$N_MPI_PER_COMPUTE_NODE sim_script.sh
# Run
. $NEST_PATH/bin/nest_vars.sh
NEST_DATA_PATH=$OUTPUT_PATH
mpirun nest $OUTPUT_PATH/microcircuit.sli
unset NEST_DATA_PATH
1 change: 0 additions & 1 deletion pynest/examples/Potjans_2014/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from matplotlib.patches import Polygon
import matplotlib.pyplot as plt
import os
import sys
import numpy as np
if 'DISPLAY' not in os.environ:
import matplotlib
Expand Down
39 changes: 20 additions & 19 deletions pynest/examples/Potjans_2014/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import numpy as np
import nest
import helpers
import warnings


class Network:
Expand Down Expand Up @@ -189,13 +190,13 @@ def __derive_parameters(self):
self.net_dict['full_num_neurons'])

# scaled numbers of neurons and synapses
self.num_neurons = np.round((self.net_dict['full_num_neurons'] *
self.net_dict['N_scaling'])).astype(int)
self.num_synapses = np.round((full_num_synapses *
self.net_dict['N_scaling'] *
self.net_dict['K_scaling'])).astype(int)
self.ext_indegrees = np.round((self.net_dict['K_ext'] *
self.net_dict['K_scaling'])).astype(int)
self.num_neurons = np.round((self.net_dict['full_num_neurons']
* self.net_dict['N_scaling'])).astype(int)
self.num_synapses = np.round((full_num_synapses
* self.net_dict['N_scaling']
* self.net_dict['K_scaling'])).astype(int)
self.ext_indegrees = np.round((self.net_dict['K_ext']
* self.net_dict['K_scaling'])).astype(int)

# conversion from PSPs to PSCs
PSC_over_PSP = helpers.postsynaptic_potential_to_current(
Expand All @@ -210,7 +211,7 @@ def __derive_parameters(self):
DC_amp = np.zeros(self.num_pops)
else:
if nest.Rank() == 0:
print('DC input compensates for missing Poisson input.\n')
warnings.warn('DC input created to compensate missing Poisson input.\n')
DC_amp = helpers.dc_input_compensating_poisson(
self.net_dict['bg_rate'], self.net_dict['K_ext'],
self.net_dict['neuron_params']['tau_syn'],
Expand Down Expand Up @@ -324,9 +325,9 @@ def __create_neuronal_populations(self):
self.net_dict['neuron_params']['V0_mean']['original'],
self.net_dict['neuron_params']['V0_std']['original']))
else:
raise Exception(
'V0_type incorrect. ' +
'Valid options are "optimized" and "original".')
raise ValueError(
'V0_type is incorrect. '
+ 'Valid options are "optimized" and "original".')

self.pops.append(population)

Expand Down Expand Up @@ -419,8 +420,8 @@ def __create_dc_stim_input(self):

dc_dict = {'amplitude': dc_amp_stim,
'start': self.stim_dict['dc_start'],
'stop': (self.stim_dict['dc_start'] +
self.stim_dict['dc_dur'])}
'stop': (self.stim_dict['dc_start']
+ self.stim_dict['dc_dur'])}
self.dc_stim_input = nest.Create('dc_generator', n=self.num_pops,
params=dc_dict)

Expand Down Expand Up @@ -448,15 +449,15 @@ def __connect_neuronal_populations(self):
'weight': nest.math.redraw(
nest.random.normal(
mean=self.weight_matrix_mean[i][j],
std=abs(self.weight_matrix_mean[i][j] *
self.net_dict['weight_rel_std'])),
std=abs(self.weight_matrix_mean[i][j]
* self.net_dict['weight_rel_std'])),
min=w_min,
max=w_max),
'delay': nest.math.redraw(
nest.random.normal(
mean=self.net_dict['delay_matrix_mean'][i][j],
std=(self.net_dict['delay_matrix_mean'][i][j] *
self.net_dict['delay_rel_std'])),
std=(self.net_dict['delay_matrix_mean'][i][j]
* self.net_dict['delay_rel_std'])),
min=self.sim_resolution,
max=np.Inf)}

Expand Down Expand Up @@ -518,8 +519,8 @@ def __connect_thalamic_stim_input(self):
'delay': nest.math.redraw(
nest.random.normal(
mean=self.stim_dict['delay_th_mean'],
std=(self.stim_dict['delay_th_mean'] *
self.stim_dict['delay_th_rel_std'])),
std=(self.stim_dict['delay_th_mean']
* self.stim_dict['delay_th_rel_std'])),
min=self.sim_resolution,
max=np.Inf)}

Expand Down