@@ -16,26 +16,33 @@ def resetTodefault(_):
1616 slider_amplitude .value = 50
1717 slider_width .value = 0
1818 slider_translation .value = 50
19- cb .value = False
20-
21- #function to define injector current parameters and plot
22- def injectorCurrent (amplidute = 10 , t_width = 100 , t_translation = 100 ):
23- t = np .arange (0 , 450 , 5 ) #range for plotting only not used in simulation
24- for i in t :
25- I_inj = amplidute * (t > t_translation ) - amplidute * (t > t_translation + t_width )
26- plt .figure ()
27- plt .plot (t , I_inj )
28- plt .xlabel ('t (ms)' , fontsize = 15 )
29- plt .ylabel ('$I_{inj}$ ($\\ mu{A}/cm^2$)' )
30- plt .show ()
31- #display(plt.show(),wid_plotArea)
3219
33- header_capacitance = ipywidgets .HTML (value = f"<b><font color='blue'>Membrane Capacitance, uF/cm^2</b>" )
34- header_conductance = ipywidgets .HTML (value = f"<b><font color='blue'>Maximum Conductances, mS/cm^2</b>" )
35- header_potential = ipywidgets .HTML (value = f"<b><font color='blue'>Nernst Reverasal Potentials, mV</b>" )
36- header_simTime = ipywidgets .HTML (value = f"<b><font color='blue'>Simulation Time, ms</b>" )
20+ #function to change slider handle colour when move from default
21+ def highlight_slider ():
22+ inputList = [slider_capacitance , slider_cond_Na , slider_cond_K , slider_cond_L , slider_pot_Na , slider_pot_K , slider_pot_L ]
23+ inputDefault = [1.0 , 120 , 36 , 0.3 , 50 , - 77 , - 54.387 ]
24+ for l , d in zip (inputList ,inputDefault ):
25+ if l .value == d :
26+ l .style .handle_color = 'white'
27+ else :
28+ l .style .handle_color = 'orange'
29+ if slider_width .value == 0.0 :
30+ slider_amplitude .style .handle_color = 'white'
31+ slider_width .style .handle_color = 'white'
32+ slider_translation .style .handle_color = 'white'
33+ else :
34+ slider_amplitude .style .handle_color = 'orange'
35+ slider_width .style .handle_color = 'orange'
36+ slider_translation .style .handle_color = 'orange'
37+
38+ header_capacitance = ipywidgets .HTMLMath (value = r"<b><font color='blue'>Membrane Capacitance, \(\mu{F}/cm^2\)</b>" )
39+ header_conductance = ipywidgets .HTMLMath (value = r"<b><font color='blue'>Maximum Conductances, \(mS/cm^2\)</b>" )
40+ header_potential = ipywidgets .HTMLMath (value = r"<b><font color='blue'>Nernst Reverasal Potentials, \(mV\)</b>" )
41+ header_simTime = ipywidgets .HTMLMath (value = r"<b><font color='blue'>Simulation Time, \(ms\)</b>" )
42+ header_injCurrent = ipywidgets .HTMLMath (value = r"<b><font color='blue'>Injection Current, \(\mu{A}/cm^2\)</b>" )
43+ injCurrent_note = ipywidgets .HTML (value = f"<i>*For injection current width = 0, the model uses default two pulse signal from tutorial</i>" )
3744slider_capacitance = ipywidgets .FloatSlider (value = 1 ,min = 0 ,max = 3 ,step = 0.1 ,description = 'Capacitance' ,readout_format = '.1f' ,continuous_update = False )
38- slider_cond_Na = ipywidgets .FloatSlider (value = 120 ,min = 80 ,max = 160 ,step = 0.1 ,description = 'Sodium' ,readout_format = '.1f' ,continuous_update = False )
45+ slider_cond_Na = ipywidgets .FloatSlider (value = 120 ,min = 0 ,max = 160 ,step = 0.1 ,description = 'Sodium' ,readout_format = '.1f' ,continuous_update = False )
3946slider_cond_K = ipywidgets .FloatSlider (value = 36 ,min = 0 ,max = 80 ,step = 0.1 ,description = 'Potassium' ,readout_format = '.1f' ,continuous_update = False )
4047slider_cond_L = ipywidgets .FloatSlider (value = 0.3 ,min = 0 ,max = 1 ,step = 0.1 ,description = 'Leak' ,readout_format = '.1f' ,continuous_update = False )
4148slider_pot_Na = ipywidgets .FloatSlider (value = 50 ,min = - 100 ,max = 100 ,step = 0.1 ,description = 'Sodium' ,readout_format = '.1f' ,continuous_update = False )
@@ -44,6 +51,9 @@ def injectorCurrent(amplidute=10, t_width=100, t_translation=100):
4451time_start = ipywidgets .FloatText (value = 0 ,description = 'Start Time' ,disabled = True )
4552time_end = ipywidgets .FloatText (value = 450 ,description = 'Total Time' ,disabled = False )
4653time_step = ipywidgets .FloatText (value = 0.01 ,description = 'Time Step' ,disabled = False )
54+ slider_amplitude = ipywidgets .FloatSlider (value = 50 ,min = - 20 ,max = 200 ,step = 0.1 ,description = 'Amplitude' ,readout_format = '.1f' ,continuous_update = False )
55+ slider_width = ipywidgets .FloatSlider (value = 0 ,min = 0 ,max = 500 ,step = 0.1 ,description = 'Width' ,readout_format = '.1f' ,continuous_update = False )
56+ slider_translation = ipywidgets .FloatSlider (value = 50 ,min = 0 ,max = 250 ,step = 0.1 ,description = 'Start at' ,readout_format = '.1f' ,continuous_update = False )
4757
4858reset_button = ipywidgets .Button (description = "Reset All" )
4959reset_button .on_click (resetTodefault )
@@ -56,11 +66,8 @@ def injectorCurrent(amplidute=10, t_width=100, t_translation=100):
5666h6 = ipywidgets .HBox ([slider_pot_Na ,slider_pot_K ,slider_pot_L ])
5767h7 = ipywidgets .HBox ([header_simTime ])
5868h8 = ipywidgets .HBox ([time_start ,time_end ,time_step ])
59- h9 = ipywidgets .HBox ([reset_button ])
60- basicInputs = ipywidgets .VBox ([h1 ,h2 ,h3 ,h4 ,h5 ,h6 ,h7 ,h8 ,h9 ])
61-
62- #Advanced Inputs
63- cb = ipywidgets .Checkbox (value = False ,description = f"<b><font color='blue'>Advanced Input - Incjection Current</b>" ,indent = False )
64- slider_amplitude = ipywidgets .FloatSlider (value = 50 ,min = - 100 ,max = 100 ,step = 1 ,description = 'Amplitude' ,readout_format = 'd' ,continuous_update = False )
65- slider_width = ipywidgets .FloatSlider (value = 0 ,min = 0 ,max = 500 ,step = 1 ,description = 'Width' ,readout_format = 'd' ,continuous_update = False )
66- slider_translation = ipywidgets .FloatSlider (value = 50 ,min = 0 ,max = 250 ,step = 1 ,description = 'Start at' ,readout_format = 'd' ,continuous_update = False )
69+ h9 = ipywidgets .HBox ([header_injCurrent ])
70+ h10 = ipywidgets .HBox ([injCurrent_note ])
71+ h11 = ipywidgets .HBox ([slider_amplitude ,slider_width ,slider_translation ])
72+ h12 = ipywidgets .HBox ([reset_button ])
73+ modelInputs = ipywidgets .VBox ([h1 ,h2 ,h3 ,h4 ,h5 ,h6 ,h7 ,h8 ,h9 ,h10 ,h11 ,h12 ])
0 commit comments