-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathlimo_winvar.m
More file actions
39 lines (29 loc) · 1014 Bytes
/
limo_winvar.m
File metadata and controls
39 lines (29 loc) · 1014 Bytes
1
function wvarx = limo_winvar(x,percent)% function wvarx = limo_winvar(x,percent)%% Computes the winsorised variance along the last dimension of a 3D matrix.% x is a matrix with EEGLAB format electrodes x frames x trials. % percent must be a number between 0 & 100 - default value = 20;%% See also LIMO_YUEN_TTEST% ------------------------------% Copyright (C) LIMO Team 2019% Original code provided by Prof. Patrick J. Bennett, McMaster University% made 3D: GAR - University of Glasgow - 7 Dec 2009if nargin<2;percent=20;endif isempty(x) error('winvareeg:InvalidInput', 'data vectors cannot have length=0');endif (percent >= 100) || (percent < 0) error('winvareeg:InvalidPercent', 'PERCENT must be between 0 and 100.');end% number of trialsn=size(x,3);% number of items to winsorize and trimg=floor((percent/100)*n);% winsorise xxsort=sort(x,3);wx=xsort;wx(:,:,1:g+1)=repmat(xsort(:,:,g+1),[1 1 g+1]);wx(:,:,n-g:end)=repmat(xsort(:,:,n-g),[1 1 g+1]);wvarx=var(wx,0,3);