Skip to content

Commit

Permalink
Merge pull request #20 from FranckLab/dev
Browse files Browse the repository at this point in the history
Added 'm' grid point as output
  • Loading branch information
mohakpatel authored Jan 24, 2018
2 parents 1d93039 + 0a8175f commit 882c10e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Matlab Code/DVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@

%% equation 4

if prod(single(sSize == 32)) || prod(single(sSize == 64)) || prod(single(sSize == 128))
if prod(single(sSize == 32)) || prod(single(sSize == 16))
sSize = sSize(1);

x = cell(1,3);
Expand Down
5 changes: 4 additions & 1 deletion Matlab Code/Example/exampleRunFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
% u{time}{2} = displacement in y-direction at t=time of size MxNxP
% u{time}{3} = displacement in z-direction at t=time of size MxNxP
% cc: peak values of the cross-correlation for each interrogation
% dm: meshgrid spacing (8 by default)
% m: The grid points at which displacements are computed. The grid
% points locations are in the same format as 'u'.
%
% NOTES
% -------------------------------------------------------------------------
Expand All @@ -69,7 +72,7 @@
filename = 'vol*.mat';

% Estimate displacements via IDVC
[u, cc, dm] = funIDVC(filename, sSize, incORcum);
[u, cc, dm, m] = funIDVC(filename, sSize, incORcum);

save('resultsFIDVC.mat','u','cc','dm');

Expand Down
45 changes: 27 additions & 18 deletions Matlab Code/IDVC.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [u, cc, dm] = IDVC(varargin)
function [u, cc, dm, m] = IDVC(varargin)
% [u, cc] = IDVC(I,sSize,u0,className);
% I = filterDisplacements(I0,filterSize,z) applies a low-pass convolution
% filter to the displacement field to mitigate divergence based on
Expand All @@ -25,6 +25,8 @@
% u{4} = magnitude
% cc: peak values of the cross-correlation for each interrogation
% dm: meshgrid spacing (8 by default)
% m: The grid points at which displacements are computed. The grid
% points locations are in the same format as 'u'.
%
% NOTES
% -------------------------------------------------------------------------
Expand Down Expand Up @@ -60,14 +62,16 @@
[converged01, SSE(i-1) , sSize(i,:), sSpacing(i,:)] = checkConvergenceSSD(I,SSE,sSize,sSpacing,convergenceCrit);

if ~converged01
finalSize = sSize(i,:);

[I, m] = parseImages(I,sSize(i,:),sSpacing(i,:));

% run cross-correlation to get an estimate of the displacements
[du, cc] = DVC(I,sSize(i,:),sSpacing(i,:),DVCPadSize,ccThreshold);

% add the displacements from previous iteration to current
waitbar(3/7,wb,'Adding displacements from previous iteration');
[u, ~, cc] = addDisplacements(u,du,cc,m,dm);
[u, ~, cc, mFinal] = addDisplacements(u,du,cc,m,dm);

% filter the displacements using a predictor filter
waitbar(4/7,wb,'Filtering Displacements');
Expand All @@ -87,11 +91,11 @@
disp(['Elapsed time (iteration ',num2str(i-1),'): ',num2str(toc(ti))]);
i = i + 1;
end

end

[u,cc] = parseOutputs(u,cc,dm,padSize);
end

[u,cc,m] = parseOutputs(u,cc,finalSize,padSize,mFinal);
delete(wb);
disp(['Convergence at iteration ',num2str(i)]);
disp(['Title time: ',num2str(toc(t0))]);
end
Expand Down Expand Up @@ -167,22 +171,27 @@
end


function [u,cc] = parseOutputs(u,cc,filterSpacing,padSize)
function [u,cc,m] = parseOutputs(u,cc,finalsSize,padSize,m)
% parses outputs and unpads the displacment field and cc.

unpadSize(1,:) = ceil(padSize(1,:)/filterSpacing);
unpadSize(2,:) = floor((padSize(2,:)+1)/filterSpacing);
% +1 from the extra meshgrid point during the meshing of the DVC algorithm. EBK (10-23-2013)

% % % % unpadSize(1,:) = ceil(padSize(1,:)/filterSpacing);
% % % % unpadSize(2,:) = floor((padSize(2,:)+1)/filterSpacing);
% % % % % +1 from the extra meshgrid point during the meshing of the DVC algorithm. EBK (10-23-2013)
% % % %
% % % % for i = 1:3
% % % % u{i} = u{i}(1+unpadSize(1,1):end-unpadSize(2,1),...
% % % % 1+unpadSize(1,2):end-unpadSize(2,2),...
% % % % 1+unpadSize(1,3):end-unpadSize(2,3));
% % % % end
% % % % u{4} = sqrt(u{1}.^2 + u{2}.^2 + u{3}.^2);
% % % %
% % % % cc = cc(1+unpadSize(1,1):end-unpadSize(2,1),...
% % % % 1+unpadSize(1,2):end-unpadSize(2,2),...
% % % % 1+unpadSize(1,3):end-unpadSize(2,3));
filterSpacing = finalsSize/2;
u{4} = sqrt(u{1}.^2 + u{2}.^2 + u{3}.^2);
for i = 1:3
u{i} = u{i}(1+unpadSize(1,1):end-unpadSize(2,1),...
1+unpadSize(1,2):end-unpadSize(2,2),...
1+unpadSize(1,3):end-unpadSize(2,3));
m{i} = m{i}-padSize(1,i)-filterSpacing(i);
end
u{4} = sqrt(u{1}.^2 + u{2}.^2 + u{3}.^2);

cc = cc(1+unpadSize(1,1):end-unpadSize(2,1),...
1+unpadSize(1,2):end-unpadSize(2,2),...
1+unpadSize(1,3):end-unpadSize(2,3));

end
2 changes: 1 addition & 1 deletion Matlab Code/addDisplacements.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [u, du, cc] = addDisplacements(u0,du0,cc0,m0,dm)
function [u, du, cc, m] = addDisplacements(u0,du0,cc0,m0,dm)
% u = addDisplacements(u,thr,epsilon) removes outliers using the universal
% outlier test based on
%
Expand Down
6 changes: 4 additions & 2 deletions Matlab Code/funIDVC.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [u, cc, dm] = funIDVC(varargin)
function [u, cc, dm, m] = funIDVC(varargin)
% u = funIDVC(filename, sSize, incORcum) is the main function that performs
% IDVC on a time increment of volumetric images.
%
Expand Down Expand Up @@ -40,6 +40,8 @@
% u{time}{4} = magnitude
% cc: peak values of the cross-correlation for each interrogation point
% dm: meshgrid spacing (8 by default)
% m: The grid points at which displacements are computed. The grid
% points locations are in the same format as 'u'.
%
% NOTES
% -------------------------------------------------------------------------
Expand All @@ -62,7 +64,7 @@

%Start DVC
disp(['Current file: ' fileInfo.filename{i}])
[u_, cc{i-1}, dm] = IDVC(I,sSize0,u_);
[u_, cc{i-1}, dm, m] = IDVC(I,sSize0,u_);

% Saving iterations of the DVC
u{i-1}{1} = -u_{1}; u{i-1}{2} = -u_{2}; u{i-1}{3} = -u_{3}; u{i-1}{4} = u_{4};
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The Fast Iterative Digital Volume Correlation Algorithm (FIDVC) is the next generation DVC algorithm providing significantly improved signal-to-noise, and large (finite) deformation (incl. large rotations and image stretches) capture capability at low computational cost (please see [Bar-Kochba, Toyjanova et al., Exp. Mechanics, 2014](http://link.springer.com/article/10.1007/s11340-014-9874-2?sa_campaign=email/event/articleAuthor/onlineFirst) for more details).

### Important pages
* [Download latest version v1.2.3!](https://github.com/FranckLab/FIDVC/releases)
* [Download latest version v1.2.4!](https://github.com/FranckLab/FIDVC/releases)
* [Example data](https://drive.google.com/folderview?id=0ByhZqlrbo5srSmU2ZW1TOXpfVkE&usp=sharing)
* [FAQ](https://github.com/FranckLab/FIDVC#faq)
* [Questions/Issues](https://github.com/FranckLab/FIDVC/issues)
Expand Down

0 comments on commit 882c10e

Please sign in to comment.