Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
share|improve this question
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

1 Answer 1

up vote 10 down vote accepted

For the neuron activity part:

Code

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{arrows}
\usepackage{xifthen}

\begin{document}

\begin{tikzpicture}
%\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}
            \ifthenelse{\drawbool=1}
                {   \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};
    }
\end{tikzpicture}

\end{document}

Result

enter image description here

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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