root/trunk/doc/spike2.txt

Revision 277, 2.6 KB (checked in by apdavison, 4 years ago)

Minor fixes in docs

Line 
1=========================
2The ``spike2`` module
3=========================
4
5The ``spike2`` module offers an easy way for reading data from CED's Spike2 Son files into the NeuroTools environment.
6
7The main interaction with with Spike2 files is provided by the SON Library which was written by::
8
9 Antonio Gonzalez
10 Department of Neuroscience
11 Karolinska Institutet
12 Antonio.Gonzalez at cantab.net
13 http://www.neuro.ki.se/broberger/
14
15The ``spike2`` module integrates the SON library such that the loading function directly returns ``NeuroTools.signals`` objects.
16This makes it very easy to apply certain analysis routines on simulated and real experimental data.
17
18----------------
19loading channels
20----------------
21
22Usually SON files contain data from multiple channels. The channels can contain analog signals, like membrane potential traces or discrete data like markers. The ``spike2`` module knows which type of channel you are loading and thus returns the appropriate ``NeuroTools.signals`` object.
23
24Here some examples how one can simply load the data. For the following example we assume that the SON file contains the membrane potential trace in channel 1, the markers in channel 2 and in channel 3 is data that we dont want to use:
25       
26To load the ``spike2`` module you could do the following::
27       
28        >>> import NeuroTools.spike2.spike2channels as spike2
29       
30to load all channels in the file just use the load function::
31
32        >>> all_channels = spike2.load(filename)
33        >>> all_channels.keys()
34        [1,2,3]
35
36since we don't need channel 3 we can use the channels parameter to specify which channel to load::
37       
38        >>> just_needed_channels = spike2.load(filename, channels=[1,2])
39        >>> just_needed_channels.keys()
40        [1,2]
41
42what objects are returned?::
43       
44        >>> type(just_needed_channels[1])
45        <class 'NeuroTools.spike2.spike2channels.Adc'>
46        >>> type(just_needed_channels[2])
47        <class 'NeuroTools.spike2.spike2channels.Marker'>
48
49what can I now do with it? I.e. the Adc channel type is inherited from ``signals.AnalogSignal`` and thus you could plot an event_triggered_average on the marker times (please note that the markers are in seconds, we need them in milliseconds therefore the factor 1000)::
50
51        >>> vm = just_needed_channels[1]
52        >>> marker = just_needed_channels[2]
53        >>> vm..event_triggered_average(marker.times*1000., display=True)
54       
55in case your vm channel contains multiple stimuli conditions that you dont want to average, but still be separated you can use the slice_by_events function::
56       
57        >>> vm_sclices = vm.slice_by_events(marker.times*1000.,t_min=100,t_max=1000)
58
59For further examples of what to do with ``NeuroTools.signals`` objects, please refer to the documentation for the ``signals`` module.
60
61
Note: See TracBrowser for help on using the browser.