AddDiscMaterial

From openEMS

Jump to: navigation, search

AddDiscMaterial(CSX,name,varargin) belongs to the mechanism to handle discretized materials in openEMS

A discretized material allows a voxel-based description of objects in a simulation volume - as opposed to a description using geometrical objects like boxes, cylinders etc..

To make use of it you first create a database of materials used in your design. Then, you create a rectilinear voxel mesh inside your simulation volume. Finally, you create a 3D matrix in Matlab. The size of that matrix is equal to the number of voxels in x,y, and z direction. Each element of that matrix is an uint giving a position in the material database. The respective voxel is supposed to be filled with the material pointed at by the uint.

Using CreateDiscMaterial(filename, data, mat_db, mesh) the discretized material is stored into a .h5-file.

Using AddDiscMaterial(CSX,name,varargin) it can be added as a property to your CSX-object.

Adding a primitive of the respective property will finally create the discretized material in the simulation volume.

Code Example:

%put phantom
mat_db.epsR=[bg1e bge2e csfe bgme, bwme fe me sde bce bve fe de bme ];
mat_db.kappa=2*pi*f0*EPS0*[bg1ee bg2ee csfee bgmee, bwmee fee mee sdee bcee bvee fee dee bmee ];
mat_db.density=zeros(1,13);
mat_db.Name={'Background','Background2','CSF','BrainGreyMatter','BrainWhiteMatter','Fat','Muscle','SkinDry','BoneCortical',...
    'BloodVessel','Fat2','Dura','BoneMarrow'};
nii = load_nii('subject04_crisp_v.nii');
size_of_img=size(nii.img);
nii_extent=size_of_img.*nii.hdr.dime.pixdim(2:4);

hdf5_mesh.x = -nii_extent(1)/2:nii.hdr.dime.pixdim(2):nii_extent(1)/2;
hdf5_mesh.y = -nii_extent(2)/2:nii.hdr.dime.pixdim(3):nii_extent(2)/2;
hdf5_mesh.z = -nii_extent(3)/2:nii.hdr.dime.pixdim(4):nii_extent(3)/2;

if ~exist('phantom.h5','file')
    
    CreateDiscMaterial('phantom.h5', uint8(nii.img)+1, mat_db, hdf5_mesh )
    
end
                         
CSX = AddDiscMaterial(CSX,'phantom','Scale',1,'File','c:\Users\NIELS\Documents\tomographer\Matlab\phantom.h5');
start = [hdf5_mesh.x(1)   hdf5_mesh.y(1)   hdf5_mesh.z(1)];
stop  = [hdf5_mesh.x(end) hdf5_mesh.y(end) hdf5_mesh.z(end)];
CSX = AddBox(CSX,'phantom',3,start,stop);

Note the following mapping from the voxel-data in the given example to the material database:

data(m,n,o) ---> mat_db.epsR(data(m,n,o)+1) (all other elements of mat_db dto.):

Retrieved from "index.php/AddDiscMaterial"