2525from bluecellulab .analysis .inject_sequence import run_multirecordings_stimulus
2626from bluecellulab .analysis .inject_sequence import run_stimulus
2727from bluecellulab .cell .core import Cell
28+ from bluecellulab .simulation .neuron_globals import NeuronGlobals
2829from bluecellulab .stimulus .factory import IDRestTimings
2930from bluecellulab .stimulus .factory import StimulusFactory
3031from bluecellulab .tools import calculate_input_resistance
3334logger = logging .getLogger (__name__ )
3435
3536
36- def plot_trace (recording , out_dir , fname , title ):
37+ def plot_trace (recording , out_dir , fname , title , plot_current = True ):
3738 """Plot a trace with inout current given a recording."""
3839 outpath = out_dir / fname
3940 fig , ax1 = plt .subplots (figsize = (10 , 6 ))
4041 plt .plot (recording .time , recording .voltage , color = "black" )
41- current_axis = ax1 .twinx ()
42- current_axis .plot (recording .time , recording .current , color = "gray" , alpha = 0.6 )
43- current_axis .set_ylabel ("Stimulus Current [nA]" )
44- fig .suptitle (title )
42+ if plot_current :
43+ current_axis = ax1 .twinx ()
44+ current_axis .plot (recording .time , recording .current , color = "gray" , alpha = 0.6 )
45+ current_axis .set_ylabel ("Stimulus Current [nA]" )
46+ if title :
47+ fig .suptitle (title )
4548 ax1 .set_xlabel ("Time [ms]" )
4649 ax1 .set_ylabel ("Voltage [mV]" )
4750 fig .tight_layout ()
@@ -410,20 +413,61 @@ def fi_test(template_params, rheobase, out_dir, spike_threshold_voltage=-30.):
410413 }
411414
412415
416+ def thumbnail_test (template_params , rheobase , out_dir ):
417+ """Thumbnail test: creating a thumbnail."""
418+ stim_factory = StimulusFactory (dt = 1.0 )
419+ step_stimulus = stim_factory .idrest (threshold_current = rheobase , threshold_percentage = 130 )
420+ recording = run_stimulus (
421+ template_params ,
422+ step_stimulus ,
423+ "soma[0]" ,
424+ 0.5 ,
425+ add_hypamp = True ,
426+ )
427+
428+ # plotting
429+ outpath = plot_trace (
430+ recording ,
431+ out_dir ,
432+ fname = "thumbnail.pdf" ,
433+ title = "" ,
434+ plot_current = False
435+ )
436+
437+ return {
438+ "name" : "thumbnail" ,
439+ "passed" : True ,
440+ "validation_details" : "" ,
441+ "figures" : [outpath ],
442+ }
443+
444+
413445def run_validations (
414- cell , cell_name , spike_threshold_voltage = - 30 , output_dir = "./memodel_validation_figures"
446+ cell ,
447+ cell_name ,
448+ spike_threshold_voltage = - 30 ,
449+ v_init = - 80.0 ,
450+ celsius = 34.0 ,
451+ output_dir = "./memodel_validation_figures"
415452):
416453 """Run all the validations on the cell.
417454
418455 Args:
419456 cell (Cell): The cell to validate.
420457 cell_name (str): The name of the cell, used in the output directory.
421458 spike_threshold_voltage (float): The voltage threshold for spike detection.
459+ v_init: Initial membrane potential. Default is -80.0 mV.
460+ celsius: Temperature in Celsius. Default is 34.0.
422461 output_dir (str): The directory to save the validation figures.
423462 """
424463 out_dir = pathlib .Path (output_dir ) / cell_name
425464 out_dir .mkdir (parents = True , exist_ok = True )
426465
466+ # set initial voltage and temperature
467+ neuron_globals = NeuronGlobals .get_instance ()
468+ neuron_globals .temperature = celsius
469+ neuron_globals .v_init = v_init
470+
427471 # get me-model properties
428472 holding_current = cell .hypamp if cell .hypamp else 0.0
429473 if cell .threshold :
@@ -473,6 +517,9 @@ def run_validations(
473517 # Validation 9: FI Test
474518 fi_test_result = fi_test (cell .template_params , rheobase , out_dir , spike_threshold_voltage )
475519
520+ # Validation 10: Thumbnail Test
521+ thumbnail_result = thumbnail_test (cell .template_params , rheobase , out_dir )
522+
476523 return {
477524 "memodel_properties" : {
478525 "holding_current" : holding_current ,
@@ -487,4 +534,5 @@ def run_validations(
487534 "rin_test" : rin_result ,
488535 "iv_test" : iv_test_result ,
489536 "fi_test" : fi_test_result ,
537+ "thumbnail_test" : thumbnail_result ,
490538 }
0 commit comments