Borrar filtros
Borrar filtros

parseInputs(varargin{:}) related questions

32 visualizaciones (últimos 30 días)
tao wang
tao wang el 20 de Nov. de 2017
Respondida: BA el 10 de Feb. de 2018
I am trying to calculate the deformation displacement of two MRI images. My code has been shown below:
function [u, cc] = DVC(varargin)
% Parse inputs and create meshgrid
[I,m,mSize,sSize,MTF,M,ccThreshold] = parseInputs(varargin{:});
% Initialize variables
mSize_ = prod(mSize);
u123 = zeros(mSize_,3);
cc = zeros(mSize_,1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wb = findall(0,'Tag','TMWWaitbar'); wb = wb(1);
waitbar(1/7,wb,'Estimating Displacements (Time Remaining: )');
for k = 1:mSize_
tStart = tic; % begin timer
%--------------------------------------------------------------------------
% grab the moving subset from the images
A = I{1}(m{1}(k,:),m{2}(k,:),m{3}(k,:));
B = I{2}(m{1}(k,:),m{2}(k,:),m{3}(k,:));
% multiply by the modular transfer function to alter frequency content
A = MTF.*A; B = MTF.*B;
% run cross-correlation
A = xCorr3(A,B,sSize);
% find maximum index of the cross-correlaiton
[cc(k), maxIdx] = max(A(:));
% compute voxel resolution displacements
[u1, u2, u3] = ind2sub(sSize,maxIdx);
% gather the 3x3x3 voxel neighborhood around the peak
try xCorrPeak = reshape(A(u1 + (-1:1), u2 + (-1:1), u3 + (-1:1)),27,1);
% last squares fitting of the peak to calculate sub-voxel displacements
du123 = lsqPolyFit3(xCorrPeak, M{1}, M{2});
u123(k,:) = [u1 u2 u3] + du123' - sSize/2 - 1;
%--------------------------------------------------------------------------
catch
u123(k,:) = nan;
end
% xCorrPeak = reshape(A(u1 + (-1:1), u2 + (-1:1), u3 + (-1:1)),27,1);
%
% % least squares fitting of the peak to calculate sub-voxel displacements
% du123 = lsqPolyFit3(xCorrPeak, M{1}, M{2});
% u123(k,:) = [u1 u2 u3] + du123' - (sSize/2) - 1;
%--------------------------------------------------------------------------
% waitbar calculations (update only every 100 iterations)
if rem(k,100) == 0
tRemaining = (toc(tStart)*(mSize_ - k)); % Time remaining for waitbar
waitbar(1/7*(k/mSize_ + 1),wb,['Estimating Displacements (Time Remaining: ', datestr(datenum(0,0,0,0,0,tRemaining),'MM:SS'),')'])
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Reshape displacements and set bad correlations to zero
waitbar(2/7,wb,'Removing Bad Correlations')
%
cc = reshape(double(cc),mSize);
% cc = permute(cc,[2 1 3]);
[cc, ccMask] = removeBadCorrelations(I,cc,ccThreshold);
%
% u = cell(1,3);
% for i = 1:3
% u{i} = reshape(double(u123(:,i)),mSize).*ccMask;
% u{i} = permute(u{i},[2 1 3]);
% end
u{1} = reshape(double(u123(:,2)),mSize).*ccMask;
u{2} = reshape(double(u123(:,1)),mSize).*ccMask;
u{3} = reshape(double(u123(:,3)),mSize).*ccMask;
end
It gets error like
Error in DVC (line 29)
[I,mSize,sSize,ccThreshold] = parseInputs(varargin{:});
  5 comentarios
tao wang
tao wang el 21 de Nov. de 2017
Editada: per isakson el 21 de Nov. de 2017
That is true. I am very new to this part of matlab. I need to do 3D analysis of MRI images. Based on Frank Lab's FIDVC toolbox, they created a method to do 3D images analysis. Their instructions are:
function [u, cc] = DVC(varargin)
% [du, cc] = DVC(I,sSize,sSpacing,ccThreshold) estimates
% displacements between two volumetric images through digital volume
% correlation.
%
% INPUTS
% I: cell containing the undeformed, I{1}, and deformed, I{2} 3-D images
% sSize: interrogation window (subset) size
% sSpacing: interrogation window (subset) spacing. Determines window
% overlap factor
% ccThreshold: threshold value that defines a bad cross-correlation
%
% OUTPUTS
% u: cell containing the displacement field (u{1:3} = {u_x, u_y, u_z})
% cc: peak values of the cross-correlation for each interrogation
%
% NOTES
% all functions are self contained
% If used please cite:
% Bar-Kochba E., Toyjanova J., Andrews E., Kim K., Franck C. (2014) A fast
% iterative digital volume correlation algorithm for large deformations.
% Experimental Mechanics. doi: 10.1007/s11340-014-9874-2
%
% Parse inputs and create meshgrid
%
[I,m,mSize,sSize,MTF,M,ccThreshold] = parseInputs(varargin{:});
% Initialize variables
mSize_ = prod(mSize);
u123 = zeros(mSize_,3);
cc = zeros(mSize_,1);
Thank you!
Adam
Adam el 21 de Nov. de 2017
Well, if it is a toolbox then I assume the function is defined in the toolbox, or probably further down that particular file.

Iniciar sesión para comentar.

Respuestas (2)

Fangjun Jiang
Fangjun Jiang el 21 de Nov. de 2017
Regarding parse inputs, you can type "doc parse" in MATLAB and see an example. It is a better way to write a function to have some checks on the input arguments.
If you are new to MATLAB, just ignore this part and provide all the necessary and needed inputs.

BA
BA el 10 de Feb. de 2018
it could be a hidden function which can be accessed via
which -all parseInputs

Categorías

Más información sobre Biomedical Imaging en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by