Abstract
Electrical stimulation is a simple and powerful tool to perturb and evoke neuronal activity in order to understand the function of neurons and neural circuits. Despite this, devices that can provide precise current or voltage stimulation are expensive and closed-source. Here, we introduce Stimjim, a capable and inexpensive ($200 USD) open-source instrument for electrical stimulation that combines both function generation and electrical isolation. Stimjim provides microsecond temporal resolution with microampere or millivolt scale precision on two electrically isolated output channels. We demonstrate Stimjim’s utility both in vitro by precisely stimulating brain slices, and in vivo by training mice to perform intracranial self-stimulation (ICSS) for brain stimulation reward. During ICSS, Stimjim enables the experimenter to smoothly tune the strength of reward-seeking behavior by varying either the output frequency or amplitude. We envision Stimjim will enable new kinds of experiments due to its open-source and scalable nature.
Introduction
Electrical stimulation of neural tissue is an invaluable and ubiquitous research tool. Over the past 150 years, it has helped researchers understand the function of various brain regions by directly inducing neurons in those regions to fire 1;2;3. More recently, it has also found important clinical applications in neurological disorders including Parkinson’s disease 4 and depression 5. However, to date, the hardware for performing precise current- and voltage-based electrical stimulation generally remains expensive and closed source.
In contrast, there has been a recent push within the scientific community to produce open labware – open source hardware and software replacements for a variety of common laboratory tasks 6;7;8. Examples in the life sciences include software and hardware for:
recording or stimulating neurons (e.g. Open Ephys 9;10, Miniscopes 11;12;13;14, and others 15;16;17)
amplifying DNA (e.g., OpenPCR 18)
electroporation 30
ecological monitoring (e.g., Audiomoth 31)
We now add Stimjim to this growing body of open hardware. Stimjim replaces commercial neural stimulators at a fraction of the cost, with improved programmability. Furthermore, due to its entirely open design and software, Stimjim can be modified by users to fit their specific needs.
Results
Design
We developed Stimjim to be a precise, electrically isolated stimulus generator. Stimjim is based on the Teensy 3.5 microcontroller board (www.pjrc.com/teensy), which utilizes a 32-bit Arm Cortex-M4F processor running at 120 MHz. Each stimulating channel includes a current source based on an improved Howland current pump 32, and a voltage source (an op-amp), driven by a 16-bit digital-to-analog converter (DAC). The final output of each channel is selected by a 4-way switch, such that either channel can be configured as a current output, voltage output, grounded, or disconnected. To ensure the stimulator is properly connected (a common issue with experiments in freely moving animals) and to verify required stimulus current or voltage amplitudes, each channel also has an analog-to-digital converter (ADC) able to read either the output voltage or the output current (via a low-value sense resistor in series with the current output). Our circuit board design was made using Kicad 33 (www.kicad-pcb.org), an open-source printed circuit board (PCB) design program. Schematic, layout, bill of materials, and build instructions are included as supplemental materials and are also available in the Stimjim git repository (bitbucket.org/natecermak/stimjim).
Stimjim’s design compares favorably against alternatives (Table 1). It is an order of magnitude less expensive than most commercial alternatives. Its only draw-back is that its compliance voltage is lower, which limits the load resistance that Stimjim can drive. For a given resistance R, each Stimjim channel cannot output a current larger than . Thus, Stimjim is not suitable for high-impedance electrodes such as pulled glass electrodes. Note however, that Stimjim’s compliance voltage can be doubled to roughly ± 27 V by connecting the two channels in series. As a low-cost open-source device, Stimjim is perhaps most similar to PulsePal 2, an open-source programmable pulse generator 34. However, it expands on PulsePal’s capabilities by including electrical isolation, current output mode, and on-board monitoring of output currents/voltages. Further electrical characteristics of Stimjim are given in Table 2.
Stimjim’s software is written in C++ using the the Arduino development environment. We provide an Arduino-compatible Stimjim library permitting low-level device control (writing registers in the DACs or ADCs, or setting the stimulation control mode). Library functions enable users to create new programs to run on Stimjim for example, generation of custom waveform outputs stored on the onboard SD card. We also provide a default program using this library that can generate user-defined pulse train sequences. Users set the parameters for pulse trains and read the measured pulse amplitudes via a 12 Mbit/s serial connection over USB. Pulse train parameters include output mode (current or voltage), frequency, duration, and the amplitude of each phase of the pulse itself. Stimjim can store definitions for 100 pulse trains concurrently, and users can select and initiate particular pulse trains on the fly.
Benchmarking
To benchmark Stimjim and our pulse train program, we generated a series of one-second biphasic pulse trains in which we varied the pulse frequency (from 2 Hz to 4000 Hz), pulse duration (from 20 µs to 4000 µs), and amplitude. We simultaneously recorded from both of Stimjim’s output channels using a National Instruments PCI-6110 card (2 MHz sampling rate per channel, 4.9 mV resolution). One Stimjim channel was set to voltage mode and the other channel to current mode with a 9.86 kΩ resistor connected to the output.
Stimjim proved capable of providing microsecond temporal resolution and millivolt- and microampere-amplitude resolution. Across the tested range of stimulation frequencies, Stimjim generated accurate and highly consistent inter-pulse intervals (IPIs; Fig. 2A-C) and pulse widths (PW) (Fig. 2D-F). While worst case errors of 2 µs (IPI) and 10 µs (PW) were detected, typical performance exceeded the temporal resolution of our test equipment. For example, IPI and PW standard deviations were typically less than 0.5 µs, which was the temporal resolution of our test equipment. For both IPI and PW, the absolute error magnitudes increased as the duration itself increased (Fig. 2C,F). However, the worst case absolute errors (2 µs and 10 µs) correspond to fractional errors of 0.0004% and 0.25% for IPI and PW, respectively. Finally, we assessed pulse amplitudes across a range of settings to ensure negligible DC offsets and proper gains. From −10V to +10V (the range of our test equipment), Stimjim produced accurate voltage and current amplitudes, with maximal errors of less than 40 mV and 2.5 µA (Fig. 2G-I). Pulse rise and fall times were rapid (Fig. 2J and Table 2) and exhibited low noise (Table 2). However, we did observe small-amplitude (0.2 V) high-frequency spikes during voltage pulses, which resulting from reading the output voltage via the onboard ADC. If needed, users can remove the ADC read operation and eliminate these spikes. Current pulses did not exhibit such spikes because the ADC instead reads a buffered signal from the current-sense amplifier, not the actual output signal.
Brain slice stimulation
We evaluated Stimjim for use in brain slice experiments. While Stimjim could not provide sufficient current for synaptic stimulation through pulled glass theta electrodes (resistance greater than 1 MΩ, data not shown), we were able to successfully stimulate pyramidal neurons in rat piriform cortex slices using monopolar platinum-iridium electrodes (100 kΩ). The exposed conical electrode tip was approximately 20 µm long with a maximal diameter of roughly 5 µm. We first placed a single stimulating electrode approximately 100 µm adjacent to the soma amd applied 0.4 ms current stimulation pulses of gradually increasing amplitudes. With increasing amplitude, we observed increasingly rapid and reliable action potential generation, and eventually emergence of a second action potential (Fig. 3A).
Next, we verified Stimjim’s ability to provide coordinated pulses on two separate electrodes. We placed one electrode in the lateral olfactory tract (LOT), a thick layer of axons that courses through the apical dendrites of piriform pyramidal neurons. We then placed a second electrode approximately 100 µm from the soma, near the basal dendrites. We generated variable delays (up to ± 3 ms) between LOT and basal stimulation (Fig. 3B). When LOT inputs were stimulated 0.5 ms after basal stimulation, but not before, we observed the most reliable generation of action potential. Outside of this window, action potential timing was variable and action potentials occasionally were not evoked. These experiments demonstrate Stimjim’s potential for precise extracellular electrical stimulation in brain slices.
In vivo stimulation
To demonstrate Stimjim’s utility in vivo, we used it to train mice in a classical paradigm known as intra-cranial self stimulation (ICSS) 35. In this assay, animals are implanted with electrodes (or more recently optical fibers 36;37;38) enabling activation of a pleasure/reward-related brain region 39. Animals are then placed in a training paradigm in which they learn that a simple motor action (typically spinning a wheel or pressing a lever) causes direct activation of this brain region. Animals quickly learn the required action and are willing to repeat it for extended periods of time.
We trained two mice in a head-fixed variant of ICSS, in which animals could lick a sensor in order to obtain brain stimulation reward (BSR). We used a capacitive sensor attached to a small metal pole to detect licking, and every lick triggered a stimulus pulse train (0.5 seconds, initially 150 Hz and the minimal current at which animals would respond). To initially encourage licking, we placed a small amount of peanut butter on the metal sensor. After initial licking was reinforced by BSR, animals would continue licking long after the peanut butter was gone, including during the next session in which no peanut butter was offered. After animals had learned the licking behavior (usually within their first hour session), we varied the BSR frequency and amplitude and assessed how it affected licking behavior. Both animals showed clear frequency- and amplitude-dependent responses, in which animals ceased licking when the rewarding stimulation was insufficiently intense (Fig. 4).
We observed clear differences between the two animals. Mouse 1 shows a rather linear response to either increasing frequency or increasing amplitude, whereas mouse 2 had a more “digital” response akin to passing an activation threshold. However, maximal licking rates were comparable between the two animals. Such differences are likely due to electrode placement35, although they may also reflect intrinsically different personalities between the two animals. Stimjim provides a precise and cost-effective means to scan the space of stimulation patterns, which could be useful to ensure all animals are given stimuli yielding the same response level.
As a secondary test of Stimjim’s ability to provide effective BSR, we placed head-fixed mice on a linear tread-mill and recorded their running behavior for 20 minutes. We then offered BSR for every increment the mice ran on the treadmill, initially every 20 cm and linearly increasing up to 60 cm over the course of 20 minutes. As shown in Fig. 5, mice always ran faster when BSR was offered than when it was not (n=9 sessions across 4 mice, p=0.004, paired Wilcoxon rank sum test). This shows that Stimjim provides a cost-effective means of motivating mice to run, such as for experiments studying place cells or motor-related neural signaling.
Conclusions
We have introduced Stimjim, an inexpensive yet precise open-source stimulator for neuroscience. At a cost of roughly $200 USD for parts, Stimjim is order of magnitude less expensive than commercial, proprietary alternatives. It offers microsecond temporal control of current and voltage with millivolt/microampere precision.
Stimjim’s low cost opens up many potential applications, such as learning paradigms that involve direct electrical stimulation. Stimjim’s open source nature makes it straightforward for researchers to customize the stimulation parameters and use Stimjim in closed loop experiments. Furthermore, researchers who were previously limited to training only one animal at a time due to possessing only a single stimulator could now train or perform experiments with ten or more animals simultaneously for comparable cost.
Conflicts of interest
JPN and MW are board members of Open Ephys Inc., a nonprofit that supports the development, standardization, and distribution of open-source tools for neuro science research. The work described in this manuscript may be distributed through Open Ephys. None of the authors are receiving any financial compensation for their position on the board or for the work described in this manuscript.
Methods
Stimjim fabrication and benchmarking
PCBs for Stimjim were ordered from JLCPCB and components were ordered from Digikey. Components were manually soldered to the PCB using solder paste and a soldering iron. After soldering, the pulse control program was downloaded to the Teensy using the Arduino IDE and Teensyduino. From that point on, Stimjim’s settings were controlled via serial communication over USB. For benchmarking, we used a custom NI LabView program to set Stimjim’s pulse parameters (frequency, amplitude, duration, etc.), initiate a one-second pulse train, and record both Stimjim channels using a National Instruments PCI-6110 card via a breakout box. This program is also available in the git repository.
Electrode implantation and ICSS
Monopolar electrodes (Plastics1, #MS303/2-AIU/SPC, coated stainless steel, 200 µm diameter) were implanted above the medial forebrain bundle according to the protocol in reference 39. The ground was implanted in the contralateral cortex. Additionally, a 3D-printed headpost was affixed to the animal’s skull by dental cement to enable head fixation. Typical resistance (100 µs pulse) between connector pins after implantation was 20-30 kΩ. All animal procedures were in accordance with guidelines established by the NIH on the care and use of animals in research and were confirmed by the Technion Institutional Animal Care and Use Committee (IL-012-01-18, valid until 10/4/2022).
Slice stimulation experiments
Coronal brain slices were prepared from the anterior piriform cortex from 28-40 day old Wistar rats. 300 µm thick slices were cut in ice-cold artificial cerebro-spinal fluid (ACSF) bubbled with 95% oxygen and 5% CO2, then incubated for 30 min at 37 C and kept at room temperature afterwards. Whole cell patch clamp recordings were performed with an Axon amplifier (Multiclamp). Glass electrodes (6-8 MΩ) were made from thick-walled (0.25 mm) borosilicate glass capillaries on a Flaming/Brown micropipette puller (P-97; Sutter Instrument). Intracellular pipette solution contained 135 mM potassium gluconate, 4 mM KCl, 4 mM Mg-ATP, 10 mM Na2-phosphocreatine, 0.3 mM Na-GTP, 10 mM HEPES, 0.2 mM OGB-6F, 0.2 mM CF-633, and biocytin (0.2%) at pH 7.2. The ACSF solution contained 125 mM NaCl, 25 mM NaHCO3, 25 mM Glucose, 3 mM KCl, 1.25 mM NaH2PO4, 2 mM CaCl2, 1 mM MgCl2 at pH 7.4. After patches were established, platinum-iridium electrodes for stimulation (Alpha Omega, #387-102S01-11, 250 µm diameter, Pary lene C and Polyamide coated, 0.1 MΩ) were placed in the lateral olfactory tract and in the basal dendrites roughly 100 µm from the soma.
Supplemental materials
In case of future modifications, the most up-to-date details regarding Stimjim will be available at https://bitbucket.org/natecermak/stimjim. The following are included as supplemental materials for the version of Stimjim documented here (v0.18).
Bill of materials: stimjim bom.xlsx
Fabrication files: stimjimFabricationFiles v0.18.zip and stimjimPanelFabricationFiles v0.18.zip
Schematic: schematic.pdf
Acknowledgments
We thank Amit Kumar for help with the brain slice experiments, and Jakob Voigts for support in the MFB implant surgery. We also thank the Schiller lab for discussions and help with preliminary testing. NC acknowledges support in part from a Zuckerman STEM Leadership Fellowship at the Technion.