How to import voxels from Matlab?


I think my question is related to this one:

I have an anatomical body model as a 3D matrix [x][y][z] in Matlab, with each entry as the index of a tissue. I also have a separate tissue descriptor file.

What is the preferred format to go from Matlab -> Sim4Life to import the voxel model? I'm not able to import a .mat file.

Also, can you please describe the steps to import & process the model (ie. create surfaces, etc.) necessary to properly use this model in an acoustic simulation?

Thank you!

Not sure what the best way to do this, but I recently got a mesh in Matlab and I used stlwrite in matlab to export it as an Stl file which I then imported into S4L.

Otherwise I'd try to reexport the xyz file into another format, but I'm not familiar with these formats.

Sim4Life has it's own voxeler so I'd say the easiest way to be to export your voxels as a 3D model (one for each entity/tissue) and then use the Sim4Life voxeler engine to regenerate the voxels. This will also give you more flexibility in case you want to change the voxel resolution

@dbsim4 first to the second question:
If you manage to import the voxels in Sim4Life, you can selected the LabelField entity and run the Image Tools / Generate Surfaces tool. I would recommend to turn on smoothing and simplification (edge length typically >= voxel size, depending on the feature size you want to preserve).

To import the voxels in Sim4Life, you should write the voxels as a binary file (8-bit, 16-bit or 32-bit unsigned integer). A quick google search resulted in this MATLAB documentation page on writing binary data:

Alternatively, you could find a package to export the voxels as nifti file, and import the nifti file As LabelField (option in import dialog). The importer can also load an iseg tissue list, which assigns colors and names to the tissue labels. An iseg tissue list contains following information. First line is version, second line contains number of tissues not including background with label=0. The subsequent lines start with C and list the color (RGB-Alpha) and name.

C0.00 0.00 1.00 0.50 Bone
C0.00 1.00 0.00 0.50 Fat
C1.00 0.00 0.00 0.50 Skin