| ERPIMAGE | Image single-trial ERPs optionally sorted on and/or aligned to an input variable and smoothed by moving-average (Note: to return event-aligned data without plotting, use eventlock. Click on axes to examine separately and zoom. | 
| Usage: | >> [outdata,outvar,outtrials,limits,axhndls,erp, amps,cohers,cohsig,ampsig,outamps,phsangls,phsamp,sortidx] = erpimage(data,sortvar,times,'title',avewidth,decimate, flag1,arg1,flag2,arg2,...); | 
| Inputs: | |
| data    | single-channel data: format (1,frames*trials) or (frames,trials) | 
| sortvar    | vector variable to sort trials on (ntrials = length(sortvar)) for example, >> sortvar = rts (in ms) | 
| times    | vector of times in ms (frames=length(times)){def|0->[0:frames-1]} else [startms ntimes srate] = start time (ms), time points per epoch, sampling rate (Hz), | 
| 'title'    | title string {default none} | 
| avewidth    | ntrials in moving average window (may be non-int) {def|0->1} | 
| decimate    | factor to decimate ntrials out by (may be non-int) {def|0->1} If this is large (>sqrt(num. trials)), this many trials output. | 
| Options: | |
| 'align'    | [time] -> time lock data to sortvar aligned to time in msec | 
| (time    | Inf -> align to median sortvar) {default: no align} | 
| 'nosort'    | don't sort data on sortvar {default: sort} | 
| 'noplot'    | don't plot sortvar {default: plot if in times range} | 
| 'limits'    | [lotime hitime minerp maxerp loamp hiamp locoher hicoher bamp] Can use NaN for missing items and omit late items; use bamp to fix baseline amplitude. | 
| 'caxis'    | [lo hi] -> set color axis limits {default: data bounds} else [fraction] = set caxis limits at (+/-)fraction*max(abs(data)) | 
| 'cbar'    | plot color bar to right of erp-image {default no} | 
| 'erp'    | plot erp time average of the trials below the image | 
| 'auxvar'    | [matrix] -> plot auxiliary variable(s) for each trial as separate traces. To plot N traces, the auxvar matrix should be size (N,frames) ELSE, 'auxvar',{[matrix],{colorstrings}} specifies the N trace colors. e.g. colorstrings = {'r','bo-','k:'} | 
| Note: | FOR MORE INPUT ARGS: phase,coher,allamps,topo,spec,srate,signif,vert,noxlabel SEE: >> erpimage moreargs | 
| Outputs: | |
| outdata    | (times,epochsout) data matrix (after smoothing) | 
| outvar    | (1,epochsout) sortvar vector (after smoothing) | 
| outtrials    | (1,epochsout) smoothed trial numbers | 
| limits    | (1,10) array, 1-9 as in 'limits' above, then analysis frequency (Hz) | 
| axhndls    | vector of 1-7 plot axes handles (img,cbar,erp,amp,coh,topo,spec) | 
| erp    | plotted ERP average | 
| Note: | FOR MORE OUTPUT ARGS: amps,coher,cohsig,ampsig,outamps,phsangls,phsamp,sortidx SEE: >> erpimage moreargs | 
| Authors: | Scott Makeig & Tzyy-Ping Jung, CNL/Salk Institute, La Jolla, 3-2-1998 | 
| See also: | erpimages, phasecoher, rmbase, cbar, movav |