1+ import os
2+ # Force headless plotting for Matplotlib (as in RE_netpy)
3+ os .environ ["MPLBACKEND" ] = "Agg"
4+ import matplotlib
5+ matplotlib .use ("Agg" )
6+ # Ensure NEURON runs headless in non-GUI environments
7+ os .environ ["NEURON_NO_GUI" ] = "1"
8+ os .environ .pop ("DISPLAY" , None )
9+ print (f"[IT2_netpy] Headless env: DISPLAY={ os .environ .get ('DISPLAY' )} , NEURON_NO_GUI={ os .environ .get ('NEURON_NO_GUI' )} , MPLBACKEND={ os .environ .get ('MPLBACKEND' )} " )
10+
111from netpyne import specs , sim
212import pprint
313
4- netParams = specs .NetParams ()
5- ## IT2 cell properties
6- soma = {'geom' : {}, 'ions' : {}, 'mechs' : {}, 'vinit' : - 85.7 , 'threshold' : 5.0 }
14+ netParams = specs .NetParams ()
15+
16+ ## IT2 cell properties (NetPyNE version using same mechanisms as IT2_reduced_cell.nml)
17+ soma = {'geom' : {}, 'ions' : {}, 'mechs' : {}, 'vinit' : - 85.7 , 'threshold' : 5.0 }
718soma ['geom' ] = {'diam' : 28.2149102762 , 'L' : 48.4123467666 , 'Ra' : 70.0015514222 , 'cm' : 2.4998269977 , 'nseg' : 1 , 'pt3d' : []}
819soma ['geom' ]['pt3d' ].append ((0 , 0 , 0 , 28.2149102762 ))
920soma ['geom' ]['pt3d' ].append ((0 , 48.4123467666 , 0 , 28.2149102762 ))
144155
145156netParams .popParams ['IT2' ] = {'cellType' : 'IT2_HH_reduced' , 'numCells' : 1 }
146157
147- netParams .stimSourceParams ['Input' ] = {'type' : 'IClamp' , 'dur' : 1600 , 'del' : 200 , 'amp' : 0.3 }
158+ netParams .stimSourceParams ['Input' ] = {'type' : 'IClamp' , 'dur' : 300 , 'del' : 200 , 'amp' : 0.3 }
148159netParams .stimTargetParams ['Input->IT2' ] = {'source' : 'Input' , 'sec' : 'soma' , 'loc' : 0.5 , 'conds' : {'cellType' : 'IT2_HH_reduced' }}
149160netParams .defaultThreshold = 5.0
150161# Simulation options
151162simConfig = specs .SimConfig () # object of class SimConfig to store simulation configuration
152163
153164simConfig .recordCells = ['all' ]
154165simConfig .hParams ['celsius' ] = 34
155- simConfig .duration = 2000 # Duration of the simulation, in ms
156- simConfig .dt = 0.01
157- # Internal integration timestep to use
166+ simConfig .duration = 700 # Duration of the simulation, in ms
167+ simConfig .dt = 0.025 # Internal integration timestep to use
158168simConfig .verbose = False # Show detailed messages
159- simConfig .recordTraces = {'V_soma' :{'sec' :'soma' ,'loc' :0.5 ,'var' :'v' }} # Dict with traces to record
160- simConfig .recordStep = 0.01 # Step size in ms to save data (eg. V traces, LFP, etc)
161- simConfig .filename = 'IT2_reduced_all' # Set file output name
162- simConfig .savePickle = False # Save params, network and sim output to pickle file
163- simConfig .saveDataInclude = ['simData' ]
164- simConfig .saveJson = True
165- simConfig . analysis [ 'plotTraces' ] = { 'include' : [ 0 ], 'saveFig' : True } # Plot recorded traces for this list of cells
166- simConfig .analysis [ 'plotRaster' ] = {'saveFig' : True } # Plot a raster
169+ simConfig .recordTraces = {'V_soma' : {'sec' : 'soma' , 'loc' : 0.5 , 'var' : 'v' }}
170+ simConfig .recordStep = 0.025 # Step size in ms to save data
171+ simConfig .filename = 'IT2_reduced_all'
172+ simConfig .savePickle = False
173+ simConfig .saveDataInclude = ['simData' ]
174+ simConfig .saveJson = True
175+ # Disable built-in plotting during headless runs
176+ simConfig .analysis = {}
167177
168178# Create network and run simulation
169179sim .createSimulateAnalyze (netParams = netParams , simConfig = simConfig )
170180
171- #import pylab; pylab.show() # this line is only necessary in certain systems where figures appear empty
181+ #import pylab; pylab.show() # this line is only necessary in certain systems where figures appear empty
0 commit comments