-
Notifications
You must be signed in to change notification settings - Fork 1
/
fcn_baseline.m
53 lines (46 loc) · 1.42 KB
/
fcn_baseline.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function [minb,maxb] = fcn_baseline(lc,latency,len_base)
% fcn_baseline() - function which returns the start and the end of
% baselines.
%
% Author: Fanny Grosselin, 2018
%
% Usage:
% >> [minb,maxb] = fcn_baseline(lc,latency,len_base)
%
% Inputs:
% lc - [raw vector of integers] It contains sample points indicating
% starts or ends of baselines. It is the output of the function
% find_resp_marks().
% latency - ['pos'|'neg'] If it's 'pos', lc will be starts of baselines.
% If it's 'neg', lc will be ends of baselines.
% len_base - [char] Number written in char. It describes length of
% baselines.
%
% Outputs :
% minb - [raw vector of integers] It contains starts of baselines.
% maxb - [raw vector of integers] It contains ends of baselines.
%
% See also:
% pop_evokedinduced(), find_resp_marks().
%
EEG = evalin('base','EEG');
%% Start of baseline
% -----------------
lc = lc;
%% Latency of baseline
% -------------------
if strcmp(latency,'pos')
minb = lc; % start of baseline = lc
maxb = [];
else
minb = [];
maxb = lc; % end of baseline = lc
end;
%% Length of baseline
% ------------------
factor_time = abs(abs(EEG.times(1)) - abs(EEG.times(2)));
if isempty(maxb)
maxb = minb + str2num(len_base)/factor_time;
elseif isempty(minb)
minb = maxb - str2num(len_base)/factor_time;
end;