Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes memory bugs and removes unused code and routines #264

Merged
merged 4 commits into from
Sep 11, 2024
Merged
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
52 changes: 5 additions & 47 deletions API/parseClassToStructs.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,34 +90,16 @@
% Each cell is {1 x Inf char}


% First parse the class to a structure variable.
%% First parse the class to a structure variable.
inputStruct = project.toStruct();

%% Start by removing the cell arrays
contrastLayers = inputStruct.contrastLayers;
layerDetails = inputStruct.layerDetails;

% If any of the contrastLayers are empty, replace the empty cells by zero
% thickness layers
for i = 1:length(contrastLayers)
thisLayer = contrastLayers{i};
if isempty(thisLayer)
contrastLayers{i} = 0;
end
end

% Do the same for layerDetails
if isempty(layerDetails)
layerDetails = {0};
end

% Pull out all the cell arrays (except priors) into one array
%% Pull out all the cell arrays (except priors) into one array
problemCells{1} = inputStruct.contrastRepeatSLDs;
problemCells{2} = inputStruct.data;
problemCells{3} = inputStruct.dataLimits;
problemCells{4} = inputStruct.simLimits;
problemCells{5} = contrastLayers;
problemCells{6} = layerDetails;
problemCells{5} = inputStruct.contrastLayers;
problemCells{6} = inputStruct.layerDetails;
problemCells{7} = inputStruct.paramNames;
problemCells{8} = inputStruct.backgroundParamNames;
problemCells{9} = inputStruct.scalefactorNames;
Expand All @@ -137,39 +119,15 @@

% Now deal with domains cell arrays
if isa(project, 'domainsClass') && isa(project.domainContrasts, 'domainContrastsClass')

domainContrastLayers = inputStruct.domainContrastLayers;

% If any of the domainContrastLayers are empty, replace the empty
% cells by zero thickness layers
for i = 1:length(domainContrastLayers)
thisLayer = domainContrastLayers{i};
if isempty(thisLayer)
domainContrastLayers{i} = 0;
end
end

problemCells{18} = inputStruct.domainContrastRepeatSLDs;
problemCells{19} = domainContrastLayers;
problemCells{19} = inputStruct.domainContrastLayers;
end

if isa(project, 'domainsClass')
problemCells{20} = inputStruct.domainRatioNames;
end

% Fix for cell array bug with custom layers - is this needed still??
if strcmpi(inputStruct.modelType,'custom layers') || strcmpi(inputStruct.modelType,'custom xy')
for i = 1:length(problemCells{5})
problemCells{5}{i} = 0;
end
for i = 1:length(problemCells{19})
problemCells{19}{i} = 0;
end

problemCells{6} = {0};

end

% Also the custom files array..
if isempty(problemCells{14})
problemCells{14} = {''};
Expand Down
2 changes: 1 addition & 1 deletion API/projectClass/contrastsClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
contrastLayers{i} = thisArray;
contrastCustomFile(i) = NaN;
otherwise
contrastLayers{i} = {};
contrastLayers{i} = [];
whichFile = thisContrast.model;
thisContrastFileNum = find(strcmpi(whichFile, allowedNames.customFileNames));
contrastCustomFile(i) = thisContrastFileNum;
Expand Down
2 changes: 1 addition & 1 deletion compile/fullCompile/makeCompileArgsFull.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
ARG = coder.typeof(0,[1 maxArraySize],[1 1]);
ARGS_1_2{5} = coder.typeof({ARG}, [1 maxArraySize],[0 1]);
ARG = coder.typeof(0,[1 10],[1 1]);
ARGS_1_2{6} = coder.typeof({ARG}, [maxArraySize 1],[1 0]);
ARGS_1_2{6} = coder.typeof({ARG}, [maxArraySize 1],[1 1]);
ARG = coder.typeof('X',[1 maxArraySize],[0 1]);
ARGS_1_2{7} = coder.typeof({ARG}, [1 maxArraySize],[0 1]);
ARG = coder.typeof('X',[1 maxArraySize],[0 1]);
Expand Down
2 changes: 1 addition & 1 deletion compile/reflectivityCalculation/makeCompileArgs.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
ARG = coder.typeof(0,[1 maxArraySize],[1 1]);
ARGS_1_2{5} = coder.typeof({ARG}, [1 maxArraySize],[0 1]);
ARG = coder.typeof(0,[1 10],[1 1]);
ARGS_1_2{6} = coder.typeof({ARG}, [maxArraySize 1],[1 0]);
ARGS_1_2{6} = coder.typeof({ARG}, [maxArraySize 1],[1 1]);
ARG = coder.typeof('X',[1 maxArraySize],[0 1]);
ARGS_1_2{7} = coder.typeof({ARG}, [1 maxArraySize],[0 1]);
ARG = coder.typeof('X',[1 maxArraySize],[0 1]);
Expand Down
30 changes: 0 additions & 30 deletions minimisers/NS/plotLivePointsWithEllipses.m

This file was deleted.

24 changes: 4 additions & 20 deletions targetFunctions/common/groupLayers/allocateLayersForContrast.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function thisContrastLayers = allocateLayersForContrast(contrastLayers,outParameterisedLayers,useImaginary)
function thisContrastLayers = allocateLayersForContrast(contrastLayers,outParameterisedLayers,useImaginary)
% Decide which layers are needed for a particular contrast.
% This function takes the master array of all layers
% and extracts which parameters are required for
Expand All @@ -8,30 +8,14 @@
% outParameterisedLayers - List of all the available layers
% thisContrastLayers - Array detailing which layers are required for this contrast

coder.varsize('thisContrastLayers',[1000 6],[1 1]);

if useImaginary
thisContrastLayers = zeros(length(contrastLayers),6);
else
thisContrastLayers = zeros(length(contrastLayers),5);
end

for i = 1:length(contrastLayers)
if (contrastLayers(i) ~= 0)
thisLayer = outParameterisedLayers{contrastLayers(i)};

% % Check the length of thisLayer. If it's 6, then we have an
% % imaginary SLD defined. Combile them into one complex number at
% % this point.
% if length(thisLayer) == 6
% compSLD = complex(thisLayer(2),thisLayer(3));
% thisLayer = [thisLayer(1) compSLD thisLayer(4:end)];
% end

thisContrastLayers(i,:) = thisLayer;
else
thisContrastLayers(1,:) = [];
end
for i = 1:length(contrastLayers)
thisContrastLayers(i,:) = outParameterisedLayers{contrastLayers(i)};
end

end
end

This file was deleted.

8 changes: 3 additions & 5 deletions targetFunctions/common/resampleLayers/SLDFunction.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
if ~isempty(where)
sldVal = rho(where);
else
belowVals = find(x > z);
aboveVals = find(x < z);
below = belowVals(end);
above = aboveVals(1);

below = find(x > z, 1, 'last');
above = find(x < z, 1);

belowY = rho(below);
aboveY = rho(above);

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat
Binary file not shown.
Binary file modified tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/nonPolarisedTFReflectivityCalculation/customLayersInputs.mat
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat
Binary file not shown.
Binary file modified tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat
Binary file not shown.
Binary file modified tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ function loadTFParams(testCase, TFFile)
methods (Test, ParameterCombination='exhaustive')
%% Test High Level RAT Routines

function testRATEmpty(testCase)
% Test that RAT runs for a project without any layers.
emptyProject = projectClass();
emptyProject.addContrast('data', 'Simulation',...
'background', 'Background 1',...
'bulkIn', 'SLD Air',...
'bulkOut', 'SLD D2O',...
'scalefactor', 'Scalefactor 1',...
'resolution', 'Resolution 1');

[~, ~] = RAT(emptyProject,testCase.controlsInput);
end

function testRAT(testCase)
[projectOutput, result] = RAT(testCase.project,testCase.controlsInput);

Expand Down
2 changes: 1 addition & 1 deletion tests/testContrastsClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ function testToStructCustomLayers(testCase)
for i=1:testCase.numContrasts
testCase.exampleClass.contrasts{i}.model = {'DSPC Model'};
end
testCase.exampleStruct.contrastLayers = {{} {} {}};
testCase.exampleStruct.contrastLayers = {[] [] []};
testCase.exampleStruct.contrastCustomFile = [1 1 1];

testCase.verifyEqual(testCase.exampleClass.toStruct(testCase.allowedNames, 'custom layers', testCase.varTable), testCase.exampleStruct);
Expand Down
Binary file modified tests/testProjectConversion/DSPCBilayerProjectClass.mat
Binary file not shown.
Binary file modified tests/testProjectConversion/monolayerVolumeModelProjectClass.mat
Binary file not shown.
131 changes: 0 additions & 131 deletions utilities/misc/hdrload.m

This file was deleted.

Loading