Thanks for this! This worked perfect.
I'm an undergrad doing some research. I'm not a CS major but I know enough to be dangerous. I was able to compile your code and get it working. I'm curious, do you know how I would change the connection rules as shown here (https://nest-simulator.readthedocs.io/en/v3.4/synapses/connection_management...) or should I open a new thread?