hdmf-dev / hdmf

The Hierarchical Data Modeling Framework
http://hdmf.readthedocs.io
Other
47 stars 26 forks source link

Improve access of DynamicTable and DynamicTableRegion subset IDs #656

Open rly opened 3 years ago

rly commented 3 years ago

Given a DynamicTableRegion, e.g., ElectricalSeries.electrodes, to access the IDs of the subset of the table, one needs to do:

electrode_table_indices = eseries.electrodes.data[:]
selected_elect_ids = eseries.electrodes.table.id[electrode_table_indices]

Or

selected_elect_ids = list(eseries.electrodes.to_dataframe().index)

It would be a nicer user interface to allow:

eseries.electrodes['id'][:]
# or
eseries.electrodes[:, 'id']
# or even
eseries.electrodes.id[:]

Also, given a DynamicTable, e.g., NWBFile.electrodes, to access the IDs of the table, one needs to do:

nwbfile.electrodes.id[:]
nwbfile.electrodes['id'][:]

but

nwbfile.electrodes[:, 'id']

does not work, a main inconsistency with how users access data from a column.

Checklist

mavaylon1 commented 6 months ago

@stephprince A good start in digging into DynamicTableRegion