quantumjot / btrack

Bayesian multi-object tracking
https://btrack.readthedocs.io
MIT License
311 stars 50 forks source link

Example to add additional parameters for the inference #182

Open Micro-Sandworms opened 1 year ago

Micro-Sandworms commented 1 year ago

Hi,

This software has great potential, but its usage remains a bit obscure to me, sorry. I am facing the following problem: I am tracking segmented neurons from a C. elegans brain. I have a series of properties that I would like to exploit to improve the tracking. For instance, I have the segmented volume (number of voxels) or the fluorescent signal from neurons at each time point. How can I exploit these? Also, the animal is moving in time, and not at a constant velocity. How can I adapt the motion model accordingly? It would be fantastic, if we could have two more examples to refine our models.

Many thanks

quantumjot commented 1 year ago

Hi @Micro-Sandworms,

There are some examples of using features (object properties) in the examples folder - you can try adding the segmented volume as a feature. Some details of the motion model specification is found in the readthedocs and guide page.

In general, I agree - we could have more documentation! Can you explain a bit more about what you're trying to achieve?

Micro-Sandworms commented 1 year ago

Hi Alan,

Thank you for taking the time to reply to me. For instance, I have a set of values: x, y, z, t, number_voxels, intensity the intensity and voxels parameters have errors and might drift in time. In a manner of speaking, this is like tracking a particle with two additional dimensions. If I read your docs correctly, I could use the tracker features for this: tracker.features = ['voxels', 'intensity'] Please confirm whether this is the expected usage of btrack...

It is, however, unclear if these properties have to be constant, and how the program weights their associated probability. or I could tell the model that I have 2 additional measurements (x, y, z, number_voxels, intensity) and 10 states: (x, y, z, voxels, intensity, dx, dy, dz, dvoxels, dintensity). Presumably, the corresponding matrices in the model should look like this:

      "measurements": 5,
      "states": 10,
      "accuracy": 7.5,
      "prob_not_assign": 0.01,
      "max_lost": 10,
      "A": {
        "matrix": [1,0,0,0,0,1,0,0,0,0,
                   0,1,0,0,0,0,1,0,0,0,
                   0,0,1,0,0,0,0,1,0,0,
                   0,0,0,1,0,0,0,0,1,0,
                   0,0,0,0,1,0,0,0,0,1,
                   0,0,0,0,0,1,0,0,0,0,
                   0,0,0,0,0,0,1,0,0,0,
                   0,0,0,0,0,0,0,1,0,0,
                   0,0,0,0,0,0,0,0,1,0,
                   0,0,0,0,0,0,0,0,0,1]
      },
      "H": {
        "matrix": [1,0,0,0,0,0,0,0,0,0,
                   0,1,0,0,0,0,0,0,0,0,
                   0,0,1,0,0,0,0,0,0,0,
                   0,0,0,1,0,0,0,0,0,0,
                   0,0,0,0,1,0,0,0,0,0]
      },
      "P": {
        "sigma": 150.0,
        "matrix": [0.1,0,0,0,0,0,0,0,0,0,
                   0,0.1,0,0,0,0,0,0,0,0,
                   0,0,0.1,0,0,0,0,0,0,0,
                   0,0,0,0.1,0,0,0,0,0,0,
                   0,0,0,0,0.1,0,0,0,0,0,
                   0,0,0,0,0,1,0,0,0,0,
                   0,0,0,0,0,0,1,0,0,0,
                   0,0,0,0,0,0,0,1,0,0,
                   0,0,0,0,0,0,0,0,1,0,
                   0,0,0,0,0,0,0,0,0,1]
      },
      "G": {
        "sigma": 15.0,
        "matrix": [0.75,0.5,0.5,1,1,1,1,1,1,1]

      },
      "R": {
        "sigma": 5.0,
        "matrix": [1,0,0,0,0,
                   0,1,0,0,0,
                   0,0,1,0,0,
                   0,0,0,1,0,
                   0,0,0,0,1]

Using such a model will generate an error in one of the internal C++ libraries that the package calls. Some matrix not having the correct number of rows. If important, I can run the code again and give you the specific message.

The second question that I had is that the motion model that is already implemented in the software seems to be a constant velocity. I have read the documentation several times, and I am sorry, but I still do not see how to implement a scenario where the velocity is not constant. Should I include then 3 measurements (x,y,z) and 9 states corresponding to (x, y, z, dx, dy, dz, d2x, d2y, d2z)?

Again, many thanks