You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: phantoms.m
    path of file: ./repos/segment-open/source
    
    the code of the file until where you have to start completion: function varargout = phantoms(varargin)
%PHANTOMS helper function to Seg
    
function pwhelper(rad,flow,roiname)
%----------------------------------
%Helper function to add image stacks

global DATA SET NO

nx = 256;
ny = 256;
nz = 1;
nt = length(flow);
venc = 150;

[x,y] = ndgrid(1:nx,1:ny);

%Magnitude image
mag = single(sqrt((x-nx*0.5).^2+(y-ny*0.5).^2)<=rad);
mag = repmat(mag,[1 1 nt nz]);
NO = length(SET)+1; magno = NO;
SET(NO).IM = mag; %+0.05*randn(size(mag));
SET(NO).VENC = venc;
filephantomhelper;

openfile('setupstacksfromdicom',NO);

%Convert flow to pixel values
numpixels = sum(sum(mag(:,:,1,1)));
area = 0.1*0.1*numpixels; %cm^2

%vol = area*vel*deltat => vel = vol/(area*deltat)
velocity = flow/(area*1); %cm/s

%Convert to phasevalue 0..1 (0.5=0 cm/s);
phasevalue = 0.5+0.5*velocity/venc;

if max(phasevalue)>1
  error('Wrapping.');
end