This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
analysis:nsb2015:week3short [2015/07/16 19:02] mvdm |
analysis:nsb2015:week3short [2018/07/07 10:19] (current) |
||
---|---|---|---|
Line 46: | Line 46: | ||
<code matlab> | <code matlab> | ||
%% cd to data folder -- replace this with yours | %% cd to data folder -- replace this with yours | ||
- | fd = 'D:\data\DataAnalysisTutorial\R042-2013-08-18'; | + | fc = 'D:\data\DataAnalysisTutorial\R042-2013-08-18'; |
cd(fc); | cd(fc); | ||
Line 103: | Line 103: | ||
''csc'' is the common Neuralynx designation for "continuously sampled channel" and typically is an EEG or LFP type signal sampled and filtered so that high-frequency components such as spikes are not accessible. It is possible to have wide-band, 32kHz CSCs suitable for spike extraction, but these are not included in the current dataset. As discussed in [[analysis:nsb2015:week2|Module 3]] a LFP **tsd** is defined by matching sets of sample timestamps (''csc.tvec'') and sampled data (''csc.data''). | ''csc'' is the common Neuralynx designation for "continuously sampled channel" and typically is an EEG or LFP type signal sampled and filtered so that high-frequency components such as spikes are not accessible. It is possible to have wide-band, 32kHz CSCs suitable for spike extraction, but these are not included in the current dataset. As discussed in [[analysis:nsb2015:week2|Module 3]] a LFP **tsd** is defined by matching sets of sample timestamps (''csc.tvec'') and sampled data (''csc.data''). | ||
- | ==== plotting spike rasters ==== | + | ==== Plotting basic spike rasters ==== |
The ''S'' variable that contains our spike times is a MATLAB struct that conforms to the ''ts'' ("timestamp") format introduced in [[analysis:nsb2015:week2|Module 2]]. Its ''.t'' field contains spike trains as lists of numbers, corresponding to the timestamps of the spikes. So, to plot a raster with the spikes of the first cell in our data set: | The ''S'' variable that contains our spike times is a MATLAB struct that conforms to the ''ts'' ("timestamp") format introduced in [[analysis:nsb2015:week2|Module 2]]. Its ''.t'' field contains spike trains as lists of numbers, corresponding to the timestamps of the spikes. So, to plot a raster with the spikes of the first cell in our data set: | ||
Line 118: | Line 118: | ||
You should find that it takes a significant amount of time to plot that many spikes. In practice we often want to plot spikes for specific time intervals; we will do this below. Alternatively, there exists code that is much faster at plotting rasters (albeit more obscure; implemented in ''PlotSpikeRaster2()'' if you want to see an example). | You should find that it takes a significant amount of time to plot that many spikes. In practice we often want to plot spikes for specific time intervals; we will do this below. Alternatively, there exists code that is much faster at plotting rasters (albeit more obscure; implemented in ''PlotSpikeRaster2()'' if you want to see an example). | ||
- | ==== restricting ts and tsd objects ==== | + | ==== Temporally restricting ts and tsd objects ==== |
A useful function that works on ''ts'', ''tsd'' and ''iv'' objects is ''restrict()''. | A useful function that works on ''ts'', ''tsd'' and ''iv'' objects is ''restrict()''. | ||
Line 134: | Line 134: | ||
This high-frequency osillation (the "ripple") superimposed on a slower oscillation (the "sharp wave") is the signature associated with "replay" events in the hippocampus. We will explore this phenomenon in detail in later modules. | This high-frequency osillation (the "ripple") superimposed on a slower oscillation (the "sharp wave") is the signature associated with "replay" events in the hippocampus. We will explore this phenomenon in detail in later modules. | ||
- | ==== quick figure export ==== | + | ==== Exporting figures ==== |
A good way to save figures you may want to keep is: | A good way to save figures you may want to keep is: | ||
Line 144: | Line 144: | ||
Notice that the first argument of ''print'' is the current figure (''gcf''). The other arguments specify that we want a ''PNG'' file, with 300dpi resolution. PNG format is a good choice for saving figures because it uses lossless compression, JPG images, which use lossy compression, can have ugly artifacts (but more colors). Other useful save formats are ''-dill'' which saves ''.ai'' Illustrator files, and ''-depsc'' which saves an embedded %%PostScript%% file (both vector formats). | Notice that the first argument of ''print'' is the current figure (''gcf''). The other arguments specify that we want a ''PNG'' file, with 300dpi resolution. PNG format is a good choice for saving figures because it uses lossless compression, JPG images, which use lossy compression, can have ugly artifacts (but more colors). Other useful save formats are ''-dill'' which saves ''.ai'' Illustrator files, and ''-depsc'' which saves an embedded %%PostScript%% file (both vector formats). | ||
- | ==== a fully featured plotting function ==== | + | ☛ Critically evaluate the formatting of figure shown above. What are some missing elements you would want to see if this figure were to be used in a talk or paper? What changes could you make to improve legibility? |
+ | ==== A fully featured plotting function ==== | ||
+ | |||
+ | ''MultiRaster()'' is a versatile and fast plotting function, with many different options and features. | ||
+ | |||
+ | The most basic usage is simply: | ||
+ | |||
+ | <code matlab> | ||
+ | MultiRaster([],S) | ||
+ | </code> | ||
+ | |||
+ | Note that the first argument in this case is the empty matrix ''[]''. For more features, this argument is used as a ''cfg'' variable with several options, for instance: | ||
+ | |||
+ | <code matlab> | ||
+ | plot_cfg = []; | ||
+ | plot_cfg.lfp = csc; | ||
+ | plot_cfg.spkColor = 'hsv'; | ||
+ | MultiRaster(plot_cfg,S) | ||
+ | </code> | ||
+ | |||
+ | This particular data set also has some experimenter annotations associated with it, for example in the %%ExpKeys%% file: | ||
+ | |||
+ | <code matlab> | ||
+ | >> LoadExpKeys | ||
+ | >> ExpKeys | ||
+ | |||
+ | ExpKeys = | ||
+ | |||
+ | Behavior: 'MotivationalT' | ||
+ | RestrictionType: 'water' | ||
+ | Session: 'standard' | ||
+ | Layout: 'foodLeft' | ||
+ | Pedestal: 'R' | ||
+ | nPellets: 5 | ||
+ | waterVolume: [] | ||
+ | nTrials: 18 | ||
+ | forcedTrials: [] | ||
+ | nonConsumptionTrials: [] | ||
+ | badTrials: [] | ||
+ | pathlength: 318 | ||
+ | patharms: 369 | ||
+ | realTrackDims: [139 185] | ||
+ | convFact: [2.9176 2.3794] | ||
+ | TimeOnTrack: 3240 | ||
+ | TimeOffTrack: 5645 | ||
+ | prerecord: [2.1266e+03 3.2141e+03] | ||
+ | task: [3.2387e+03 5.6452e+03] | ||
+ | postrecord: [5.6564e+03 6.5635e+03] | ||
+ | goodSWR: {1x2 cell} | ||
+ | goodTheta: {'R042-2013-08-18-CSC07a.ncs'} | ||
+ | |||
+ | </code> | ||
+ | |||
+ | The meaning of these fields is explained in more detail in the full [[task description]], but for now we will just use the start and end times for the 'prerecord' segment of the data to highlight it visually: | ||
+ | |||
+ | <code matlab> | ||
+ | plot_cfg = []; | ||
+ | plot_cfg.evt = iv(ExpKeys.prerecord); | ||
+ | plot_cfg.evtColor = [0 0 0.5]; | ||
+ | MultiRaster(plot_cfg,S) | ||
+ | </code> | ||
+ | |||
+ | ''MultiRaster()'' is interactive, allowing the user to scroll, zoom, move from one event to another, et cetera. To see the full list of keybindings, type ''help navigate''. | ||
+ | |||
+ | The [[analysis:nsb2015:week3long|long version]] of this module challenges you to write a version of this visualization function yourself, so you can understand how it is done, and customize it for your application. |