Skip to content

2.5.6 plotSEM()

Shun Li edited this page Jul 23, 2024 · 5 revisions

Overview

plotSEM() takes in an array and plot the average and SEM by row. This is heavily used to plot average of event aligned traces of a given signal (e.g. photometry, camera, lick rates, etc).

Inputs and options

Required inputs

  • x: double, the vector that stores x value of individual time points. Called timestamp in plotTraces()
  • y: double, the array where each row is each individual events and column is timepoints. Called traces in plotTraces()
  • color: color of the trace to be plotted

Options

  • smooth: double, default is 0; determines the time duration (in seconds) of a smoothing window. If smooth=0, then no smoothing is performed.
  • smoothMethod: string, default is 'movmean'; determines which smoothing method is used for smoothing. See Matlab method smoothdata() for more options.
  • plotMean: logical, default is true.
  • plotPatch: logical, default is true; if false, only the mean trace will be plotted and the shaded areas indicating SEM will not.
  • plotIndividual: logical, default is false; if true, it will plot individual trace in the background
  • individualColor: default is 'gray'; this determines the color of individual trace. If enter same, then the individual trace will follow the color of mean trace determined by color, adding some alpha determined by individualAlpha.
  • individualAlpha: double, default is 0; determines the transparency of the individual traces. 1 is fully transparent.
  • LineStyle: string, default is "-"; determines the line style of the mean trace. See Matlab documentation for details.
  • LineWidth: any numeric values, default is 2; determines the width of line. See Matlab documentation for details.
  • plotStyle: string, default is 'line'; determines the style of plot. It also can be set to stairs, which will give a stairs plot. See Matlab documentation of stairs() method for details.
  • delta: double, default is empty ([]); This specify the time window to calculate mean value and subtract it from the whole trace. Normally used for baseline subtraction.

Outputs

  • There is no outputs of this function. Do make sure to use initializeFig() before calling any plotting functions.

Examples

initializeFig(0.5,0.3);
combined = combineTraces(animals,timeRange=[-0.5,3],...
                            eventRange='Water',...
                            animalRange=["SL133","SL135"],...
                            taskRange='Random',...
                            totalTrialRange=totalTrialRange,...
                            trialRange=trialRange,...
                            signalRange='NAc');
plotSEM(combined.timestamp,combined.data{1},[.213 .543 .324]);
xlabel('Time (s)'); ylabel('z-score');

image