Sometimes I have to put text on a path

Thursday, July 25, 2013

Comsol and MRI/CT: the pain of working with complex geometries in Comsol; tutorials for comsol

The pain of working with complex geometries in Comsol!

Some questions :

I am trying to develop a quite simple, but realistic human head 3D model based on MR and CT images and use it as geometry in COMSOL Multiphysics.
My workflow is following: MRI/CT data --> segmentation through Simpleware/Amira/SPM --> STL-file --> COMSOL.
I have googled a lot, tried different settings while exporting to STL and then another different settings while importing in COMSOL, different settings of mesh -- everything is useless, still I have such issues as:1.) Errors in rendering the geometry.2.) Errors while meshing. Here [1] is an example of used model of white matter in STL format -- it seems to be good (MeshLab), what is wrong then, why I cannot create the mesh?3.) Troubles segmenting the CSF.4.) My current experiments involving only one tissue at a time, but which would be the best way to create a geometry consisting of all the subdomains at one time? I mean skin, skull, brain (or WM+GM) and CSF together as different subdomains in geometry.
   ONE answer:
ahhh the pain of working with complex geometries in Comsol.... 
I am working on a very similar problem to yours - but using heart. As Daniel suggested it is much easier to import the mesh into Comsol and then convert it back to a draw object in COmsol. 
1.) Errors in rendering the geometry.This is reallly annoying and time-consuming to resolve. You have to play around with the import options in Comsol. In particular -max angle between boundary elements (70 is a good start) -max angle between neighbouring boundary elements (5-10)-and remove small faces 0.01-0.04by trying out different combinations of these , eventually, you will be able to import the mesh and create a draw object without any rendereing issues.
My current experiments involving only one tissue at a time, ; but which would be the best way to create a geometry consisting of >> all the subdomains at one time?Simpleware allows you to simultaneously mesh a number of masks at the same time. You can then import the mesh, made up of the differnt tissue masks, into comsol. If import is successful Comsol will treat each mask as a seperate subdomain. Because Simpleware takes care of contacts between different masks I found this a much better approach than importing each mask individually into comsol - sometimes u'll have gaps between subdomains which are difficult to find. 
final tip.. make sure your segmented masks are at least 2 voxels wide in any direction (x,y,z,oblique). this helps reeduce the rendering errors u get in Comsol.

Simpleware should be able to output a COMSOL mesh file, either .mphtxt or .mphbin. You can then import the mesh into COMSOL which should work perfectly (File>Import mesh). You can't make changes to the geometry once it is in COMSOL. STL is not a good CAD or mesh file sharing format at all. You could also get a human head object by requesting this model from your COMSOL sales representitive:


How to use COMSOL batch to solve many files repeatedly without GUI?


Some "papers":

Diffusion Processes in Human Brain Using COMSOL Multiphysics, 2006; Cherubini, et al
Facoltà di Ingegneria Università Campus Biomedico di Roma, via Longoni, 83 - 00155
Rome, Italy. International Center for Relativistic Astrophysics - I.C.R.A, University of Rome ``La Sapienza'', I-00185 Rome, Italy.1,2
*Corresponding author:

Electrical Stimulation of Brain using a realistic 3D Human Head Model: Improvement of Spatial Focality

An MRI slice and the corresponding E-field induced in brain calculated with COMSOL Multiphysics.  By poular vote, this poster won the Best Poster Award at the COMSOL Conference 2008 Boston.
A. Datta, M. Elwassif, and M. Bikson
Department of Biomedical Engineering, The City College of the CUNY, New York, NY, USA
We calculated the spatial distribution of the electric fields induced in the brain during transcranial current stimulation (TCS). The spatial focality obtained using ‘concentric-ring’ configurations is investigated using a realistic MRI derived 3D finite element model of the human head.

Two disc electrode configurations were simulated using COMSOL Multiphysics. The distant-bipolar configuration, which is comparable to commonly used TCS protocols, resulted in diffuse (un-focal) modulation. The reduced concentric-ring results in higher spatial focality at the expense of increased total surface current. Superficial cortical neurons may be thus selectively targeted using a concentric-ring configuration.

Absorbed Radiation (SAR) in the Human Brain
Model ID: 2190

Scientists use the SAR (specific absorption rate) to determine the amount of radiation that human tissue absorbs. This measurement is especially important for mobile telephones, which radiate close to the brain. The model studies how a human head absorbs a radiated wave from an antenna and the temperature increase that the absorbed radiation causes.
The increasing use of wireless equipment has also increased the amount of radiation energy to which human bodies are exposed. A common property that measures absorbed energy is the SAR value, (specific absorption rate) to determine the amount of radiation that human tissue absorbs.
The human head geometry is the same geometry (SAM Phantom) provided by IEEE, IEC and CENELEC from their standard specification of SAR value measurements. The original geometry was imported into COMSOL Multiphysics. In addition, the model samples some material parameters with a volumetric interpolation function that estimates the variation of tissue type inside the head.
This model studies how a human head absorbs a radiated wave from an antenna, and the temperature increase that this causes. This model requires the RF Module and the Heat Transfer Module.

Absorbed Radiation (SAR) in the Human Brain


Tutorial: Working between COMSOL 4.1 and MATLAB 2010b 

Ok, here is what I figured out in order to be able to take a COMSOL model, modify it in MATLAB and then reopen it in COMSOL for further work:

1. Launch COMSOL normally;
2. Launch MATLAB by using "COMSOL 4.1 with MATLAB";

- Saving your current COMSOL model into the COMSOL server:
a) File > Export Model to Server...
(Default settings: Server = localhost, Port = 2036)
Model = (Ex.: shell_diffusion)

(At that point, your COMSOL model is in the COMSOL server/buffer and is named "shell_diffusion")

- Loading your COMSOL model that you sent in the COMSOL server:
>> model = ModelUtil.model('shell_diffusion');
- Saving the file as a MATLAB .m-file:
>>, 'm'); (Ex.:'shell_diffusion2', 'm'); )
(The file would be saved by default in the current working folder)
- In order to save the file in a specific folder:
>>'C:\COMSOL_Models\shell_diffusion2', 'm');

(You now have created a MATLAB .m-file from a COMSOL file which you can edit and modify)
(I know, you could have just use the File > Save as Model M-File... option in COMSOL but I don't know how you could resend it to COMSOL that way)

- To save your modified model back into COMSOL:
>>'C:\COMSOL_Models\shell_diffusion3'); (No specific file extension will save it as a .mph COMSOL file)

(You now have your COMSOL file back which you can reopen in COMSOL)

-------------------------------tutorials (youtube) comsol 4.2
for absolute beginners

how to use an example


ex: 2D
explain "addd physics" (equations) without programming and math;
electromagnetics, frequency domain (light)

3) geometry
(2objectx->union->one object)
(grossir un objet; faire une N-copie d'un objet: array)

6)global parameters:

7/defining materials

8) meshing

Setting up RF-Physics

10)Simulation and Analysis

11) Analysis: Integration

12) Parameteric Sweep

13) Create Animation, Video, Movie

14) Extract Data from Simulation, Line Scan, Line Graph

---------------------- for "beginners" (quite complex geometry: nanoparticle and concentric spheres):
This tutorial is the first on a series of 3. Shows how to build a model step by step. Electromagnetic waves scattering off of a nano sphere. Use of work planes and revolve. Material properties .

part2 and 3:
Comsol Step by Step: Refraction, Total Internal Reflection (comsol 4.2)
cantilevel & comsol 4.2
part 1/5:
poisson equation/sphere/equation 2 forms for parameters:
Comsol Tutorial How to draw a coil
Postprocessing Tutorial: Creating a Plot in COMSOL Multiphysics
This video tutorial depicts the basics of how to generate plots and how to tweak the different visualization options in order to create the optimal display of results for your COMSOL model. A 2D plot group is created and multiple 2D plot types are superimposed so multiple variables can be displayed simultaneously. The plot types demonstrated here include: Surface, Arrow Surface, Contour, Deformation, and Height Expression.
How to 3D Print COMSOL Models

-------------------------------some video of models in neuroscience

COMSOL Multiphysics CoW Bloodflow simulation
This is a COMSOL model I created for my Biotransport Phenomena course. It simulates blood flow velocity through the Circle of Willis, an arterial network in the brain. It simulates multiple heartbeats at a HR of 60bpm.

Pyramidal Neurons Firing
MATLAB vector containing firing patterns is used as the input function for the COMSOL model.