RatInABox icon indicating copy to clipboard operation
RatInABox copied to clipboard

RatInABox data saving

Open TomGeorge1234 opened this issue 1 year ago • 8 comments

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.

TomGeorge1234 avatar Dec 17 '24 15:12 TomGeorge1234

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.

niksirbi avatar Dec 17 '24 16:12 niksirbi

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?

TomGeorge1234 avatar Jan 15 '25 16:01 TomGeorge1234

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.

niksirbi avatar Jan 15 '25 17:01 niksirbi

Awesome! Keep in touch!

TomGeorge1234 avatar Jan 17 '25 04:01 TomGeorge1234

@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.

TomGeorge1234 avatar Feb 06 '25 22:02 TomGeorge1234

Sounds good @TomGeorge1234, I will chat about this with @mehulrastogi next week!

niksirbi avatar Feb 07 '25 10:02 niksirbi

@mehulrastogi any movement on this? (pun intended)

TomGeorge1234 avatar Jun 04 '25 15:06 TomGeorge1234

@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.

mehulrastogi avatar Jun 16 '25 12:06 mehulrastogi