Does anyone know of packages for displaying neuroscience schematics with tikz? For example, I would like to place a raster plot next to the diagram of a Markov process to help explain how Markov models could be used to simulate the firing of neurons.

I know that I could do this by including an image of neural activity in the tikz picture. But, I wondered if there was a solution that could only use tikz.

Below is the, admittedly, amateurish, version I made in PPT. The raster plot refers to the horizontal lines of ticks. Each tick is the same and marks where a neuron fired.

I know how to use the automata library in tikz to make the state diagram. I wondered if there was an easier way to draw many horizontal lines than the brute force approach with a for loop.

Sketch of slide combining raster plots and Markov chain

Sample neural data (times in ms that a neuron fired) for 50 ms:

 2,10,12,14,15,20,25,34,35,48, 49
  • 7
    Can you please provide (a link to) an image of the kind of drawing you would like to do? – Gonzalo Medina Sep 22 '12 at 21:47
  • Could you provide some sample "neuron firing" data? Otherwise random numbers it is. The color represents intensity? (There are lines of different color: black, orange, red) – Tom Bombadil Sep 23 '12 at 11:48
  • Random numbers are fine. Most simulations use a Poisson process with a rate of 10. I've edited to provide some example times though. There should only be one color-black. The rasters are pasted from another program into PPT and the coloring is an artifact when two black lines are really close together. – mac389 Sep 23 '12 at 11:58

For the neuron activity part:




%\pgfmathsetseed{42}% or some other number
\foreach \y [count=\c] in {-0.5,-1,...,-2.5}
    {   \node[right] at (15.2,\y+0.1) {\scriptsize Subject \c};
        \foreach \x in {1,...,300}
        {   \pgfmathtruncatemacro{\drawbool}{rand-0.7 > 0 ? 1 : 0}
                {   \fill (\x/20,\y) rectangle (\x/20+0.05,\y+0.3);}

    \draw[-stealth] (0,0) -- (15.5,0);
    \node[right] at (15.5,0.2) {t in ms};
    \foreach \x [evaluate=\x as \v using int(20*\x)] in {0,...,15}
    {   \draw (\x,-0.05) -- (\x,0.05) node[above] {\v};



enter image description here

  • 1
    That's beautiful. – mac389 Sep 23 '12 at 12:45
  • How would I position the state diagram and the raster plot in the same tikz picture? – mac389 Sep 23 '12 at 12:46
  • Just take the state diagram commands and put them in a shifted scope: \begin{scope}[shift={(x,y)}] <draw commands> \end{scope} – Tom Bombadil Sep 23 '12 at 12:49
  • @Ahmed Musa: It's random numbers, so they are different after each compile. To make them stay constant, add \pgfmatsetseed{<number>} before the first foreach. I added it in the answer. – Tom Bombadil Sep 23 '12 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.