Page 1 of 1
Post-Processing Advice
Posted: Mon Mar 15, 2021 10:57 am
by cjbright
Hi guys,
I hope you're all keeping well.
Sorry for a short and fairly open post, but I was wondering if anyone's experienced in post-processing their results who could give me a hand.
I've ran a 3D simulation, but I'd like to record information from the centrelines of the model so I can plot pressure/flow along the length of each vessel.
I've been struggling to do this in Paraview, has anybody got any advice or places I could look to for help?
Thanks,
Charlie
Re: Post-Processing Advice
Posted: Tue Mar 16, 2021 5:26 pm
by davep
Hi Charlie,
One way to do what you want is to extract centerlines from your model and use them to sample your simulation results. You can use the SV Python API to extract centerlines from a surface (.vtp file) and then break up the centerlines into distinct branches. The
centerlines.py and
extract-brances.py scripts in
https://github.com/SimVascular/SimVascu ... tests/vmtk are used to do this.
This is how I used the scripts for the Demo project model
Execute the
centerlines.py script to create the
centerlines-result.vtp file
Executing the
extract-branches.py script reads in the
centerlines-result.vtp file and writes out a .vtp file for each branch in the model: branch_0.vtp, branch_1.vtp and branch_2.vtp.
The .vtp files can then be read in to ParaView to sample your simulation results (see
https://public.kitware.com/pipermail/pa ... 38277.html).
Cheers,
Dave
Re: Post-Processing Advice
Posted: Wed Mar 17, 2021 12:01 pm
by cjbright
Hi Dave,
That looks like it's exactly what I want!
Thank you for drafting up the instructions and especially for finding a relevant Paraview post for me.
I'm a little inexperienced using Python & the new API. I've read through the documentation but I'm still a little confused, would you mind helping me?
Firstly I converted my Parasolid model to a PolyData model so it works with the Python scripts.
Then am I supposed to import 'centerlines.py' into the API's text editor and run it?
On both Ubuntu-18 and Win-10 I get the following error when doing so:
" File "<string>", line 9, in <module>
ImportError: No module named 'graphics' "
I can get rid of this error pasting the contents of 'graphics.py' into 'centrelines.py' as a brute work-around, but then I'm not sure where to go from there.
Otherwise, am I supposed to use the Python console within SV with the input:
>>> centerlines = sv.vmtk.centerlines(model, source_ids, target_ids, use_face_ids=True) ?
Replacing 'model', 'source_ids', etc. with values. e.g.
>>> centerlines = sv.vmtk.centerlines('Healthy_Model_PolyData',[1],[2],use_face_ids=True)
Using that line of code I also get an error:
"Traceback (most recent call last):
File "<string>", line 1, in <module>
vmtk.Error: Vmtk.centerlines() The polydata argument is not a vtkPolyData object."
Any help on where I'm going wrong would be much appreciated,
Charlie
Re: Post-Processing Advice
Posted: Thu Mar 18, 2021 12:57 pm
by davep
Hi Charlie,
The scripts should be run from the command line (see
http://simvascular.github.io/docsPython ... thon_shell). The
graphics module is local to the
SimVascular-Tests/new-api-tests so it won't work in the SV GUI. You don't need graphics to run the scripts.
On Ubuntu you would run the
centerlines.py script using
Code: Select all
/usr/local/sv/simvascular/DATE/simvascular/2021.02.06/simvascular --python -- centerlines.py
Cheers,
Dave
Re: Post-Processing Advice
Posted: Thu Mar 25, 2021 1:48 am
by cjbright
Hi Dave,
I went back and had another crack at it and it worked great!
A few tips for anyone new to the post:
- Make sure you export your solid model to get the .vtp - it didn't seem to work with the .vtp from the model folder.
- Open the .mdl file in a text editor to find the face ids for the caps of your model to put into the script.
- To anyone who isn't confident with python: 1) Git clone the 'new-api-tests' repo. 2) Place your .vtp into the /data/ directory. 3) Navigate the terminal to the /vmtk/ directory and alter the .py to read your file specific name/faceids. 4) Run the command as from the post above.
Thanks again,
Charlie
Re: Post-Processing Advice
Posted: Thu Mar 25, 2021 10:51 am
by davep
Hi Charlie,
Glad things are working and thanks for posting your tips!
You mentioned that the centerlines.py script didn't seem to work with the .vtp from the model folder. I tested on MacOS and Ubuntu and it does produce the correct results, it does not work on Windows, paths need to be set in a more complex manner, I haven't fixed all of the scripts yet.
Cheers,
Dave