From d25de5f979520a784b16a80f4956807656386fbc Mon Sep 17 00:00:00 2001 From: Shrediquette <42935970+Shrediquette@users.noreply.github.com> Date: Mon, 12 Aug 2024 22:22:05 +0200 Subject: [PATCH] More fixes for loading and detecting filter matrices when deployed as toolbox or app --- +wOFV/FetchFilterMatrices.m | 10 ++++++++-- +wOFV/getFmatPyramid.m | 14 +++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/+wOFV/FetchFilterMatrices.m b/+wOFV/FetchFilterMatrices.m index 9de8597e..20f36f31 100644 --- a/+wOFV/FetchFilterMatrices.m +++ b/+wOFV/FetchFilterMatrices.m @@ -1,14 +1,20 @@ function FetchFilterMatrices() - %Jassal, G., & Schmidt, B. E. (2024, August 12). wOFV Filter Matrices. https://doi.org/10.17605/OSF.IO/Y48MK - +gui.update_progress(0) +uiwait(warndlg(['Wavelet filter matrices do not exist. They are downloaded and stored for later use now.' newline newline 'Please watch the command window for progress messages.'],'No filter matrices found','modal')); +gui.toolsavailable(1) +gui.toolsavailable(0,'Downloading filter matrices...');drawnow FileUrl = 'https://files.osf.io/v1/resources/y48mk/providers/osfstorage/?zip='; FileName = 'Filter Matrices.zip'; disp('Downloading Filter Matrices.') disp('This might take a while...') websave(FileName,FileUrl); +gui.toolsavailable(1) +gui.toolsavailable(0,'Unzipping filter matrices...');drawnow disp('Filter Matrices downloaded, unzipping...') [filepath,~,~]= fileparts(which('PIVlab_GUI.m')); unzip(FileName,fullfile(filepath,'+wOFV','Filter matrices')) disp('Filter Matrices stored.') delete(FileName) +gui.toolsavailable(1) +gui.toolsavailable(0,'Busy, please wait...');drawnow \ No newline at end of file diff --git a/+wOFV/getFmatPyramid.m b/+wOFV/getFmatPyramid.m index 24bd0951..766743e9 100644 --- a/+wOFV/getFmatPyramid.m +++ b/+wOFV/getFmatPyramid.m @@ -1,26 +1,26 @@ function Fmats = getFmatPyramid(M,PyramidLevels) %check if the filter matrix exists, if it doesn't generate them -if ~exist(['+wOFV/Filter Matrices/bior6.8/' num2str(M) '/Fmats.mat'],'file') - uiwait(warndlg(['Wavelet filter matrices do not exist. They are downloaded and stored for later use now.' newline newline 'Please watch the command window for progress messages.'],'No filter matrices found','modal')); + +[filepath,~,~]= fileparts(which('PIVlab_GUI.m')); +if ~exist(fullfile(filepath,'+wOFV','Filter matrices','bior6.8',num2str(M) ,'Fmats.mat'),'file') wOFV.FetchFilterMatrices(); end -load(['+wOFV/Filter Matrices/bior6.8/' num2str(M) '/Fmats.mat'],'Fw','FwInv','N0','N1','N2','N3','N4'); +load(fullfile(filepath,'+wOFV','Filter matrices','bior6.8',num2str(M) ,'Fmats.mat'),'Fw','FwInv','N0','N1','N2','N3','N4'); Fmats.FmatPy{1} = cat(3,Fw,FwInv); Fmats.NiPy{1} = cat(3,N0,N1,N2,N3,N4); -load(['+wOFV/FD Matrices/' num2str(M) '/Dmat.mat'],'Dmat'); +load(fullfile(filepath,'+wOFV','FD matrices',num2str(M),'Dmat.mat'),'Dmat'); Fmats.DmatPy{1} = Dmat; for iii = 1:(PyramidLevels-1) - load(['+wOFV/Filter Matrices/bior6.8/' num2str(2^(log2(M)-iii)) '/Fmats.mat'],'Fw','FwInv','N0','N1','N2','N3','N4') + load(fullfile(filepath,'+wOFV','Filter matrices','bior6.8',num2str(2^(log2(M)-iii)),'Fmats.mat'),'Fw','FwInv','N0','N1','N2','N3','N4') Fmats.FmatPy{iii+1} = cat(3,Fw,FwInv); Fmats.NiPy{iii+1} = cat(3,N0,N1,N2,N3,N4); end - for iii = 1:(PyramidLevels-1) - load(['+wOFV/FD Matrices/' num2str(2^(log2(M)-iii)) '/Dmat.mat'],'Dmat') + load(fullfile(filepath,'+wOFV','FD matrices',num2str(2^(log2(M)-iii)),'Dmat.mat'),'Dmat') Fmats.DmatPy{iii+1} = Dmat; end \ No newline at end of file