@@ -14,7 +14,9 @@ def __init__(self, C_m=1, gmax_Na=120, gmax_K=36, gmax_L=0.3, E_Na=50,
1414 E_K = - 77 , E_L = - 54.387 , t_0 = 0 , t_n = 450 , delta_t = 0.01 ,
1515 I_inj_amplitude = 0 , I_inj_duration = 0 , I_inj_delay = 0 ,
1616 vc_delay = 10 , vc_duration = 30 , vc_condVoltage = - 65 ,
17- vc_testVoltage = 10 , vc_returnVoltage = - 65 , runMode = 'iclamp' ):
17+ vc_testVoltage = 10 , vc_returnVoltage = - 65 , runMode = 'iclamp' ,
18+ injected_current_plot = True , gating_plot = True , cond_dens_plot = True ,
19+ current_plot = True , memb_pot_plot = True ):
1820
1921 self .C_m = C_m
2022 """ membrane capacitance, in uF/cm^2 """
@@ -73,6 +75,19 @@ def __init__(self, C_m=1, gmax_Na=120, gmax_K=36, gmax_L=0.3, E_Na=50,
7375 self .simpleSeriesResistance = 1e7
7476 """Current will be calculated by the difference in voltage between the target and parent, divided by this value, in mOhm"""
7577
78+ # plotting conditionals
79+ self .injected_current_plot = injected_current_plot
80+ self .gating_plot = gating_plot
81+ self .cond_dens_plot = cond_dens_plot
82+ self .current_plot = current_plot
83+ self .memb_pot_plot = memb_pot_plot
84+
85+ self .num_plots = (int (self .injected_current_plot ) +
86+ int (self .gating_plot ) + int (self .cond_dens_plot ) +
87+ int (self .current_plot ) + int (self .memb_pot_plot ))
88+
89+ self .plot_count = 0
90+
7691 def alpha_m (self , V ):
7792 """Channel gating kinetics. Functions of membrane voltage"""
7893 return 0.1 * (V + 40.0 )/ (1.0 - np .exp (- (V + 40.0 ) / 10.0 ))
@@ -268,53 +283,79 @@ def Main(self, init_values=[-64.99584, 0.05296, 0.59590, 0.31773]):
268283 plt .rcParams ['figure.figsize' ] = [10 , 7 ]
269284
270285 plt .close ()
271- fig = plt .figure ()
272- fig .canvas .header_visible = False
273286
274- ax1 = plt .subplot (5 ,1 ,1 )
287+ fig = plt .figure (figsize = (7 , self .num_plots * 2 ))
288+ fig .canvas .header_visible = False
275289 plt .xlim ([np .min (self .t ),np .max (self .t )]) #for all subplots
276- plt .title ('Simulation of Hodgkin Huxley model neuron' )
277290
278- if self .is_vclamp ():
279- i_inj_values = [self .I_inj_vclamp (t ,v ) for t ,v in zip (self .t ,V )]
280- else :
281- i_inj_values = [self .I_inj (t ) for t in self .t ]
282-
283- plt .plot (self .t , i_inj_values , 'k' )
284- plt .ylabel ('$I_{inj}$ ($\\ mu{A}/cm^2$)' )
285- if self .is_vclamp (): plt .ylim (- 2000 ,3000 )
286-
287-
288- plt .subplot (5 ,1 ,2 , sharex = ax1 )
289- plt .plot (self .t , m , 'r' , label = 'm' )
290- plt .plot (self .t , h , 'g' , label = 'h' )
291- plt .plot (self .t , n , 'b' , label = 'n' )
292- plt .ylabel ('Gating Variable' )
293- plt .legend ()
294-
295- plt .subplot (5 ,1 ,3 , sharex = ax1 )
296- plt .plot (self .t , gna , 'c' , label = '$g_{Na}$' )
297- plt .plot (self .t , gk , 'y' , label = '$g_{K}$' )
298- plt .ylabel ('Cond. dens' )
299- plt .legend ()
300-
301- plt .subplot (5 ,1 ,4 , sharex = ax1 )
302- plt .plot (self .t , ina , 'c' , label = '$I_{Na}$' )
303- plt .plot (self .t , ik , 'y' , label = '$I_{K}$' )
304- plt .plot (self .t , il , 'm' , label = '$I_{L}$' )
305- plt .ylabel ('Current' )
306- plt .legend ()
307-
308- plt .subplot (5 ,1 ,5 , sharex = ax1 )
309- plt .plot (self .t , V , 'k' )
310- plt .ylabel ('V (mV)' )
311- plt .xlabel ('t (ms)' )
312- if not self .is_vclamp (): plt .ylim (- 85 ,60 )
313- #plt.ylim(-1, 40)
291+ if self .injected_current_plot :
292+ ax1 = plt .subplot (self .num_plots ,1 ,self .plot_count + 1 )
293+ plt .title ('Simulation of Hodgkin Huxley model neuron' )
294+ if self .is_vclamp ():
295+ i_inj_values = [self .I_inj_vclamp (t ,v ) for t ,v in zip (self .t ,V )]
296+ else :
297+ i_inj_values = [self .I_inj (t ) for t in self .t ]
298+
299+ if self .is_vclamp (): plt .ylim (- 2000 ,3000 )
300+
301+ plt .plot (self .t , i_inj_values , 'k' )
302+ plt .ylabel ('$I_{inj}$ ($\\ mu{A}/cm^2$)' )
303+
304+ self .plot_count += 1
305+
306+
307+ if self .gating_plot :
308+ try :
309+ plt .subplot (self .num_plots ,1 ,self .plot_count + 1 , sharex = ax1 )
310+ except NameError :
311+ ax1 = plt .subplot (self .num_plots ,1 ,self .plot_count + 1 )
312+ plt .title ('Simulation of Hodgkin Huxley model neuron' )
313+ plt .plot (self .t , m , 'r' , label = 'm' )
314+ plt .plot (self .t , h , 'g' , label = 'h' )
315+ plt .plot (self .t , n , 'b' , label = 'n' )
316+ plt .ylabel ('Gating Variable' )
317+ plt .legend ()
318+ self .plot_count += 1
319+
320+ if self .cond_dens_plot :
321+ try :
322+ plt .subplot (self .num_plots ,1 ,self .plot_count + 1 , sharex = ax1 )
323+ except NameError :
324+ ax1 = plt .subplot (self .num_plots ,1 ,self .plot_count + 1 )
325+ plt .title ('Simulation of Hodgkin Huxley model neuron' )
326+ plt .plot (self .t , gna , 'c' , label = '$g_{Na}$' )
327+ plt .plot (self .t , gk , 'y' , label = '$g_{K}$' )
328+ plt .ylabel ('Cond. dens' )
329+ plt .legend ()
330+ self .plot_count += 1
331+
332+ if self .current_plot :
333+ try :
334+ plt .subplot (self .num_plots ,1 ,self .plot_count + 1 , sharex = ax1 )
335+ except NameError :
336+ ax1 = plt .subplot (self .num_plots ,1 ,self .plot_count + 1 )
337+ plt .title ('Simulation of Hodgkin Huxley model neuron' )
338+ plt .plot (self .t , ina , 'c' , label = '$I_{Na}$' )
339+ plt .plot (self .t , ik , 'y' , label = '$I_{K}$' )
340+ plt .plot (self .t , il , 'm' , label = '$I_{L}$' )
341+ plt .ylabel ('Current' )
342+ plt .legend ()
343+ self .plot_count += 1
344+
345+ if self .memb_pot_plot :
346+ try :
347+ plt .subplot (self .num_plots ,1 ,self .plot_count + 1 , sharex = ax1 )
348+ except NameError :
349+ ax1 = plt .subplot (self .num_plots ,1 ,self .plot_count + 1 )
350+ plt .title ('Simulation of Hodgkin Huxley model neuron' )
351+ plt .plot (self .t , V , 'k' )
352+ plt .ylabel ('V (mV)' )
353+ plt .xlabel ('t (ms)' )
354+ if not self .is_vclamp (): plt .ylim (- 85 ,60 )
355+ #plt.ylim(-1, 40)
356+ self .plot_count += 1
314357
315358 plt .tight_layout ()
316-
317-
318359 plt .show ()
319360
320361if __name__ == '__main__' :
0 commit comments