12345678910111213141516171819202122232425262728 |
- function [SNR, SNRconservative] = get_snr(data,goodtrials,t,baselinewin)
- % this function calculates two different estimates of SNR, a normal one
- % and a conservative one.
- % input:
- % - data (has to be NORMALIZED so the peak response is 1)
- % - boolean array of good trials, only good trials are included in std
- % calculation
- % - time axis in same unit as baseline window
- % - [start end] baseline window
- %
- % Rob Teeuwen 20190815
- % first average the baseline window for each trial to get a single
- % baseline value per trial. then calculate the standard deviation
- % of all baseline values. divide 1 by this std (because we
- % normalized, so 1 is the peak response).
- bl = find(t>baselinewin(1) & t<baselinewin(2));
-
- baselines = nanmean(data(bl,goodtrials==1),1); % baselines is 1xtrls array
- SNR = 1/(std(baselines));
- % calculate a conservative SNR as well, first calculate the std for
- % each trial, then average the stds.
- baselinedev = std(data(bl,goodtrials==1));
- SNRconservative = 1/(mean(baselinedev));
- end
|