-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmeanIAF.m
50 lines (44 loc) · 1.48 KB
/
meanIAF.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
function [paf, cog] = meanIAF(sums, nchan, cmin)
% Average repeated-measures PAF and CoG means in proportion to number of
% channels that contributed to calculation of each respective mean.
% No averaging performed if only one valid estimate provided per subject.
%
% Part of the `restingIAF` package, (c) Andrew W. Corcoran, 2016-2017.
% Visit github.com/corcorana/restingIAF for licence, updates, and further
% information about package development and testing.
%
%%
% Outputs:
% paf = grand average peak alpha frequency
% cog = grand average centre of gravity
%
% Required inputs:
% sums = structure containing mean PAF/CoG estimates and number of
% channels from which estimates derived
% nchan = vector containing number of channels per recording
% cmin = minimum number of channel estimates required for inclusion
%% setup variable check
if ~exist('sums', 'var')
error('Provide structure containing PAF and CoG estimate fields');
end
if ~exist('nchan', 'var')
error('Provide vector containing number of channels in each recording')
end
%%
% peaks
nSelect = [sums.pSel] >= cmin;
if sum(nSelect) == 0
paf = NaN;
else
paf = sum([sums(nSelect).paf].*([sums(nSelect).pSel]./nchan(nSelect)))...
/ sum([sums(nSelect).pSel]./nchan(nSelect));
end
% gravs
nSelect = [sums.gSel] >= cmin;
if sum(nSelect) == 0
cog = NaN;
else
cog = sum([sums(nSelect).cog].*([sums(nSelect).gSel]./nchan(nSelect)))...
/ sum([sums(nSelect).gSel]./nchan(nSelect));
end
end