Commit e1ecae89 authored by James Desjardins's avatar James Desjardins
Browse files

Add out_dist output to marks_array2flags, and add flag_vals and flag_crit opt...

Add out_dist output to marks_array2flags, and add flag_vals and flag_crit opt inputs (flag_val deprecated).
parent 9a07a608
function [outarray,outind]=marks_array2flags(inarray,varargin)
function [outarray,outind,out_dist]=marks_array2flags(inarray,varargin)
%% handle varargin
g=struct(varargin{:});
......@@ -12,7 +12,19 @@ try g.init_dir; catch, g.init_dir='both'; end; %pos, neg, both
try g.init_crit; catch, g.init_crit=[]; end; %outlier distance classification
try g.flag_method; catch, g.flag_method='z_score'; end; %fixed, dist
try g.flag_val; catch, g.flag_val=3; end; % value of percentage
try g.flag_vals; catch, g.flag_vals=[]; end; %distribution values for flagging by flag_crit = 'q' or 'fixed'
try g.flag_crit; catch, g.flag_crit=[]; end; % value of percentage
% flag_val is deprecated... trated synonymous with flag_crit for
% flag_method "z_score" and "fixed".
try
g.flag_val;
g.flag_crit = g.flag_val;
catch,
% g.flag_val=[];
g.flag_crit = [];
end; % value of percentage
try g.trim; catch, g.trim=0; end;
try g.plot_figs; catch, g.plot_figs='off';end;
......@@ -30,6 +42,13 @@ end
outarray=zeros(size(inarray));
outind=1:size(inarray,2);
m_dist=[];
s_dist=[];
l_dist=[];
u_dist=[];
l_out=[];
u_out=[];
% for each column flag cell of inarray
for coli=outind;
%Calculate mean and standard deviation for each column
......@@ -63,7 +82,8 @@ for coli=outind;
l_out(coli)=m_dist(coli)-s_dist(coli)*g.init_crit;
u_out(coli)=m_dist(coli)+s_dist(coli)*g.init_crit;
case 'fixed'
%not implemented yet.
l_out(coli)=g.init_vals(1);
u_out(coli)=g.init_vals(2);
end
%for each row
......@@ -86,16 +106,22 @@ end
%average column of outarray
critrow=squeeze(mean(outarray,2));
%mean and sd of average outarray column
mccritrow=mean(critrow);
sccritrow=std(critrow);
%set the flag index threshold (may add quantile option here as well)
switch (g.flag_method);
case 'fixed';
rowthresh=g.flag_val;
rowthresh=g.flag_crit;
case 'z_score'
rowthresh=mccritrow+sccritrow*g.flag_val;
mccritrow=mean(critrow);
sccritrow=std(critrow);
rowthresh=mccritrow+sccritrow*g.flag_crit;
case 'q';
qval=[];
qval(1)=.5;
qval(2)=g.flag_vals;
mccritrow=quantile(critrow,qval(1));
sccritrow=quantile(critrow,qval(2));
rowthresh=mccritrow+(sccritrow-mccritrow)*g.flag_crit;
end
%get indeces of rows beyond threshold
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment