0x9dedbaf9
0x9dedbaf9

Reputation: 121

Is there a way to manipulate an STL's data points in Python? (Medical application)

Newbie programmer trying to apply programming to medical research. I'm conducting a biomechanical simulation using Python and STL (3D format) files made from patients' CT scans. I'm trying to rotate one bone region about an arbitrary axis to simulate joint motion and measuring the (change in) distance between ligament insertion points, but coming at a loss with how to do this. I can import data from an STL file into a point cloud, and do basic operations there, but I have no idea how to reconstruct the STL. Is there a way treat STL data as a structure and conduct geometric transformations directly? Based off of the new locations, I'm calculating an effective ligament length (basically the distance between one point to another point in the bone region of interest). Based off of these values, I'm trying to "colorize" the STL and make a 3D "heat map," basically higher values are red, lower blue, etc. I can't really get Mayavi to work, and I would keep the point cloud, but it's terribly slow to plot and manipulate in Python. Thanks for the help!

TL; DR below:

Upvotes: 2

Views: 1987

Answers (1)

loopbackbee
loopbackbee

Reputation: 23322

There are many subtasks involved in this process. You'll have to group the points that belong to each body part, define rotation points and measurement points.

In my opinion, none of these operations are well-suited to be performed through programming (in python or otherwise), since they involve lots of user interaction. You may want to learn how to perform these operations in a 3D editor.

Blender is free, can import STL, and although the learning curve is a bit steep, there are lots of learning materials online. You'll want to look into vertex groups, rigging, and measuring distances.

Once you have the basic model set up, you can easily make programmatic changes to it, thanks to blender's extensive python API. With it, you'll be able to automate testing, and graphically inspect the results when needed.

Be aware that many of the documentation available still concerns blender version series 2.4, while the most recent is 2.6 . You may want to try both.

Upvotes: 1

Related Questions