RatInABox data saving
We should provide a standardised way to export RiaB data (times, trajectories and cell data). This follows on from a conversation I had with @niksirbi and @sfmig about integrating some functionality from RiaB into movement and vica versa.
The two ways this could be done are either each cell/agent has its own .save_history() function. Or else a single utils function could take all active agents / cells and save all data together into one file.
Option would be to then have a .load_history() function.
I'm cross-linking this to other relevant issues/discussions for cross-reference:
- https://github.com/neuroinformatics-unit/movement/issues/341
- https://github.com/freemocap/freemocap/issues/653
We, in the movement project, are also in the process of figuring out export formats and the above threads have contain some relevant points.
Probably the most low-effort file format for exchanging trajectories between movement and RatInABox would be a tabular .csv file in a "tidy"/"tall" format. A contrived example follows:
| time | agent_id | x | y |
|---|---|---|---|
| 0 | Alice | 35 | 22 |
| 0 | Bob | 100 | 120 |
| 1 | Alice | 37 | 25 |
| 1 | Bob | 102 | 121 |
Other columns can be added as needed, as long as we stick to the principle of "one variable - one column", and the valid column names are documented somewhere.
The advantage of csv is that it's simple, cross-language, and wouldn't necessitate adding any new dependencies to RatInABox. csv files can be written with native Python libraries - see example here.
Hi @niksirbi I'm aware I haven't made progress on this. I'm very sorry! I have been (and probably will continue to be) a bit busy for the next month or so...is this currently bottlenecking you?
Thanks for checking in, Tom. Don't worry about it at all, we haven't worked on it either and it's definitely not a bottleneck for us. It's more of a nice-to-have.
I can ping you when we get to this from our side, but there is definitely no urgency.
Awesome! Keep in touch!
@niksirbi I spoke to @mehulrastogi and he kindly offered to take this on. Given you're both in London perhaps you should chat and align on whats required (not much!). Sorry to palm this off but thank you both for time/patience :))
Also, still excited for the Riab <--> Movement demos so we shouldn't forget about that too.
Sounds good @TomGeorge1234, I will chat about this with @mehulrastogi next week!
@mehulrastogi any movement on this? (pun intended)
@TomGeorge1234 thanks for the reminder the new PR should take care of most use cases but I am testing for edge cases. Namely testing import/export robustly (type checking). There seems to be an issue to export after importing.