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

I have a spike train. The data shows the time at which the neuron fired a spike. I want to plot them like this picture:

enter image description here

Here is the data for one spike train which corresponds to the one of the neurons in the figure above.

Download the spike train data

share|improve this question
    
This can be done really easily. But your data are much larger than those on your plot. –  Öskå Jul 25 at 13:46
    
@Öskå I just put the data as a sample of the spike train in case it is needed. –  yashar Jul 25 at 14:19

3 Answers 3

up vote 7 down vote accepted

Here is an example with some random data:

SeedRandom@0;
dat = Sort /@ RandomInteger[{200, 700}, {3, 25}];
Graphics[{Hue@.5, Opacity@.7, 
  MapIndexed[Line@Outer[List, #, 40 #2[[1]] + {20, -20}] &, dat]}, 
  Axes -> {True, True}, 
  Ticks -> {Automatic, Thread@{Range[40, 3*40, 40], Range@3}}]

Mathematica graphics

With your data, it's a different story and it looks like:

data = ToExpression@Import["http://pastebin.com/raw.php?i=Vj4nQNB5"];
Graphics[Line[{{Log@#, .5}, {Log@#, 1.5}}] & /@ data]

Mathematica graphics

share|improve this answer
1  
You can replace your Table expression with: MapIndexed[Line @ Outer[List, #, 40 #2[[1]] + {20, -20}] &, dat] –  Mr.Wizard Jul 25 at 14:35
    
@Mr.Wizard Thanks! I knew that there was something but I just considered that Table was fast enough for this.. :) –  Öskå Jul 25 at 17:39

DistributionChart with ChartElementFunction->"LineDensity"

spktrnF[data_, opts : OptionsPattern[]] := 
   Module[{options = {ChartBaseStyle -> EdgeForm[None],
                      ChartElementFunction -> "LineDensity",
                      BarOrigin -> Left, BarSpacing -> 0.1,
                      ChartLabels -> Range[Length@data]}},
          DistributionChart[data, If[opts === {}, options, PrependTo[options, {opts}]]]]


SeedRandom@0;
dat = Sort /@ RandomInteger[{200, 700}, {5, 100}];

spktrnF[dat, ImageSize -> 800, AspectRatio -> 1/3, 
             ChartStyle -> "SolarColors", FrameStyle -> 16, 
             FrameLabel -> {"Time", "Neuron", None, None}]

enter image description here

share|improve this answer

You could use ArrayPlot.

t = Flatten @ Import["f:\\spikes.dat"];
p = ConstantArray[0, Max[t]];
p[[t]] = 1;
ArrayPlot[{p[[1 ;; 1000]], p[[1000 ;; 2000]]},
  AspectRatio -> 1/10,
  FrameTicks -> Automatic,
  FrameLabel -> {"neuron", "time"}]

enter image description here

But this approach is bad for data with more than 1000 time records

share|improve this answer

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.