NEURON Cheat Sheet

Compile all .mod files in directory

 nrnivmodl #NRN IV MOD L

Use variable step integration

h.cvode_active(1) # or 0 for fixed, note the _ 
h.cvode.atol(0.01) # for tolerance 0.001 is default

Run sim till a specific time

h.continuerun(tstop)

Record value e.g. memb pot

vVector = h.Vector() 
vVector.record(section(0.5)._ref_v) #Use h._ref_t for time #Then, after h.run()
vVector.to_pyton() to get an array

Collect at regular period, even with cvode()

collector_stim = h.NetStim(0.5)
collector_stim.start = 0
collector_stim.number = 1e9
collector_stim.noise = 0
collector_stim.interval = collection_period_ms
collector_con = h.NetCon(collector_stim, None)
collector_con.record((collect_var_method, param1_to_method)) # method called every collection_period_ms
keep = h.FInitializeHandler(clear_collected_values_method)

Show the standard run panel

h.nrncontrolmenu()

Show a graph of default section voltage

h.newPlotV()

Automate Atol Tool

This will run the atoltool, save tolerances, close atoltool panel:

h.NumericalMethodPanel[0].map()
h.NumericalMethodPanel[0].atoltool()
h.tstop = tstop

print("Getting error tolerances...")
h.AtolTool[0].anrun()
h.AtolTool[0].rescale()
h.AtolTool[0].fill_used()

h.save_session('atols.ses')
print("Error tolerances saved")

h.AtolTool[0].box.unmap()
h.NumericalMethodPanel[0].b1.unmap()

To restore the saved tolerances:

h.load_file('atols.ses')

h.NumericalMethodPanel[0].b1.unmap()
print("Using saved error tolerances")

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s