README for pulse_inject demo scripts ------------------------------------ These files are meant to be examples for tutorials on creating Python GUIs for G-3 single cell simulations, similar to those used in GENESIS 2 with SLI XODUS commands. The model and simulation parameters are contained in 'simplecell_pulse_sim.py', in the definition of the class G3Sim(). On instantiation, it loads a cell model, which in this case, is 'cells/simplecell-nolib.ndf', and sets up a simulation with a 'pulsegen' object to provide pulsed current injection to the cell soma. It has the option (set as the default) to use a 'live_output' output device as well output to a file with 'double_2_ascii' to output the soma membrane potential Vm. With minimal modifications, it could use another cell model such as the edsjb1994 Purkinje cell model used in the SSPy test script 'tests/python/pulsegen_freerun_api.py'. The 'G3Sim' class also defines methods set_inject_pulse(current, delay, width, interval) to set the injection parameters, and run_simulation(simulationtime) to run the simulation for the specified time. These are designed to be called from the main script that creates the simulation and its GUI. When 'simplecell_pulse_sim.py' is run as a main script, it creates a G3Sim instance 'mySim', sets injection parameters and outputs, then runs it for 0.5 seconds. The main script 'simplecell_pulse_main.py' adds a control panel and a graph for running the simulation, changing the runtime and injection pulse parameters, or toggling the injection ON and OFF. The RESET button invokes the Reset() method on both the scheduler and the graph. When the Overlay toggle is OFF (default), the Reset() method of the graph clears the graph. Otherwise, it redraws it without clearing, so that the next RUN will overlay it with a new plot. The additional imported files are: ---------------------------------- cpanel_pulse_inject.py - defines a generic Control Panel class CPanelFrame(wx.Frame) that provides buttons, "dialogs", labels, and toggles to control the simulation. It forms these from custom classes defined in 'G2Xwidgets.py'. When run as a main script, it creates a Control Panel with default labels and dialog entry values. simplecell_pulse_main.py defines the actions that will be performed by mouse clicks or text entry in these widgets. [Current problem: I have been unable to get the widgets to expand in width when the frame is resized.] G2Xwidgets.py - This defines a set of G-3 widget classes that have the appearance and functionality of the XODUS widgets that are used with GENESIS 2 SLI scripts. These are implemented as customized versions of wxPython generic widget classes. Note that the 'XDialog' class is not the usual pop-up dialog window, but is what some graphics packages call a "labeled text entry widget". It is implemented as a panel containing a label and a widget for text entry (e.g. the wxPython TextCtrl). The XToggle class extends the GenToggleButton class to add separate background and foreground colors for ON and OFF states. GXgraph.py - This script was adapted from gtube/plot/__init__.py, which is used for the g3plot utility. It creates a frame with a toolbar that holds a G-3 graph (2D 'y vs. x' plot). The graph allows multiple plots from multicolumn data "x, y1, y2, ..." given at successive x-values. The data to be plotted is represented as a list of lists, as would be generated by the G-3 live_output option. Running this as a main program generates a test plot of sin and cos data vs. time. The frame and graph are created from the class Xgraph defined here. [Current problem: Although the axes are properly scaled when running GXgraph.py to plot the test data, I can't set the axes xmin, xmax, ymin, and ymax when I create a Xgraph instance from the 'simplecell_pulse_main.py' script.] Dave Beeman June 2012