quantumjot / btrack

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

Config JSON matrices format #272

Open KristinaUlicna opened 2 years ago

KristinaUlicna commented 2 years ago

When I export the configuration into the json file using the Save configuration button, the motion model matrices are not written out in the 2D matrix form, but in number-per-line format (see picture below). Their values are 100% correct, but it's visually difficult to check the matrix for symmetry & see its diagonal values. Could we re-format this?

Screenshot 2022-06-24 at 16 17 16
p-j-smith commented 1 year ago

This is to do with how json files are written in general. If you write a config file using BayesianTracker directly rather than through the gui:

import btrack
from btrack import datasets

config_file = btrack.datasets.cell_config()
config = btrack.config.load_config(config_file)
btrack.config.save_config('test_config.json', config)

you'll get the same result. Maybe there's a library we can use to format the json nicely, or perhaps it's possible by writing a custom json encoder to pass to pydantic, but I'm not sure.

Should we move this issue to the main BayesianTracker repo?

paddyroddy commented 1 year ago

Alternatively, could we store these "matrices" as matrices, i.e. 2D lists?

p-j-smith commented 1 year ago

we could but there would still be only one element per line not one sub-list per line, so it would be the same looking file just with more square brackets and indentation. We'd still need to write a custom encoder to write it nicely.

Plus changing the way the config files are written might break things for a lot of people, unless we support reading both the current format and a new format with 2d lists

paddyroddy commented 1 year ago

Agreed it would be a drastic change but I personally don't think it is worth the effort if we keep them as 1D lists.