lowe-lab-ucl / arboretum

Track and lineage visualization with btrack and Napari :evergreen_tree:
MIT License
45 stars 11 forks source link

Crash on single state tracking #2

Closed zachfox closed 3 years ago

zachfox commented 4 years ago

This tool seems great so far. I was able to install and run the test, and moved on to trying with some other data. There is only one "state" to the system, so I rewrote the config.json as:

{
  "TrackerConfig":
    {
      "MotionModel":
        {
          "name": "cell_motion",
          "dt": 1.0,
          "measurements": 1,
          "states": 1,
          "accuracy": 7.5,
          "prob_not_assign": 0.001,
          "max_lost": 5,
          "A": {
            "matrix": [1]
          },
          "H": {
            "matrix": [1]
          },
          "P": {
            "sigma": 150.0,
            "matrix": [0.1]
          },
          "G": {
            "sigma": 15.0,
            "matrix": [0.5]

          },
          "R": {
            "sigma": 5.0,
            "matrix": [1]
          }
        },
      "ObjectModel":
        {},
      "HypothesisModel":
        {
          "name": "cell_hypothesis",
          "hypotheses": ["alive"],
          "lambda_time": 5.0,
          "lambda_dist": 3.0,
          "lambda_link": 10.0,
          "lambda_branch": 50.0,
          "eta": 1e-10,
          "theta_dist": 20.0,
          "theta_time": 5.0,
          "dist_thresh": 40,
          "time_thresh": 2,
          "apop_thresh": 5,
          "segmentation_miss_rate": 0.1,
          "apoptosis_rate": 0.001,
          "relax": true
        }
    }
}

These settings cause python to crash, and the error is:

Instantiating BTRACK interface wrapper (v0.3.10, compiled Jun 17 2020 at 09:14:42)
[INFO][2020/07/20 10:46:24 PM] btrack (v0.3.10) library imported
[INFO][2020/07/20 10:46:24 PM] Starting BayesianTracker session
[INFO][2020/07/20 10:46:24 PM] Loading motion model: b'cell_motion'
[INFO][2020/07/20 10:46:24 PM] Set volume to ((0, 235), (0, 257), (-100000.0, 100000.0))
[INFO][2020/07/20 10:46:24 PM] Setting Bayesian update method to: BayesianUpdates.EXACT
[INFO][2020/07/20 10:46:24 PM] Starting tracking...
Assertion failed: (startRow >= 0 && blockRows >= 0 && startRow <= xpr.rows() - blockRows && startCol >= 0 && blockCols >= 0 && startCol <= xpr.cols() - blockCols), function Block, file ./btrack/include/eigen/Eigen/src/Core/Block.h, line 147.

I may have settings in the config which don't totally make sense, as I'm not sure what some of them refer to.

It seems to be an issue in Eigen when the Kalman matrices are one by one? maybe?

I'm not sure if this holds if I try in btracker directly.

I'm running MacOS 10.14

quantumjot commented 4 years ago

Great to hear that you're trying things out! Regarding the crash, it's almost certainly the config file that you've created. Can you explain a little more what you're trying to achieve? Is it 2d+t object tracking? Does the default config work at all?

zachfox commented 4 years ago

I tried with the default and I also get a crash. You're right it's 2D + t. When I try with the default config, it btrack works as far as I can tell, there are messages indicating objects were tracked until reading the btrack data from napari:

My images are a series of binary masks of cells.

Deleting BTRACK interface wrapper
Traceback (most recent call last):
  File "/Users/zachfox/sandbox/arboretum/arboretum/core.py", line 132, in add_track_layer
    properties=manager.properties,
  File "/Users/zachfox/sandbox/arboretum/arboretum/manager.py", line 89, in properties
    'generation': t.generation} for t in self.tracks]
  File "/Users/zachfox/sandbox/arboretum/arboretum/manager.py", line 89, in <listcomp>
    'generation': t.generation} for t in self.tracks]
  File "/anaconda/envs/tf_cpu/lib/python3.6/site-packages/btrack/btypes.py", line 355, in state
    return [o.state.value for o in self._data]
  File "/anaconda/envs/tf_cpu/lib/python3.6/site-packages/btrack/btypes.py", line 355, in <listcomp>
    return [o.state.value for o in self._data]
  File "/anaconda/envs/tf_cpu/lib/python3.6/site-packages/btrack/btypes.py", line 76, in state
    return constants.States(self.label)
  File "/anaconda/envs/tf_cpu/lib/python3.6/enum.py", line 293, in __call__
    return cls.__new__(cls, value)
  File "/anaconda/envs/tf_cpu/lib/python3.6/enum.py", line 535, in __new__
    return cls._missing_(value)
  File "/anaconda/envs/tf_cpu/lib/python3.6/enum.py", line 548, in _missing_
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 254 is not a valid States
quantumjot commented 4 years ago

ok! well that's easy to fix - the problem is that the current default behavior is that the pixel values in the images are interpreted as different cell states. so if you have only 1 state - you values should be 0-background and 1-cell. it seems like some of your pixel values are 254 - which it doesn't know how to interpret. how did you do the segmentation?

zachfox commented 4 years ago

Ah ok great I see, thanks! The segmentation is coming from another pipeline which uses U-net on fluorescence images of bacteria. After making them 1's instead of 255's, it tracks the cells without crashing. I think the tracking looks ok, but I should try to play with the config file a bit. My goal is to track the cells and construct a lineage tree if possible.

quantumjot commented 4 years ago

sounds great - let me know how you get on. @KristinaUlicna is updating the wiki for more detailed descriptions of the config files.

zachfox commented 4 years ago

Will do, thanks fpr your help!