glotzerlab / freud

Powerful, efficient particle trajectory analysis in scientific Python.
https://freud.readthedocs.io
BSD 3-Clause "New" or "Revised" License
280 stars 49 forks source link

Segmentation containment hierarchy #1253

Open BartBruininks opened 5 months ago

BartBruininks commented 5 months ago

Description

When working with point clouds or voxel densities, it is often useful to ask for the content of a component. However, the definition of inside is not trivial in periodic space. Nevertheless, having access to the output of a connected components segmentation in a directed acyclic graph can be extremely useful and indeed is possible (think of it as the folder structure of the simulation box).

Proposed Solution

I have been working on a mathematical robust classification for this problem in ND-(periodic) space. This works for any density structure in a (periodic) box, even if the densities are periodic themselves.

The implementation has been done and is on its way to being published, however, my own implementation in python is rather slow. I tried to make a version which uses Freud which works reasonably well, but I feel like a proper implementation could be a real boon for Freud.

I would love to give a (open) presentation for the developers and fellow freudians, to present my work and how I think it could be valuable to Freud --- an hour should be fine.

Additional Context

An example of what I mean is given in my Github. The implementation of the math is cheating a bit in its current implementation, but the results for the examples are all correct (I am currently reworking the code to adhere to the new mathematical machinery used to tackle the problem).

An example of a solvent phase (-2) whith multiple lipid components (1--4) in it. One of the lipid components (3) has a solvent component (-1) in its interiour as represented by the graph (the arrows point from container -->containee).

258806872-be5fff63-a967-47c2-a933-a3ecb7dcd5de

Developer

Would someone else please implement this?

tommy-waltmann commented 5 months ago

Hi @BartBruininks ,

Please link the paper corresponding to this analysis method once its either published or on ArXiV. I would like to understand this a bit better before deciding on whether to accept a PR for it. For now, I have some questions about the analysis method, maybe you can answer them:

1) Does this analysis method require volumetric data? Freud is designed to analyze systems described by points in space.

2) If the system to analyze can be described by points in space, could the same analysis be done by using freud.cluster.Cluster recursively?

Lastly, the implementation seems nontrivial, so be aware that you will probably need to implement this into freud yourself if we decide to accept a PR. The freud maintainers are graduate students who have our own science projects to work on, and without the research need from one of us, the work will need to be done by someone else.

BartBruininks commented 5 months ago

Hi @tommy-waltmann,

Once I have the paper done I will link it. Regarding your questions.

  1. The analysis is perfomed on volumetric graphs, which are nothing else then point clouds with annotated neighbors. However, it makes sense to convert this to voxels, which can be generated in Freud using your density module (this is not required but a nice speedup at the cost of memory).
  2. Yes it could (to create the graph), however, to orient the graph you need a cluster property which is currently not supported by Freud (if I am correct), which is the percolation rank of the components (clusters). This would be the main feature which could become a standard feature in Freud and seems to align well with the other features of Freud. An example algorithm to do so is given here (https://pubs.acs.org/doi/10.1021/acs.jctc.1c00423).

For now I do not want you to implement it for me, but I had to choose in the comment. My main goal at first would be to have a zoom presentation or something like that with the people in your team and give a presentation on the topic. I am sure people in you team will have all kinds of questions and ideas of what it can be used for. I do not mind working on the implementation if we decide it is worth it (or collaborate). As it is not yet published we could even add more contributors on the manuscript.

I just have a strong feeling you will like this.

Cheers,

Bart