{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf400 {\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;} \margl1440\margr1440\vieww18740\viewh17680\viewkind0 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \f0\fs24 \cf0 Meshing methods that we can use:\ \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b \cf0 \ul \ulc0 1. Cleaver GUI (2.0 Beta GUI):\ \i \ulnone pros: Easy to use, user interface, fast, quality tets, structured meshes\ cons: sizing field uses an oversized guess of distance map making resolution too low,\ can take up all RAM and crash your machine, surfaces dependent on smoothness of nrrd input (typically means they jagged output surfaces) \i0\b0 \ 1 - write out your distance maps from Seg3D\ a. Select segmentation layer\ b. Advanced Filters -> Distance Map\ c. Invert Map\ d. Run Filter\ e. Repeat for all layers\ note: may have to combine layers for air map\ note: white = positive -- black = negative\ Cleaver requires positive on the inside of the meshing region\ \ 2 - export distance field maps\ a. File -> export Active Data Layer\ b. Repeat for each distance map\ \ Now we have our inputs for Cleaver\ \ 3 - Open Cleaver\ \ 4 - Load Volumes\ a. File -> Import Volume\ b. Navigate to directory with distance maps\ c. Select all distance maps\ \ 5 - Input Sizing field - Two options\ a. Cleaver generated -- Just click the Compute Sizing Field Button (pretty easy)\ i. (opt) Surface Size drop drop down\ i. constant - makes sizing field of constant values\ ii. adaptive - makes borders more refined\ b. Custom\ i. File -> Import Sizing Field\ ii. Select sizing field\ note: you will need to generate your own sizing field to import here.\ \ 6 - Construct Mesh\ a. Version 1 - Basic tab -> click construct mesh\ \ 7. - Locate mesh\ a. mesh.mat will be generated and placed in your home directory\ b. 3 other files are generated (debug.ply, debug.ele, debug.node)\ \ \ \b \ul \ \ 2. SCIRun (tetgen):\ \i \ulnone Pros: Easy to use, User Interface, Within SCIRun\ Cons: May generate poor elements, May not run (if input is poor), requires understanding of tetgen flags\ \i0\b0 1 - Open SCIRun\ \ 2 - Load nrrd file\ a. Modules -> DataIO -> ReadField module\ b. Click UI button (User Interface) on module\ c. Change 'Files of Type' drop down to NrrdFile\ d. Select nrrd file (segmentation file, not distance maps)\ \ 3 - Clip out mesh region\ a. Modules -> NewField -> FlipFieldByFunction\ b. Click UI button\ c. In Expression box write DATA == [Value you want to clip out]\ d. Select Element Center radio button (nrrd data is on the elements)\ e. click execute\ \ 4 - Extract field boundary\ a. Modules -> NewField -> GetFieldBoundary\ \ 5 - (opt) Smooth Surface\ a. Modules -> NewField -> FairMesh\ \ 6 - Mesh with Tetgen\ a. Modules -> NewField -> InterfaceWithTetgen\ b. Connect surface output to leftmost field port\ c. Execute module\ \ 7 - Write mesh out\ a. Modules -> DataIO -> WriteField\ b. Use UI to select location and name mesh\ \ \ \ \b \ul 3. Biomesh:\ \i \ulnone Pros: high resolution mesh, smooth surfaces, smoothness and resolution control, partial quality control\ Cons: Slow (from several minutes to several hours to days or weeks), potential for poor quality elements\ \i0\b0 1 - Start with Segmentation file (Output of Seg3D)\ \ 2 - Gather an example model_config.py file\ a. Found in SCIRun/src/Applications/FEMesher directory\ \ 3 - Edit model_config.py line by line\ a. Line 1 - path to your segmentation file. Make sure your nrrd file is the last name listed in " "\ b. Line 2 - path to your output folder (you have to make your own output directory first)\ c. Line 3 - materials, type segmentation values (separated by commas) for all tissues\ d. Line 4 - mat_names, type in the names you want assigned to each tissue type. This name\ will be assigned to the output files\ e. Line 5 - mat_radii, leave at default for now\ f. Line 6 - refinement_levels, the larger the number, the smoother the mesh, but the longer\ it will take to run. 4 is probably the highest you'll want to go\ g. Line 7 - max_procs, leave at default for now, looks like it allows you to limit how many\ materials are being processed at one time\ h. Lines 8 - 10 - leave alone (may choose to drop Sizing Scale Var to 1)\ i. Line 11 - Number of iterations for particle system - the larger it is, the better quality the \ mesh, but the slower the mesh generation\ \ 4. In Terminal, navigate to SCIRun/bin/FEMesher\ a. type "cd [directory to SCIRun]/SCIRun/bin/FEMesher"\ note: this can be done one directory at a time \ (ex cd brett <enter> ; then cd Software <enter> ; etc...)\ \ 5. Type the following\ ./BuildMesh.py [path to config file]/model_config.py\ \ 6. Meshes (including complete joined mesh) will be found in the Junctions directory of the Biomesh \ Output folder defined in Line 2 of model_config file\ The mesh file will have a name like this one: heart.tets.fld, blood.tets.fld, tets-all.fld\ \ \ \ \b \ul 4. Biomesh/Cleaver Hybrid:\ \i \ulnone Pros: Fast mesh generation, smooth surfaces, high quality tets, smoothness control, structured meshes\ Cons: Dealing with two programs, Large RAM requirements, For internal tet volume\ control must interface with sizing field files in SCIRun (so 3 programs to use)\ Slow initial input phase (a decent amount of work to get it up and running)\ \i0\b0 1 - Execute steps 3.1 - 3.4 of the Biomesh method\ \ 2 - In the terminal window type:\ ./BuildMesh.py -s1:4 [path to config file]/model_config.py\ note: the s1:4 flag limits the Biomesh package to only compute to stage 4\ It generates tight fields (stage 2) which can be used as smooth Cleaver inputs\ It also generates sizing fields (stage 4) that can be used as Cleaver input\ \ 3 - Gather all of the *.tight-corrected.nrrd files into a new folder\ \ 4 - Gather all *_sf.nrrd files into a folder (it can be the same as the previous set\ a. If there has only one or two tissues (such as a heart model with and without blood) you will\ only need one sizing field, say, the heart sizing field.\ b. If there are more than two surfaces, you'll have to be creative about combining and \ generating your sizing fields. More detail are below. An example SCIRun network to do \ this task is available upon request.\ \ 5 - Open SCIRun\ \ 6 - Load the sizing field (assuming scenario 4.4.a above)\ a. Follow steps 2.1 and 2.2 in the SCIRun method above to load the sizing field file\ \ 7 - Alter Sizing field\ a. Link ReadField Module to a CalculateFieldData module\ Modules -> ChangeFieldData -> CalculateFieldData\ b. Uniform increase of the sizing field (SF)\ In Expression box, increase the minimum SF value (Usually RESULT = DATA+1;)\ The sizing field output from Biomesh generally has a very small minimum value\ This would cause Cleaver to try to generate a very high resolution near the surfaces\ If the number is too small, it will take up too much RAM to complete\ c. Capped max sizing field value\ In Expression box: RESULT = select(DATA>15,15,DATA+1)\ Sometimes you will want to control the largest tet size, do this by capping the SF\ select(,,) is the SCIRun if statement. Think of it as select(IF,Then,Else)\ \ 8 - Execute the entire Cleaver method (section 1) with the tight files as your volume functions with the \ new SF file loaded (See step 1.5.b)\ \ \ \ \b Appendix A: \b0 Combining multiple sizing fields (from 4.4.b)\ \ Combining multiple sizing fields may be difficulty given that you need to scale and translate multiple\ files while making sure that the sizing field at the intersecting surfaces of neighboring tissues are the\ same.\ \ To do this you will need:\ - each of the individual sizing fields for each tissue of interest\ - the segmentation file (preferably aligned to the sizing fields, though this can be transformed if they\ are not aligned).\ \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \cf0 1 - Open SCIRun\ \ 2 - Load segmentation and sizing field files (nrrds\ a. Modules -> DataIO -> ReadField module\ b. Click UI button (User Interface) on module\ c. Change 'Files of Type' drop down to NrrdFile\ d. Select nrrd file (segmentation file, not distance maps)\ \ 3 - Extract Min value of sizing field files\ a. Modules -> Misc -> ReportFieldInfo\ \ 4 - Translate and Scale Sizing fields using Min sizing field values\ a. Modules -> ChangeFieldData -> CalculateFieldData\ b. Connect original Sizing field output to module\ c. Connect ReportFieldInfo output port corresponding to Min data value (4th port from the left)\ to matrix input port\ d. Translate and Scale Data\ i - Simple case -- no max sizing field constraint\ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b \cf0 RESULT = .25*(DATA - A) + .75;\ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b0 \cf0 -- \ul Translation\ulnone \ DATA is the original sizing field\ A is the min matrix value\ (DATA - A) zeros out the sizing field (translates to 0)\ -- \ul Scaling\ulnone \ .25 is the scaling factor (reducing the original sizing field by 1/4)\ -- \ul Additional Translation\ \ulnone .75 translates the sizing field again so that the min sizing field is 0.75\ This MUST be done so that you don't have a 0 value for sizing\ This would crash cleaver\ You could also replace the .75 with a second input matrix\ To do this you would have to use the CreateMatrix module to\ define your min value. If you did this, your equation would be\ RESULT = .25*(DATA - A) + B;\ ii - With max sizing field constraint -- this combines 4.4.b and 4.7.c\ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b \cf0 NEWDATA = .25*(DATA - A) + .75;\ RESULT = select(NEWDATA>=1.0,1.0,NEWDATA); \b0 \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \cf0 -- \ul Translation\ulnone \ DATA is the original sizing field\ A is the min matrix value\ (DATA - A) zeros out the sizing field (translates to 0)\ -- \ul Scaling\ulnone \ .25 is the scaling factor (reducing the original sizing field by 1/4)\ -- \ul Additional Translation\ \ulnone .75 translates the sizing field again so that the min sizing field is 0.75\ This MUST be done so that you don't have a 0 value for sizing\ This would crash cleaver\ You could also replace the .75 with a second input matrix\ To do this you would have to use the CreateMatrix module to\ define your min value. If you did this, your equation would be\ RESULT = .25*(DATA - A) + B;\ -- \ul Capping\ulnone \ The final RESULT scans the data to find the max value you want to \ define. If it is above 1.0 (in this case) you will set the value to 1.0\ otherwise, it will maintain the original value\ \ 5 - Combining Sizing Fields\ The modules you use here are dependent on how many sizing fields you want to combine. In\ this example, we will have 7 sizing fields to combine. This number is chosen to illustrate the \ need for multiple linked modules. If there are less than 4 modules, the steps a - c are all you\ need. If you have more than 8 you will need to repeat steps d - f\ a. Modules -> ChangeFieldData -> CalculateFieldData5\ b. Connect segmentation field and 1st 4 modified Sizing fields outputs to module input ports\ c. Combine first 4 sizing fields\ \b RESULT = select(DATA1==0,-DATA2,\ select(DATA1 == 1,-DATA3,\ select(DATA1 == 2,-DATA4,\ select(DATA1 == 3,-DATA5,DATA1)))); \b0 \ -- DATA1 is the segmentation (0 = air, 1 = tissue 1, 2 = tissue 2, etc...)\ -- DATA2 is sizing field for air (DATA1 == 0)\ The value is set to negative\ This is done to prevent the results from having values that later match\ the segmentation values of 1, 2, 3, 4\ Negative values will not be segmentation label values\ -- DATA3 is sizing field for tissue 1 (DATA1 == 1)\ -- DATA4 is sizing field for tissue 2 (DATA1 == 2)\ -- DATA5 is sizing field for tissue 3 (DATA1 == 3)\ d. Combine additional 3 sizing fields\ i. Modules -> ChangeFieldData -> CalculateFieldData4\ \b RESULT = -select(DATA1==4,-DATA2,\ select(DATA1==5,-DATA3,\ select(DATA1==6,-DATA4,DATA1)));\ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b0 \cf0 -- DATA1 is the output of the previous\ -- notice that there is a negative in front of select() function\ this restores the sizing fields back to positive values.\ \ 6 - Optional additional translation\ Sometimes their is further need to translate the entire field if your original translation was not \ large enough to make sizing fields of a reasonable value...to do this, open a new \ ClipFieldByFunction using the output of the above step as the input and use the function \ \b RESULT = DATA + [whatever value you want]; \b0 \ \ 7 - Write out field\ a. Modules -> DataIO -> WriteField module\ b. Click UI button (User Interface) on module\ c. Change 'Files of Type' drop down to NrrdFile\ d. Select nrrd file (segmentation file, not distance maps) \ }
Attachment:
CombineAndAdjustSizingFields.srn
Description: Binary data
Hi everyone,
I'm adding cleaver to this mailing list to help with the windows crash in 3, below, and the sizing field parameters.
And I'm adding the scirun-users mailing list to help with sizing fields in SCIRun.
- liz
-------- Forwarded Message --------
Subject: Re: Biomesh3d client Date: Thu, 17 Mar 2016 15:44:05 -0300 From: Mariano Fernandez <marianofco@gmail.com> To: Moritz Dannhauer <moritz@sci.utah.edu> CC: Sergei Turovets <sturovets@yahoo.com>, Dana Brooks <brooksdh@gmail.com>, Rob MacLeod <macleod@sci.utah.edu>, Elizabeth Jurrus <liz@sci.utah.edu>
Thanks again,1) The tetgen implementation in SCIRun 5 provided by Moriz runs with no errors. The resulting surfaces of the mesh are rather "voxelized" (not smooth, see attached). I tried to include smoothing (as described in the tutorial file in point 2.5) but the tetgen fails because of self intersecting facets, which is expected as described in your help (http://scirundocwiki.sci.utah.edu/SCIRunDocs/index.php/CIBC:Documentation:SCIRun:Reference:SCIRun:FairMesh). That's a known limitation of tetgen.Dear Moritz and Rob,Thanks for your help. I found your tutorial "Meshing methods and instructions" were instructive.
This what I've tried until now (also for your records / debug):
2) Biomesh alone (third method) is too slow (still running).
3) Cleaver + biomesh seems to be the best world (method number 4) in terms of quality elements, smooth surfaces and speed. I created the Sizing fileds using biomesh3d with the -s1:4 switch (as described in the tutorial). However, I couldn't make cleaver run in windows: in the verbose mode, and after "Creating Octree Mesh ..." the program terminates with no reason and no output.
So, I installed and compiled cleaver in a Virtual Machine with ubuntu 64 bits. I generated the sizing field with the Cleaver-gui and exported it as nrrd file. Then, in SCIRun I changed it by adding 1, 2, 3, 4, 5, and 10 units (as described in point 4.7.c). It works with plus3, plus4, plus5, and plus10. When adding one or 2, or even using the original unmodified Volume-sizing-field, cleaver crashes (just a "Killed" mesage on prompt) I assume it is because of memory requirements.
So, a couple of questions:
a) In point 4.4.b it says that "more info available if needed" in order to combine sizing fields. I would like to know how to combine the individual tissue sizing fields in SciRun to control them independently. So far, I've been only changing the full already combined and cleaver generated "volume sizing field".
b) The gray matter surfaces are still not as smooth as I would like (see "dents" in attached figures) and there is not much variation between "volume sizing field +5" and "volume sizing field +3" (see attached). Are these two effects expected? With lower sizing fields, is it expected that the GM surface gets smoother? Or is it already determined by the segmentation?
Best regards,
Mariano.
2016-03-14 13:23 GMT-03:00 Moritz Dannhauer <moritz@sci.utah.edu>:
Hi Mariano, I will let you know once they bug-fixed it.
Find attached also some responses from another SCI user regarding your cleaver2 error messages and a short tutorial.
Best,
Moritz
On Mar 14, 2016, at 9:40 AM, Mariano Fernandez wrote:
> Thanks Moritz,
>
> Actually, tetgen is what I use (within the iso2mesh Matlab toolbox), but I will try your SCIRun 5 implementation. Please, let me know when you consider Cleaver 2 is ready.
>
> Bests,
>
> Mariano.
> It seems like this user is thinking that a coarse mesh would be more likely to complete. That doesn't seem to be the case given the "default binary_dir = Model configuration file Files\SCIRun does not exist." line in his error message. Besides, his computer would crash long (from memory hogging) before a week was up if Cleaver was working.
>
> In any case, here's a write-up of meshing steps that can be used, though I admit…I don't know much about using it on a windows machine. This should still be up to date.
>
>
>
> Also…does he have the Cleaver documentation? That would be able to explain the flags that he was asking about, but he should be aware that you can't define how many elements the mesher produces. You have to set scaling parameters such that they create a coarser mesh, but you don't have direct control over the total number of elements, or the dimensions of them.
Archive powered by MHonArc 2.6.18.