Skip to content

Commit

Permalink
More fixes for loading and detecting filter matrices when deployed as…
Browse files Browse the repository at this point in the history
… toolbox or app
  • Loading branch information
Shrediquette committed Aug 12, 2024
1 parent 4c6454a commit d25de5f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 8 additions & 2 deletions +wOFV/FetchFilterMatrices.m
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions +wOFV/getFmatPyramid.m
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d25de5f

Please sign in to comment.