Code covered by the BSD License  

Highlights from
Toolkit for Pulsatile flow in arteries

image thumbnail

Toolkit for Pulsatile flow in arteries

by

 

31 Jan 2013 (Updated )

Toolkit to generate pulsatile flow profile, characteristics and dicom images using Navier-Stokes eqs

FlowDICOM(u,r,folder)
function [prefix,num,venc,pixel_size] = FlowDICOM(u,r,folder)
%FlowDICOM FlowDICOM function simulates Phase Contrast MRI modality with generating DICOM images of the pulsatile flow in tube.
%   FlowDICOM(u,r,folder) provides a number of timesteps DICOM images in directory 'folder'.
%   Input parameters for the functions are defined as below:
%
%       u           matrix of velocity data generated by PulsatileFlow(r,ru,mu,freq,p0,pn,phi,timestep,grid).
%       r           radius of the tube.
%       folder      name of the folder in which DICOM images are stored.
%
%
%   [prefix,num,venc,pixel_size] = PulsatileFlowDICOM(u,r,folder) 
%   is returning equivalent PC-MRI parameters for the generated DICOM
%   images. 
%
%   Output parameters for the functions are defined as below:
%
%       prefix      a string demonstratin the prefix is used for the name
%       of the files.
%       num         an array of numbers that are used to demonstrate the
%       sequence of images. 
%       venc        venc or velocity of encoding is the parameters to
%       adjust the image intensity to the input velocity from imaging.
%       pixel_size  is the parameter showing the pixel sizes in the
%       generated DICOM images.
%
%   Examples:
%
%       FlowDICOM(PulsatileFlow(0.001,1060,0.0035,1.4,0,[0.78 1.32 -0.74],[-0.01 -1.45 -0.46],32,16),0.001,'test1') 
%
%       generates 16 DICOM images with size 32 x 32 of the blood flow in an artery of radius 0.001 m with other
%       parameters set in SI.
%
%
%   Reference:
%   A. Pashaei and N Fatouraee, "An analytical phantom for the evaluation
%   of medical flow imaging algorithms.", Phys Med Biol. 2009 Mar 21;54(6):1791-821.
%
%   Copyright 2007-2012 Ali Pashaei. 
%   $Revision: 2.0 $  $Date: 2013/11/12 12:39:00 $

if exist(folder,'dir')
    warningMessage = sprintf('The folder %s already exists!', folder);
    uiwait(warndlg(warningMessage));
else
    mkdir(folder)
end

timestep = size(u,1);
grid = size(u,2);

c=clock;
prefix=strcat(folder,'/',folder,'.',int2str(c(1)),int2str(c(2)),int2str(c(3)),'.');
num=1:timestep;
venc=max(max(max(u)));

ofst=round(grid/2);
rxl=round(3*ofst/4);
pixel_size=r/rxl; 

for i=1:timestep
    filename=strcat(prefix,int2str(num(i)),'.dcm');
    u1(:,:)=u(i,:,:);
    dicomwrite(u1, filename)
end

end

Contact us