I am trying to make a 3D model of trabecular bone for FEA in Abaqus. I am using slicer to convert the DICOM files of the bone into a 3D model, but when i first did this the .stl file i exported from slicer was only a surface mesh and as such I couldnt assign a section to it in order to apply the material to it, and it said i needed a volumetric mesh. from research, and AI, I found that downloading my model from slicer as a .vtk file was the best idea. The issue is that Abaqus cannot open .vtk files and again from research it seems the best conversion would be to a .inp file. From these forums Ive seen that people have used the meshio package in order to do this but for some reason I am running into a wall with the conversion, presumably from what i’m writing in the python console. The most common issue I get is that it doesn’t recognise my vtk file as a vtk.
Any help with this would be great, I’m pretty new at this so sorry if I am making any stupid mistakes. Thanks
STL file can only store a surface mesh. For finite-element analysis you probably want to create a volumetric mesh.
You can use the SegmentMesher extension in 3D Slicer to create a volumetric mesh from a segmentation. Alternatively, you can export a surface mesh from Slicer and use fTetWild, TetGen, NetGen - or any of the hundreds of mesh generators - to create the volumetric mesh. Each mesher has different capabilities and limitations, so it is not trivial to find one that fulfills all your needs, but there are many options.
Thanks for the response, for the segmentmesher extension, can I use my STL file to create the segment to thus make the volumetric mesh or does it have to be a certain type of file?
Your can import your STL file into a segmentation as described here.
I manage to import the stl file as a segmentation, but for some reason everytime i try to use the segment mesher module my slicer crashes. I’ve done it with both tetgen and cleaver. would it be because i need to reduce the refinement of my mesh and make it coarser?
Yes, start with coarser mesh and watch your RAM usage. You may need to configure more virtual memory in your system if you want to get very detailed mesh (but probably you want to avoid that, as it would harm your simulations, too).
Hi, Ive tried going back to using meshio in the python console, as I am still having issues with the app crashing when using segment mesher. i made the .vtk file by loading my dicom files and then saving that as a .vtk file, made sure to uncheck the compress, and when i load it again in slicer and go to use it to convert it still comes up with the error that it doesnt read it as a vtk.
>>> import meshio
>>> mesh = meshio.read(r"C:\Users\tomyf\OneDrive - Loughborough University\Desktop\Engineering\year 3\Indiviual Project\Specimen1_VOI4_Scan1.vtk")
Error: Couldn’t read file C:\Users\tomyf\OneDrive - Loughborough
University\Desktop\Engineering\year 3\Indiviual
Project\Specimen1_VOI4_Scan1.vtk as vtk
Hi there, I’ve managed to create the .inp file so no need to respond anymore. Thank you very much Mr. Lasso for your help and input, you’ve saved my project!
For those who find themselves in a similar situation, here are some pointers:
First, AI can be helpful in this area, but it definitely trips up on itself and you can get lost in the problems and you don’t know what the original problem was. also, grok seemed to be the best for me, even though i had chatgpt+, it seemed to not know the stuff as good as grok.
When saving your file as a .vtk file, make sure to uncheck the “Compress” box to make sure it saves as a volume.
Also, when you use the SegmentMesher module, if you are on your laptop like I am there are two approaches you can make:
you can either make the mesh really coarse using the Advanced dropdown (it’s described there), and then load it but for me it just made a structure which didnt resemble the desired model at all.
Or you can increase the virtual memory of your laptop, which is what i did. This basically gives you more RAM using the disk of your laptop, therefore the app can run a more difficult process, just search how to do it. When choosing what to put as your Initial/Maximum, I tried the 1.5x/3x rule the internet tells you but that didn’t do anything so I ended up putting 30MB/70MB with a 16GB RAM, which eventually worked. However, you have to be ready for your laptop to crash a couple times, so you’ll have to tweak with the coarseness of the mesh as well but basically you just have to give the app time to load, even if it says (Not Responding), just wait until it either loads or crashes the entire laptop, and then start again (so make sure to save all your files before doing this!). Also make sure to reset it once done because it affects all your other processes and slows your computer down a bunch.
From here, use the meshio in the python console to convert it to an .inp file which will instantly save it to wherever you tell it to. Here’s the code I wrote exactly to copy into the console:
import meshio
mesh = meshio.read(r"C:\\path\\to\\file.vtk")
meshio.write(r"C:\\path\\to\\file.inp")
I don’t know if I’ll be able to respond to any questions but please put any replies if you want, probably to Mr.Lasso instead as he’s the expert.
Good Luck and hope this is helpful ![]()
Thanks for sharing your experience, this is very useful.
Just a small explanation for this:
make sure to uncheck the “Compress” box to make sure it saves as a volume.
Compression does not affect what is saved, only how it is saved. Compression makes the file smaller, but some simpler VTK reader implementations can only read the uncompressed format.