BlueBrain / Ultraliser

Reconstruction of watertight meshes, annotated volumes and center line skeletons of neuroscience spatial structures from non-watertight inputs, segmented masks, skeletons of NGV morphologies and volumes.
https://portal.bluebrain.epfl.ch
GNU General Public License v3.0
26 stars 5 forks source link

Inquiries about Vessel Graph format for ultraVessMorpho2Mesh #65

Open Whan9811 opened 1 year ago

Whan9811 commented 1 year ago

Hi,

Thanks for the amazing work. I am trying to build mesh out of vessel skeletons. I have been reading the wiki page to prepare the input from numpy arrays,

https://github.com/BlueBrain/Ultraliser/wiki/Examples-ultraVessMorpho2Mesh

I noticed that there is only a link to .SWC format. Could you please also explain how I can prepare VMV and H5 formats?

Also, for the SWC format, what should the Structure Identifier be if I am not working with neuro data?

Besides, I also notice that all the examples in the ultraVessMorpho2Mesh page are using the command ultraAstroMorpho2Mesh instead. Is this a typo or what is intended?

Thanks a lot in adavance!

Best regards,

Wesley

marwan-abdellah commented 1 year ago

@Whan9811 Thanks for the nice words.

I would recommend you to encode your data in VMV (VessMorphoVis) format. It is very easy compared to the H5 format. A detailed guide to do it can be found here: https://github.com/BlueBrain/VessMorphoVis/wiki/File-Formats. Let me know if you need any help.

To ensure that you have done it right, you can visualize the VMV file in VessMorphoVis. Regards, Marwan

Whan9811 commented 1 year ago

Thank you so much for the clarification! It works! However, I am having some problems at the junctions where they are disconnected to some extent. It happens near the root of the tree where the radius is large, so I guess it is not about resolution issues? Would you be able to recommend any arguments to play with that might solve this problem? Thanks a lot in advance!

Screenshot 2023-09-15 at 13 39 48
marwan-abdellah commented 1 year ago

@Whan9811 Don't use VessMorphoVis to make a mesh. Use Ultraliser. If you can send me the morphology, I can have a look and help you to make it.

Thanks

Whan9811 commented 1 year ago

Thanks a lot for the help! I am using the ultraVessMorpho2Mesh command though.

./ultraVessMorpho2Mesh --morphology morph.vmv --output-directory tt --export-obj-mesh --scaled-resolution --voxels-per-micron 0.3

Here is the data

https://drive.google.com/file/d/1SnIGbFl3V3rn5lQDsCzQhycXpB8H-LmZ/view?usp=sharing

Please note that the radius is in the unit micro-meter. The xyz coordinates also have an isotropic size of 1 micro-meter, meaning that the simple L2 distance between two nodes represents the real distance in micro-meter. Also, each branch is strictly a single cylinder, meaning that there is no curvature before they branch. This is why each section is always made up of a single segment. Maybe I need some interpolations in between, although they do not change directions.

Thanks!

marwan-abdellah commented 1 year ago

Just make sure that you use a more convenient packing algorithm. I have generated a smoothed version of your dataset, but watertightness is not guaranteed. Just use the following command:

$ ultraVessMorpho2Mesh --morphology /ssd3/pad-x/morph.vmv --output-directory /ssd3/pad-x/output --resolution 1000 --export-obj-mesh --project-xy --solid --packing-algorithm polylines-with-spheres

And please ensure the following is present --packing-algorithm polylines-with-spheres.

Dataset is here https://drive.google.com/drive/folders/1MHRmP7f97uKkiGhEgtNkp1Dqfx9cLDnR?usp=drive_link

Whan9811 commented 1 year ago

Thank you so much!

Whan9811 commented 1 year ago

Hi again, I have been trying to use larger resolutions, which will of course take more memory. However, the rasterization computation and dual marching cubes work fine, and it can output the raw obj mesh (the one with suffix -dmc.obj) without any problem. But the memory overflow comes actually in the smoothing stage, even with the iteration number set to 1. I am wondering if you have any advice on how to handle it? Or is the raw mesh just too large to be smoothed? The mesh has 4.7 GB in memory with around 100M cells and 60M nodes.

./ultraVessMorpho2Mesh --morphology morph.vmv --output-directory output --scaled-resolution --voxels-per-micron 0.2 --export-obj-mesh --solid --packing-algorithm polylines-with-spheres --laplacian-iterations 1 --smooth-iterations 1

Screenshot 2023-09-18 at 16 08 26

marwan-abdellah commented 1 year ago

@Whan9811 What is the memory limit of your machine?

Whan9811 commented 1 year ago

Actually 32 GB which I thought was large enough

marwan-abdellah commented 1 year ago

Your dataset is relatively complex, and have very small vessels. I will run some tests and see the optimum memory requirements.

Whan9811 commented 1 year ago

Thanks a lot for taking the time to look into this! Yes, it is very complex with very small vessels. it has around 50K vessels in total of which around 30K are terminal vessels with a radius around 10 micro-meters. The vessel skeleton itself is strictly a tree (Directed Acyclic Graph) without any loops, but with thickness, there actually might be some vessels intersecting each other. But I would really like to see how far we could get from this stage. Thanks again for looking into it!

marwan-abdellah commented 1 year ago

@Whan9811 If you are able to inform me in which context this dataset is used, I think I can recommend some optimization strategies.

Thanks,

Whan9811 commented 1 year ago

The final objective is to have volume meshes to do CFDs for blood flow simulation. I know it sounds extremely ambitious on such large-scale data, but some initial visualizations of smooth surface meshes would be interesting already.

Please do let me know if you need more context and your opinions on it!

Thanks a lot!

marwan-abdellah commented 1 year ago

@Whan9811 I have already done that before for several datasets. You can refer to the supplementary document Fig S83 , but indeed with a smaller scale. What I can try is to run it on a cluster node (>250GB Ram) and run the optimizer to ensure a watertight and optimized mesh. My question is: are you sure that the dataset is a single component, i.e no floating branches?

Whan9811 commented 1 year ago

Thanks! Yes, I am sure that the skeleton itself is a single connected tree structure. Although I understand that your approach can cope with cycles and does not need order information in the .VMV file, I do have this information, e.g., which is root and which are terminals/leaves in my original skeleton tree data. But as I wrote before, some of the vessels can easily intersect with each other when given real thickness (radii). I attached some examples visualized in ParaView with the Tube filter.

Actually, we also have a slurm-cluster but I have some problems installing the software there so I have just been sticking to my local Ubuntu machine. The problem is that, as a slurm user, it is not allowed to use sudo command, so I cannot install the dependencies using sudo apt-get install. Do you have recommendations for alternatives or do I have to contact my slurm admins?

image
marwan-abdellah commented 1 year ago

@Whan9811 I have created a volume mesh of your dataset at half the resolution. The one with the full resolution should take a bit more time. You will find an optimized STL mesh that you can directly use with GMsh or TetGen to create any specific volume mesh. The mesh is watertight and optimized. If I get the result of the other mesh soon, I will let you know. All the meshes are available here. Thanks,

Whan9811 commented 1 year ago

Thank you so much! They do look great already. I will run TetGen and see what we can get from here.