NeurodataWithoutBorders / matnwb

A Matlab interface for reading and writing NWB files
BSD 2-Clause "Simplified" License
50 stars 32 forks source link

MATLAB table -> NWB DynamicTable converter #98

Closed bendichter closed 3 years ago

bendichter commented 5 years ago

We have a function util.table2nwb that takes in a MATLAB table and outputs an matnwb DynamicTable that can be directly added to an NWBFile object. This is a start, but is not fully functional enough to be used for all common table needs, like writing the units table. Here is a list of features that are needed:

How to do each of these is demonstrated here:

https://github.com/NeurodataWithoutBorders/matnwb/blob/fa4f8bdbd6f22cadca6f2d24901309d623a10947/tutorials/ecephys.m#L143-L225

lawrence-mbf commented 5 years ago

Do we eventually want this to be integrated into read/write?

bendichter commented 5 years ago

I was imagining a one-line convert command before write, but I think integrating it in directly could be nice too. What would that look like?

lawrence-mbf commented 5 years ago

There used to be a way to manually extend matNWB classes. I don't think that's around anymore but you would essentially make a subclass to DynamicTable as a container for the converted table, and have it run util.table2nwb() right before exporting normally. That might be farther down the line though.

bendichter commented 5 years ago

OK, sounds good. I like the idea of having the ability to extend matNWB classes. Having to_table() as a method, for instance, would be really nice.

lawrence-mbf commented 3 years ago

One of the inputs of the DynamicTable GetRow/AddRow #267 supports tables as well. In fact, adding a full table to an DynamicTable will convert the table to its equivalent DynamicTable type. Indexing is also supported here.