Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions API/checkRange.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function problemStruct = checkRange(problemStruct, limits)
% Check the range of fitted parameters, remove parameter from fit if range is too small.
%
% Parameters
% ----------
% problemStruct : struct
% The project struct.
% limits : struct
% The limits for each parameter.
%
% Returns
% -------
% problemStruct : struct
% The project struct with fit information.
fields = {"params", "backgroundParams", "scalefactors", "bulkIns",...
"bulkOuts", "resolutionParams", "domainRatios"};
titles = {"Parameter", "Background parameter", "Scalefactor", "Bulk in",...
"Bulk out", "Resolution parameter", "Domain ratio"};

for i = 1:length(fields)
fitIndices = find(problemStruct.checks.(fields{i}));

for j = 1:length(fitIndices)
lower = limits.(fields{i})(fitIndices(j),1);
upper = limits.(fields{i})(fitIndices(j),2);
minRange = abs(problemStruct.(fields{i})(fitIndices(j))) * 1e-6;
if minRange == 0
minRange = 1e-6;
end

if (upper - lower) < minRange
paramName = problemStruct.names.(fields{i}){fitIndices(j)};
warning('%s "%s" was removed from the fit because its range is too small (< %g).', titles{i}, paramName, minRange);
problemStruct.checks.(fields{i})(fitIndices(j)) = 0;
end
end
end

end

3 changes: 3 additions & 0 deletions API/parseClassToStructs.m
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@
problemStruct.checks.domainRatios = ones(1,0);
end

if ~strcmpi(inputControls.procedure, procedures.Calculate.value)
problemStruct = checkRange(problemStruct, limits);
end
% Make sure the indices cannot lie outside of the arrays
checkIndices(problemStruct, inputStruct.files);

Expand Down
14 changes: 7 additions & 7 deletions API/parseOutToProjectClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,43 @@
%(1) Parameters
params = problemStruct.params;
for i = 1:length(params)
project.setParameter(i, 'value', params(i));
project.setParameter(i, 'value', params(i), 'fit', logical(problemStruct.checks.params(i)));
end

%(2) Backgrounds
backgroundParams = problemStruct.backgroundParams;
for i = 1:length(backgroundParams)
project.setBackgroundParam(i, 'value', backgroundParams(i));
project.setBackgroundParam(i, 'value', backgroundParams(i), 'fit', logical(problemStruct.checks.backgroundParams(i)));
end

%(3) Scalefactors
scalefactors = problemStruct.scalefactors;
for i = 1:length(scalefactors)
project.setScalefactor(i,'value',scalefactors(i));
project.setScalefactor(i,'value',scalefactors(i), 'fit', logical(problemStruct.checks.scalefactors(i)));
end

%(4) Bulk In
bulkIns = problemStruct.bulkIns;
for i = 1:length(bulkIns)
project.setBulkIn(i,'value',bulkIns(i));
project.setBulkIn(i,'value',bulkIns(i), 'fit', logical(problemStruct.checks.bulkIns(i)));
end

%(5) Bulk Out
bulkOuts = problemStruct.bulkOuts;
for i = 1:length(bulkOuts)
project.setBulkOut(i,'value',bulkOuts(i));
project.setBulkOut(i,'value',bulkOuts(i), 'fit', logical(problemStruct.checks.bulkOuts(i)));
end

%(6) Resolutions
resolutionParams = problemStruct.resolutionParams;
for i = 1:length(resolutionParams)
project.setResolutionParam(i,'value',resolutionParams(i));
project.setResolutionParam(i,'value',resolutionParams(i), 'fit', logical(problemStruct.checks.resolutionParams(i)));
end

% (7) Domain ratio
if strcmpi(problemStruct.TF, calculationTypes.Domains.value)
domainRatios = problemStruct.domainRatios;
for i = 1:length(domainRatios)
project.setDomainRatio(i,'value',domainRatios(i));
project.setDomainRatio(i,'value',domainRatios(i), 'fit', logical(problemStruct.checks.domainRatios(i)));
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{'Sam tails hydration', 1, 5.253, 50, true, 'uniform', 0, Inf};
{'Sam rough', 1, 5.64, 15, true, 'uniform', 0, Inf};
{'cw thick', 10, 17.12, 28, true, 'uniform', 0, Inf};
{'cw SLD', 0, 0, 1e-09, false, 'uniform', 0, Inf};
{'cw SLD', 0, 0, 0, false, 'uniform', 0, Inf};
{'SAM head thick', 5, 8.56, 17, true, 'gaussian', 10, 2};
{'SAM head SLD', 1e-07, 1.75e-06, 2e-06, false, 'uniform', 0, Inf};
{'SAM head hydration', 10, 45.45, 50, true, 'uniform', 0, Inf};
Expand Down
Loading