nipy / mindboggle

Automated anatomical brain label/shape analysis software (+ website)
http://mindboggle.info
Other
145 stars 54 forks source link

Decimating surface mesh patches #24

Closed binarybottle closed 11 years ago

binarybottle commented 11 years ago

To speed up the Zernike moments (and perhaps other) calculations, we need simpler surface mesh patches than the thousands of nodes in our label and sulcus meshes. One way is to decimate the meshes (without resorting to random deletion of vertices). Smoothing seems like a reasonable option. Is there Apache, BSD, or MIT-licensed code we could use, or how might we best implement this?

satra commented 11 years ago

Q. why do we need simpler mesh patches? what is the time delta we are looking at?

re: decimation, just use vtk's decimate function.

binarybottle commented 11 years ago

even with brian's optimization of the zernike code, it might still turn out to be the longest part of mindboggle to run, which is too much to ask for a single shape measure, so i would like to reduce the computational burden by simplifying the meshes fed into the zernike code.

do you know how to access the vtk decimate function with python?

satra commented 11 years ago

http://nullege.com/codes/search/vtk.vtkDecimatePro

binarybottle commented 11 years ago

Thank you!

I have coded up a function that will decimate our meshes. below is an example of label 22 (postcentral) with 0.1 and 0.9 reduction in faces: screen shot 2013-07-14 at 3 20 10 am

binarybottle commented 11 years ago

Added smoothing with vtk.vtkSmoothPolyDataFilter() Below: 0.5 decimation without and with smoothing (100 iterations):

screen shot 2013-07-14 at 3 47 26 am

binarybottle commented 11 years ago

decimate_file() works well, but i can't figure out how to output points and faces rather than a file. could you please take a look at https://github.com/binarybottle/mindboggle/blob/master/mindboggle/utils/mesh.py#L654 and tell me what i'm doing wrong?

satra commented 11 years ago

is there an error message? the only thing i can see is the indexing for the face indices is off.

for j in range(i*3, i*3 + 3)
binarybottle commented 11 years ago

no error message, but output.GetNumberOfPoints() gives 0L, so even before indexing the faces or points, the output appears to be empty.

you are right about the indexing -- in io_vtk.py's read_vtk(), it is:

if output.GetNumberOfPolys() > 0: .... faces = [[int(output.GetPolys().GetData().GetValue(j)) ........ for j in range(i_4 + 1, i_4 + 4)] ........ for i in range(output.GetPolys().GetNumberOfCells())] else: .... faces = []