kalemaria / pycurv

Reliable estimation of membrane curvature for cryo-electron tomography
GNU Lesser General Public License v3.0
16 stars 6 forks source link

Consistent problem with Surface generation from membrane (noncompartment) segmentation #6

Closed bbarad closed 3 years ago

bbarad commented 3 years ago

Hi Maria,

I have been trying to set up pycurv to analyze some mitochondria which have complex cristae morphology, which makes compartment segmentation difficult to borderline impossible, so I am using the membrane surface generation tools packaged with pycurv. I am seeing a consistent error in surface generation with this tool, however, which I highlighted with pictures of the voxel segmentation and the resulting surface:

Screen Shot 2021-03-03 at 10 47 45 AM Screen Shot 2021-03-03 at 11 25 38 AM

This is just the outer membrane surface, but there is a consistent gap in the segmentation on both sides of the membrane where the membrane is most vertical (at the equator of the mitochondria). The following outer membrane segmentation (voxels) can reproduce the problem: https://www.dropbox.com/s/kguo79h7nyzxhr4/OMM_thick.mrc?dl=0. The gap doesn't align with the XY plane, since there is pretilt from the lamella which I didn't correct for in IMOD.

Do you have any advice for mitigating or correcting this error? Compartment segmentation is going to be near-impossible with this data, though I know it is probably the easiest solution!

Thanks, Ben Barad

bbarad commented 3 years ago

I am using the new_workflow to generate the surface, and masking against the OMM voxel segmentation itself to remove spurious surface bits!

kalemaria commented 3 years ago

Hi Ben,

I am not sure how the segmentation image with cristae relates to the surface above, as you say you have only the outer membrane segmentation? Anyway, have you already tried using the holes parameter in the new_workflow function? Setting it to 3 or 5 will close small holes of that size in voxels in the membrane segmentation, which can improve the surface extraction (without the compartment segmentation).

Best Ria

bbarad commented 3 years ago

Hi Ria, here is just the OMM from that segmentation - perhaps the consistent slice down the center is easier to see with this for comparison?

I am using hole=5 currently.

Screen Shot 2021-03-06 at 6 42 53 AM
kalemaria commented 3 years ago

Hi Ben, Thanks for the image, the segmentation looks nice. But which parts are missing in the extracted surface? Could you please attach an image of the surface of this part in the same orientation? Holes=5 should work fine. But this method does not work well for not closed surfaces in general, like membrane with a big missing wedge.

bbarad commented 3 years ago

The first surface and this voxel segmentation are at nearly the same orientation, so you can see that each side of the OMM is split in two approximately by large holes through the center. Here's a zoom in along the Y axis - I apologize, I haven't totally figured out the viewing controls in paraview so I don't have any clipping planes and you can see the other side of the OMM through the missing surface density, which may make the view noisier...

Screen Shot 2021-03-07 at 8 36 18 AM Screen Shot 2021-03-07 at 8 41 47 AM

I am going to try out a few other algorithms, but I am surprised to see this error in the most connected part of my open surface - I was expecting errors to occur more at the open edges, and I was OK with filtering those out!

kalemaria commented 3 years ago

Oh, I see the gaps now! :( Sorry, I misinterpreted the gaps in the first ParaView visualization: I thought it was a larger view with two pairs of opposite OMMs. Unfortunately, this surface extraction algorithm sometimes initialized the normal vectors in opposite directions, which leads to open edges and gaps after the masking with the segmentation. We could not figure out how to correct it, that's why we developed another surface extraction method using compartment segmentation. Sorry I could not help you further. Hope you can find a better solution without having to segment the lumen, which must be nearly impossible for mitochondria membranes.

bbarad commented 3 years ago

That is good to know - I am setting up to try power crust, which has an orientation fixing program, so maybe I will try this algorithm with skipping masking at first to see if I can repair the orientations that way before I mask.

bbarad commented 3 years ago

I think I may have found an effective algorithm - I am planning to generate the surface elsewhere and load it into pycurv for now. Do you recommend doing a uniform mesh resampling, or am I ok with some variation with triangle size and shape?

kalemaria commented 3 years ago

Hi Ben, You don't need to resample the mesh, the algorithm is robust to non-uniform triangles with different size and shape. Where do you generate the surface? Do you think it would be possible to integrate this algorithm into PyCurv? Thanks and best

bbarad commented 3 years ago

Currently making the surface in meshlab. I think it will be possible to get it working in python without too much difficulty! I am still trying to figure out the robustness for different segmentations before committing to this specific direction, but I'd love to have one of the outcomes being upstreaming to pycurv as part of us getting our manuscript out, if you are open to taking a pull request!

kalemaria commented 3 years ago

Sure, I would be glad to take a pull request! :) Thanks for using and contributing to pycurv and good luck with your manuscript!

bbarad commented 2 years ago

Hey Maria,

Sorry to take so very long to come back to this! I've got a working python workflow based on screened poisson reconstruction to generate beautiful surfaces that feed nicely into pycurv. We are putting together our manuscript now describing using that + pycurv and some home-made analysis and studying some stress-induced changes in mitochondrial ultrastructure. I'd like to try to integrate the surface reconstruction part into pycurv if you're interested - but before I prepare a pull request, wanted to check in with you. My workflow adds dependencies on pymeshlab and mrcfile (which may already be used by pyto? I haven't investigated closely) but both are easily pip-installable. It also currently deals w/ file type differences by serializing and then reading into different scripts to pass from MRC file to point cloud to ply surface to vtk surface, which is not ideal but does have the advantage of making troubleshooting easier!

I've attached a figure showing the new method vs the one built into pycurv with pycurv downstream! Ironically both methods come from H. Hoppe - mine is just from a more recent 2013 paper (Khazdan & Hoppe 2013) that is not built into VTK.

Thanks, Ben

Screen Shot 2021-11-02 at 10 05 19 AM
kalemaria commented 2 years ago

Hey Ben,

I was glad to hear about your progress, and sorry for taking me so long to reply.

The surfaces look really beautiful. :-) All the best for writing and publishing your manuscript! Sure, it would be cool if you could integrate the surface reconstruction part into pycurv, if it is not much work and if it would simplify the workflow for you. I am not supporting pycurv any more since starting my full-time job early this year, and don't even have a local installation, but I should be able to accept your pull request via GitHub. I think mrcfile was used by pyto, but maybe it was changed, as I don't see it in its setup.py, also no pymeshlab, but it should not be a problem to add both packages to pycurv's dependencies.

I must have missed out that Hoppe's paper. Did you implement the algorithm in python yourself?

Best and thanks Ria