Skip to content
Snippets Groups Projects
Commit 17e8db39 authored by William Lövfors's avatar William Lövfors
Browse files

Added two new functions

parent 2b85f2b4
No related branches found
No related tags found
No related merge requests found
function [SEM] = AdjustSEM(SEM, type, replaceNan)
if nargin<1, type='mean'; end
if nargin<2, replaceNan=True; end
validSEMs = ~isnan(SEM) & SEM~=0 & ~isinf(SEM);
if strcmp(type,'mean')
SEMReplace=mean(SEM(validSEMs));
elseif strcmp(type,'median')
SEMReplace=median(SEM(validSEMs));
else
disp('Warning, not a valid selection')
invalidSEMs = false(size(SEM));
SEMReplace=nan;
end
if replaceNan
invalidSEMs = isnan(SEM) | SEM==0;
else
invalidSEMs = SEM==0;
end
SEM(invalidSEMs) = SEMreplace;
end
\ No newline at end of file
function [t, t2] = FindLeastSearched(path, modelName)
files=dir(sprintf('%s/**/*%s*mat', path, modelName));
if ~isempty(files)
names={files.name}';
a=regexp(names,'\[(.+)\]','tokens');
a(cellfun(@isempty,a))=[];
a = string(a);
v=strtrim(split(a,',',2));
t=array2table(v);
t2=unique(t,'rows');
v=join(v);
minV=MinFrequency(v);
minV = [minV(contains(minV,'min ') & contains(minV,' k')); minV]; %If doing parameter estimation, start with minimization
t(~strcmp(v,minV(1)),:)=[];
t=t(1,:);
else
t=[];
disp('no files found')
end
end
function [minElement] = MinFrequency(variable)
uniqueData = unique(variable);
[~,w] = ismember(variable,unique(uniqueData));
cellCount = hist(w,unique(w));
% [~,indexToMinCellCount] = min(cellCount);
% minElement = uniqueData(indexToMinCellCount);
ind = cellCount ==min(cellCount);
minElement = uniqueData(ind);
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment