Skip to content

Commit

Permalink
Merge pull request #405 from Hjorthmedh/region_mesh_redux
Browse files Browse the repository at this point in the history
More flexible input generation from meta.json
  • Loading branch information
Hjorthmedh authored Jan 29, 2024
2 parents 8132cf7 + 724fb33 commit 52a019f
Show file tree
Hide file tree
Showing 43 changed files with 17,918 additions and 23,047 deletions.
479 changes: 479 additions & 0 deletions examples/notebooks/Input-generation-using-BasalGangliaData.ipynb

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion examples/notebooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ Here is a collection of Jupyter Notebooks, some of the workflows are split over
* [input_generation_example_2_frequency_vectors](input_generation_example_2_frequency_vectors.ipynb) define Poisson input with multiple start/stop times (uses [simple_network_creation](simple_network_creation.ipynb)).
* [input_generation_example_3_correlation](input_generation_example_3_correlation.ipynb) finer control in input targeting (uses [population_unit_network](population_unit_network.ipynb))
* [input_tuning_example](input_tuning_example.ipynb) explore what input number and frequency are good neurons, e.g to avoid depolarisation block.
* [Adanced input tuning](../parallel/KTH_PDC/input_tuning/) using the Dardel super computer. Here both background and signal level are optimised.
* [Advanced input tuning](../parallel/KTH_PDC/input_tuning/) using the Dardel super computer. Here both background and signal level are optimised, and the result is written to meta.json in BasalGangliaData.
* [input_frequency](InputFrequency/InputFrequency.ipynb) time varying input frequency example
* [basal_ganglia_data_input](Input-generation-using-BasalGangliaData.ipynb) builds upon the input tuned in BasalGangliaData.

## Striatum example
* [striatum_example](striatum_example.ipynb) creates a small striatal network, increase number of neurons for the full version.
Expand Down
40 changes: 40 additions & 0 deletions examples/notebooks/input_config/basal-ganglia-data-input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"dSPN": {
"cortical:1" : {
"generator" : "poisson",
"start" : [1, 4],
"end" : [3, 6],
"frequency" : [5, 5],
"populationUnitID" : 1
},

"cortical:2" : {
"generator" : "poisson",
"start" : [4],
"end" : [6],
"frequency" : [10],
"populationUnitID" : 2
}
},


"iSPN": {
"cortical:1" : {
"generator" : "poisson",
"start" : [1, 4],
"end" : [3, 6],
"frequency" : [5, 5],
"populationUnitID" : 1
},

"cortical:2" : {
"generator" : "poisson",
"start" : [4],
"end" : [6],
"frequency" : [10],
"populationUnitID" : 2
}
}


}
4 changes: 4 additions & 0 deletions examples/notebooks/input_tuning_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"id": "heated-thousand",
"metadata": {},
"source": [
"__Update__\n",
"\n",
"__There is an more extensive and updated version of this using parallel computing [here](../parallel/KTH_PDC/input_tuning)__\n",
"\n",
"Different morphologies of the same neuron type might require different activation to reach comparable firing frequency. InputScaling simulates a network of a neuron type with different number of inputs, and different frequency to infer what level of input is needed.\n",
"\n",
"Here we look at the input to ```neuron_types=\"fs\"```.\n",
Expand Down
13,702 changes: 2,852 additions & 10,850 deletions examples/parallel/KTH_PDC/input_tuning/Analyse_input_tuning_background_dspn.ipynb

Large diffs are not rendered by default.

12,662 changes: 6,569 additions & 6,093 deletions examples/parallel/KTH_PDC/input_tuning/Analyse_input_tuning_background_fs.ipynb

Large diffs are not rendered by default.

6,717 changes: 1,090 additions & 5,627 deletions examples/parallel/KTH_PDC/input_tuning/Analyse_input_tuning_background_ispn.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
export SNUDDA_TUNE_NEURON="dspn"
export SEED_LIST="[10,20,30,40,50]"
export INPUT_TYPE="cortical"
export INPUT_FREQ=40
export INPUT_FREQ=10

# You need to point this as the directory where you created the network in
#NETWORK_DIR=/cfs/klemming/home/${USER:0:1}/$USER/Snudda/examples/parallel/KTH_PDC/networks/test_10k
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#SBATCH --partition=main
#SBATCH -o log/InputTuning-%j-output.txt
#SBATCH -e log/InputTuning-%j-error.txt
#SBATCH -t 6:59:00
#SBATCH --time-min=5:59:00
#SBATCH -t 3:59:00
#SBATCH --time-min=2:59:00
#SBATCH -J InputTuning
#SBATCH -A naiss2023-5-231
#SBATCH --nodes=8-12
Expand All @@ -14,10 +14,11 @@
export SNUDDA_TUNE_NEURON="fs"
export SEED_LIST="[10,20,30,40,50]"
export INPUT_TYPE="cortical"
export INPUT_FREQ=10

# You need to point this as the directory where you created the network in
#NETWORK_DIR=/cfs/klemming/home/${USER:0:1}/$USER/Snudda/examples/parallel/KTH_PDC/networks/test_10k
NETWORK_DIR=networks/input_tuning_${SNUDDA_TUNE_NEURON}_${INPUT_TYPE}_signal
NETWORK_DIR=networks/input_tuning_${SNUDDA_TUNE_NEURON}_${INPUT_TYPE}_signal_${INPUT_FREQ}Hz

# This is used for NEURON
export N_WORKERS=$SLURM_NTASKS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#SBATCH --partition=main
#SBATCH -o log/InputTuning-%j-output.txt
#SBATCH -e log/InputTuning-%j-error.txt
#SBATCH -t 8:59:00
#SBATCH --time-min=7:59:00
#SBATCH -t 3:59:00
#SBATCH --time-min=2:59:00
#SBATCH -J InputTuning
#SBATCH -A naiss2023-5-231
#SBATCH --nodes=8-12
Expand All @@ -14,10 +14,11 @@
export SNUDDA_TUNE_NEURON="ispn"
export SEED_LIST="[10,20,30,40,50]"
export INPUT_TYPE="cortical"
export INPUT_FREQ=10

# You need to point this as the directory where you created the network in
#NETWORK_DIR=/cfs/klemming/home/${USER:0:1}/$USER/Snudda/examples/parallel/KTH_PDC/networks/test_10k
NETWORK_DIR=networks/input_tuning_${SNUDDA_TUNE_NEURON}_${INPUT_TYPE}_signal
NETWORK_DIR=networks/input_tuning_${SNUDDA_TUNE_NEURON}_${INPUT_TYPE}_signal_${INPUT_FREQ}Hz

# This is used for NEURON
export N_WORKERS=$SLURM_NTASKS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
export SNUDDA_TUNE_NEURON="dspn"
export SEED_LIST="[10,20,30,40,50]"
export INPUT_TYPE="thalamic"
export INPUT_FREQ=40
export INPUT_FREQ=10

# You need to point this as the directory where you created the network in
#NETWORK_DIR=/cfs/klemming/home/${USER:0:1}/$USER/Snudda/examples/parallel/KTH_PDC/networks/test_10k
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#SBATCH --partition=main
#SBATCH -o log/InputTuning-%j-output.txt
#SBATCH -e log/InputTuning-%j-error.txt
#SBATCH -t 6:59:00
#SBATCH --time-min=5:59:00
#SBATCH -t 3:59:00
#SBATCH --time-min=1:59:00
#SBATCH -J InputTuning
#SBATCH -A naiss2023-5-231
#SBATCH --nodes=8-12
Expand All @@ -14,10 +14,11 @@
export SNUDDA_TUNE_NEURON="fs"
export SEED_LIST="[10,20,30,40,50]"
export INPUT_TYPE="thalamic"
export INPUT_FREQ=10

# You need to point this as the directory where you created the network in
#NETWORK_DIR=/cfs/klemming/home/${USER:0:1}/$USER/Snudda/examples/parallel/KTH_PDC/networks/test_10k
NETWORK_DIR=networks/input_tuning_${SNUDDA_TUNE_NEURON}_${INPUT_TYPE}_signal
NETWORK_DIR=networks/input_tuning_${SNUDDA_TUNE_NEURON}_${INPUT_TYPE}_signal_${INPUT_FREQ}Hz

# This is used for NEURON
export N_WORKERS=$SLURM_NTASKS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#SBATCH --partition=main
#SBATCH -o log/InputTuning-%j-output.txt
#SBATCH -e log/InputTuning-%j-error.txt
#SBATCH -t 8:59:00
#SBATCH --time-min=7:59:00
#SBATCH -t 3:59:00
#SBATCH --time-min=2:59:00
#SBATCH -J InputTuning
#SBATCH -A naiss2023-5-231
#SBATCH --nodes=8-12
Expand All @@ -14,10 +14,11 @@
export SNUDDA_TUNE_NEURON="ispn"
export SEED_LIST="[10,20,30,40,50]"
export INPUT_TYPE="thalamic"
export INPUT_FREQ=10

# You need to point this as the directory where you created the network in
#NETWORK_DIR=/cfs/klemming/home/${USER:0:1}/$USER/Snudda/examples/parallel/KTH_PDC/networks/test_10k
NETWORK_DIR=networks/input_tuning_${SNUDDA_TUNE_NEURON}_${INPUT_TYPE}_signal
NETWORK_DIR=networks/input_tuning_${SNUDDA_TUNE_NEURON}_${INPUT_TYPE}_signal_${INPUT_FREQ}Hz

# This is used for NEURON
export N_WORKERS=$SLURM_NTASKS
Expand Down
131 changes: 131 additions & 0 deletions examples/parallel/KTH_PDC/input_tuning/Dardel_verify_cortical_dspn.job
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#!/bin/bash -l
#SBATCH --partition=main
#SBATCH -o log/InputTuning-%j-output.txt
#SBATCH -e log/InputTuning-%j-error.txt
#SBATCH -t 3:59:00
#SBATCH --time-min=2:59:00
#SBATCH -J InputTuning
#SBATCH -A naiss2023-5-231
#SBATCH --nodes=4
#SBATCH --tasks-per-node=128
#SBATCH --mem-per-cpu=930M
#SBATCH --mail-type=ALL

export SNUDDA_TUNE_NEURON="dspn"
export INPUT_TYPE="cortical"

# You need to point this as the directory where you created the network in
#NETWORK_DIR=/cfs/klemming/home/${USER:0:1}/$USER/Snudda/examples/parallel/KTH_PDC/networks/test_10k
NETWORK_DIR=networks/verify_input_${SNUDDA_TUNE_NEURON}_${INPUT_TYPE}

# This is used for NEURON
export N_WORKERS=$SLURM_NTASKS

# export N_WORKERS=50
# export IPNWORKERS=$N_WORKERS

# This is used for ipyparallel and Snudda
export IPNWORKERS=100

# Clear old ipyparallel
export IPYTHONDIR="/cfs/klemming/scratch/${USER:0:1}/$USER/.ipython"
rm -r $IPYTHONDIR
export IPYTHON_PROFILE=default

module load snic-env
source $HOME/Snudda/snudda_env/bin/activate
SNUDDA_DIR=/cfs/klemming/home/"${USER:0:1}"/$USER/Snudda


# If the BasalGangliaData directory exists, then use that for our data
if [[ -d "/cfs/klemming/home/${USER:0:1}/$USER/BasalGangliaData/data" ]]; then
export SNUDDA_DATA="/cfs/klemming/home/${USER:0:1}/$USER/BasalGangliaData/data"
echo "Setting SNUDDA_DATA to $SNUDDA_DATA"
rm mechanisms
ln -s $SNUDDA_DATA/neurons/mechanisms/ mechanisms
else
echo "SNUDDA_DATA environment variable not changed (may be empty): $SNUDDA_DATA"
rm mechanisms
ln -s ../../../snudda/data/neurons/mechanisms/
fi


# Start ipyparallel
#.. Start the ipcontroller
export FI_CXI_DEFAULT_VNI=$(od -vAn -N4 -tu < /dev/urandom)
srun -n 1 -N 1 -c 2 --exact --overlap --mem=0 ./../ipcontroller_new.sh &


echo ">>> waiting 60s for controller to start"
sleep 60

#.. Read in CONTROLLERIP
CONTROLLERIP=$(<controller_ip.txt)

##.. Start the engines
echo ">>> starting ${IPNWORKERS} engines "
echo "SLURM_JOB_NUM_NODES={SLURM_JOB_NUM_NODES}"

export FI_CXI_DEFAULT_VNI=$(od -vAn -N4 -tu < /dev/urandom)
srun -n ${IPNWORKERS} -c 2 -N ${SLURM_JOB_NUM_NODES} --exact --overlap --mem=0 ipengine \
--location=${CONTROLLERIP} --profile=${IPYTHON_PROFILE} --mpi \
--ipython-dir=${IPYTHONDIR} --timeout=30.0 c.EngineFactory.max_heartbeat_misses=10 c.MPI.use='mpi4py' \
1> ipe_${SLURM_JOBID}.out 2> ipe_${SLURM_JOBID}.err &


echo ">>> waiting 60s for engines to start"
sleep 30


echo "Network dir: "$NETWORK_DIR

export PATH=$SNUDDA_DIR/snudda_env/bin/:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CRAY_LD_LIBRARY_PATH
export PYTHONPATH=$SNUDDA_DIR/snudda_env/lib/python3.9/

# This will stop NEURON from failing with "can't open DISPLAY"
unset DISPLAY

# Do we need this magic?
# export FI_CXI_DEFAULT_VNI=$(od -vAn -N4 -tu < /dev/urandom)
# srun -n 1 python test_script.py &> test_print.txt

export FI_CXI_DEFAULT_VNI=$(od -vAn -N4 -tu < /dev/urandom)

# srun -n 1 python setup_input_tuning_background.py &> log/setup_network_log.txt
srun -n 1 -N 1 --exact --overlap --mem=0 python setup_verify_input_tuning.py &> log/setup_network_log.txt


# Quit ipyparallel

python ../ipcontroller_shutdown.py


##############

rm -r x86_64

export CXX=CC
export CC=cc
export FC=ftn
export MPICC=cc
export MPICXX=CC

CC --version

echo "About to run nrnivmodl"
which nrnivmodl

# srun -n nrnivmodl mechanisms/

# Do we need this magic?
export FI_CXI_DEFAULT_VNI=$(od -vAn -N4 -tu < /dev/urandom)

srun -n 1 nrnivmodl -incflags "-lltdl=/usr/lib64/libltdl.so.7 -lreadline=/lib64/libreadline.so.7 -lncurses=/lib64/libncurses.so.6.1" -loadflags "-DLTDL_LIBRARY=/usr/lib64/libltdl.so.7 -DREADLINE_LIBRARY=/lib64/libreadline.so.7 -DNCURSES_LIBRARY=/lib64/libncurses.so.6.1" mechanisms/

# Do we need this magic?
export FI_CXI_DEFAULT_VNI=$(od -vAn -N4 -tu < /dev/urandom)

srun -n $N_WORKERS $SNUDDA_DIR/examples/parallel/KTH_PDC/input_tuning/x86_64/special -mpi -python $SNUDDA_DIR/snudda/input/input_tuning.py simulate $NETWORK_DIR


Loading

0 comments on commit 52a019f

Please sign in to comment.