Monday, July 12, 2021

Pins in the head, circuit simulation, Tasmanian devil face souls

I was recently researching the electrical characteristics of brain tissue after encountering the subject of deep probe stimulation in a 2014 paper by Koubeissi et al (Electrical stimulation of a small brain area reversibly disrupts consciousness). I had been studying neuroscience for some weeks trying to acquire a good understanding of the anatomy and function of the claustrum (the latter a rather quixotic goal on my part considering that is still a mystery in the neuroscience community, though the number of research papers on the subject is increasing yearly). 

The Koubeissi paper described finding that they could switch consciousness on and off like using a light switch in a 54-year-old woman with intractable epilepsy. One of the many electrodes (A14) they had inserted (I admit I am horrified at the idea of turning the human brain in a living subject into a pin cushion, but this woman was completely disabled by her seizures, which had returned four years after surgeons had removed her left hippocampus and given her a brief respite from the attacks) was placed near the left anterior insular cortex and the claustrum. In the process of firing up one after another of the electrodes and gauging their effect, they discovered to their amazement that, with application of a 14 mA 50 Hz 0.2 ms pulse width 3-10 second signal to the A14 electrode, the patient would abruptly cease reading (neurosurgeons often have patients perform a particular mental activity in order to assess the effect of monkeying with specific areas of the brain, rather like poking an ice pick into a television receiver's circuitry and looking for changes in the picture quality), stare blankly (I sometimes do this without probe stimulation), and become unresponsive to auditory or visual commands (e.g., an instruction on a piece of paper).  

Occasionally, if the patient had been speaking when the electrical pulses were injected, her speech would not stop immediately, but would persist for a few seconds as a few sporadic nonsense syllables while her face would appear confused, as if the plug had been pulled and it took a few seconds for the motor to stop turning as it were. When they stopped the contact stimulation her consciousness returned immediately and she had no memory of the loss of consciousness.

I was curious how the electrical current affected neurons and how the current traversed the brain tissue and interacted with the neuronal body or its axons and dendrites. I began looking at electronic network simulations of the physical effects of deep brain stimulation, for example, the 2006 Sources and effects of electrode impedance during deep brain stimulation by Butson et al, and the more specific (more specific to my interest in the aspect of simulating tissue using network theory) 2008 Active Mechanisms Are Needed to Describe Cell Responses to Submicrosecond, Megavolt-per-Meter Pulses: Cell Models for Ultrashort Pulses , by Smith and Weaver. Smith had been working on meshed cell modeling since at least 2006 when he submitted a thesis on the subject while working on his master's degree in electrical engineering and computer science at Duke University. 

In the 2008 paper, Smith and Weaver described using the MTNM (Meshed Transport Network Method), a way to model  relations between adjacent finite volumes cast as equivalent circuit networks.  The system is divided into Voronoi cells (VCs), each associated with a single node to which it is closest. The interface between the cells is then halfway between nodes, which are not necessarily uniformly spaced. 

Say we have a 2-dimensional area of brain tissue we want to simulate. We can arrange some points (these will be our "nodes," the locations where values of the electrical field will be calculated) on the area, the blue dots in the following (we just arranged these uniformly, but in practice a mesh program would generate the node placement):                                                                                               

We want to tell a computer how to relate those sample points to one another in 2-D space. We can connect them with Delaunay triangles, i.e., let a computer subdivide the set of points into a non-overlapping set of triangles such that the circumcircle of one Delaunay triangle (a disk drawn through the 3 vertices of the triangle) contains no other points:

We would like to know the nearest neighbors of that set of points though, since we want to simulate electrical signal propagation from one cell to the next in the direction of the electric field vector. So we can use a computer to draw a Voronoi subdivision of the space containing our sample nodes into nearest neighborhoods of those nodes:

It turns out that the sides of the Voronoi cells then turn out to be perpendicular bisectors of the Delaunay triangle edges, simplifying transport calculations between adjacent nodes marking locations in the tissue being simulated (because, for example, the electric field can be stipulated as normal to the edges of the cells). So we show you both the above figures plotted together:

In such a spatial field, Voronoi cells then act as small tissue volume domains into which the entire domain of our sample is discretized (considered as pieces), with the circuit behavior of each small volume approximated by its associated node. You can then understand what Smith and Weaver did here (we took this image from Smith's 2006 MIT thesis paper):

Why the mesh cells? If you hold a piece of metal with the end in a flame, the heat will work its way up to your hand. A mesh characterization would let you program a computer to calculate the diffusion and conduction of the heat up the metal over time, cell by cell, governed by interaction or propagation rules from cell to cell. Instead of heat, we are looking at electrical field and current and the object of interest is just a volume of electrolyte, the fluid between and within cells.

They used the Berkeley SPICE electrical network simulator to "obtain the electrical response of cell equivalent of circuit networks to pulsed electrical fields"  (to calculate the ɸ E vector magnitude between adjacent VCs in the image above). This is a clever approach in that one piece of specialized open source software handles the characterization spatially, that is, placing the grid nodes, drawing Delaunay triangles and Voronoi cells. I wrote some trivial Python code using SciPy spatial functions to make the figures prior to the Smith figure, while Smith used some advanced Matlab code developed by Per-Olaf Persson and Gilbert Strang at MIT, Persson now at UC Berkeley. A program (SPICE) handles the electrical behavior between and among the many VCs on each step of the simulation run. For example, you might model the electrolyte medium comprising the arbitrary partitioning of the tissue into VC's as a parallel combination of a resistor R and capacitor C (recognize the  ɸ  electric field symbol from the VC mesh above):

You should note that the grid used by Smith was considerably more intricate than our samples above. In the following figure we see his VC pattern on left, Delaunay triangulation on right. The width of each box containing the circular generic body cell with a nucleus and organelle is 24 micrometers in scale, with 19,061 nodes. The dark perimeters are where the mesh becomes very dense (you could see this at higher magnification) in order to accurately capture the curve and the associated membrane electrical transport characteristics:

This got me interested in SPICE. I had done some work with a related GUI (graphical user interface) version of SPICE from Texas Instruments, "TINA-TI," some years back, and LTspice on a Windows machine in 2016. Actually my first exposure to automated network analysis was way back in 1980 or so, when I ported (rewrote the software in a different language) an HP CAP (Circuit Analysis Program) written in HP BASIC running on an HP desktop computer (an industrial computer with HP-IB bus to connect to instruments, designed for electronic labs, not the later MS Windows PC's HP offered to the public) to run on the BASIC dialect used on my TRS-80 Z80 microcomputer (I sold my 1971 Les Paul in 1979 to pay for the computer; my later music and some historical samples is still out there though if you search on "Dalton Bentley music").

Around that same time, I did punch some FORTRAN cards to run a circuit simulation on the IBM-360  mainframe computer at the University of Texas while I was taking a network analysis course there in c. 1980, but did not do much with it. They may have been running SPICE, but I don't recall, this being a classroom exercise, divorced from much interaction with the system in batch mode, other than to fix whatever error (type a new punch card) caused the line printer to start spewing paper (arousing the wrath of the computer operators as they raced to shut it off before it wasted a few hundred yards of continuous paper).

In any case, since I am running Linux now, I decided to work with Ngspice-27, without a GUI, just typing instructions in a text file (each line corresponding to one of the punched cards I mentioned above). I soon became bored with simulating simple RC circuits (and assumed the reader of the tutorial I was writing in a parallel project would also like something more challenging) and decided to examine an interesting power amplifier technique involving injecting pulsed current into a tuned LC load (an inductor L and capacitor C that resonate together at a specific frequency, tossing energy back and forth to one another as it were). 

In the process of researching neuromodulation, I had read a 2018 Berkeley EE & CS masters thesis by George Alexandrov, Powering OMNI: A Distributed and Modular Closed-Loop Neuromodulation Device. Medical regulations require that implanted wires (in the brain) carry zero DC (direct current). Alexandrov proposed therefore to distribute AC (alternating current) power (to leads in the brain) at high frequency from a pair of differential Class-E power drivers. Since half the sine wave of sinusoidal current is positive and half negative, the net DC current is 0. 

From my work in electronics, I knew of Class-A, B, and C amplifiers, but I had not heard of Class-E before. Steve Cripps, in his excellent textbook on RF power amplifiers, nicely characterizes amplifier types simply by conduction angle. The Class-A conducts 360 degrees of sinusoidal input, the Class-B 180 degrees per transistor in a push-pull pair (he also considers a single transistor conducting half, 180 degrees, to be a Class-B amplifier), and Class-C zero to 180 degrees, i.e., just a small chunk of the input sinusoidal. 

Following Alexandrov's cite, I found and read the 1975 Sokal paper that introduced the Class-E amplifier (Cripps' textbook noted, somewhat humorously, that the microwave community remained ambivalent to the Class-E concept until the Sokal patent expired c. 2005) and decided to specify circuit element values following the Sokal design rules simulate the circuit in SPICE (Ngspice-27). This is the applicable schematic (though I did include some series resistance in the wires of the inductors):


I decided to use a drive signal of 1 V peak, 256 ns period pulse  (3.9 MHz), on-time 128 ns. I assigned a load resistor using the Sokal 1975 equation (1), coming up with 11.73 ohms for RL load resistor (later adjusted to 13 ohms in order to reduce some of the current spiking on transition from voltage wave on open Q1 to current wave through Q1 saturated as switch).  I assigned 23.1 VDC to the power supply. Targeting 26 watts in our load resistor and using Sokal equation (3) I calculated 638.745 pF for C1, 410.273 pF for C2 using equation (4), 4.787 microHenry for L2 using equation (2). I just used the same L1 RF choke value of 68 microHenry as did Sokal (it must simply be large enough to block radio frequency, while sourcing DC to Q1).                    

The circuit as described (with RL adjusted to 13 ohms) gave me, in Ngspice-27 simulation, 16.3 watts rms, or 23 watts peak, pretty close to our design target above (a beautiful 3.9 MHz sine wave on the load, an astounding absence of harmonics considering the weird transistor switch waveforms, a result produced mostly by the resonant behavior of the L2 and C2 network) . Sokal equation (7) predicted the peak voltage across Q1 would be 82 volts and we measured just under 80 volts (see figure below). We measured 2.29 amps peak in the Q1 collector, differing somewhat from equation (6) Sokal predicting 1.56 amps. However, the Class E amplifier transistor voltage and current waveforms are quite unusual, both in shape and phase relation to one another, as you can see in the trace from my Ngspice-27 simulation trace:

In trace above note that the collector voltage (violet) has been scaled by 80, e.g., vertical 1 is 80 volts. Similarly, the collector current (green) has been scaled by 2, e.g., 1 is 2 amps. The time scale is seconds and the ticks are at 50 ns intervals, so the current is on roughly 120 ns (recall we set exactly 128 ns on-time for the input pulses 3.9 MHz). There is almost no dissipation of power in the transistor since this Class E design arranges the current flow to occur while there is no voltage across the transistor. We measured the product of voltage and amperes from the DC supply to be 18 watts, so the 16 watts in the load is produced at 16/18 or about 90%. Our transistor model in Ngspice-27 was not very realistic in that we used simply their generic BJT (bipolar junction transistor) model, obtaining a beta current gain of 81 here, which is really not believable for a saturated general purpose transistor. We are looking at modifying the BJT model or using a MESFET, but thought we should go ahead and post this, since we are not getting any younger and civilization is deteriorating rapidly (I would grin here, but some might not appreciate my gallows humor).

I continue to pursue academic interests while the worldline of 2021 Earth reveals itself moment by moment. From the US (pardon my provincial stance, I am aware that the world generally is sharing our disruption and dismay) pacific northwest on fire, most of the west scorched with heretofore unseen continuous lethal heat, tornados from the alley all the way to the east coast at times, the Atlantic coast battered by storms and hurricanes, and my relatively insulated portion of New Mexico almost ripped from the earth yesterday by a thunderstorm of incredible ferocity (sat in the twilight choking down bread and cold meat, power going on and off and afraid to try to heat anything or open the refrigerator and let out cold air), I feel a certain negative judgment by the Creator on the course we have taken. No matter, we are all born to die I suppose, but a man entertains delusions of timeless values, achievements, progress and it is bitter to see those dying as well.

I read Justice Alito's opinion (SCOTUS) in Brnovich et al v Democratic National Committee (decided July 1, 2021) and wonder what it feels like to be a sophist, to use the God-given ability to reason to dissemble. Alito knows very well that the purpose of the Arizona voting law that was the subject of the action was to permit ongoing attempts by republican legislatures to force just enough ballots into the hands of party loyalists that they can prevent another loss like they suffered in the 2021 presidential (and a few senatorial) election. We are talking tenths of percents, but that is exactly what is required to tip the balance. I wonder also how a man of talent can knowingly pursue the ends of destroying the American Republic, willingly trying to turn it over to a fraud and idiot who desecrated the ideals of the government, illustrating that the Constitution, like any laws in any civilization, does not shape behavior so much as codify the expectations of the framers (and unfortunately, those expectations are no longer prevalent, and the only text men such as Alito quote are lines sufficient to mask their evil purpose). 

On the other hand, you have the American university system and public education generally grotesquely perverted to the ends of one-world multiculturalism that is degrading the quality of American performance in business and government (and the quality of life), the standards lowered to fulfill the lie of equality (people have an equal opportunity to compete, but only an idiot would claim that humans are interchangeable) and constant bizarre demands for apologies from a culture that produced the most advance civilization the world had seen and in fact saved the world on several occasions.

I was fascinated by an infectious form of cancer that has all but eradicated the Tasmanian devils (I don't know if Bugs Bunny was involved). As humans become more and more like animals crowded into a zoo, there is the possibility such communicable nightmares will appear in humans, a step beyond the mere death promised by the current viral plague. When I view such a diseased devil, I can't help but see a representation of the souls of those who lie, slander and defile all that is honorable and good: