def get_sequence_index(self, data, target): return VectorIndex('sequence_index', data, target)
# the :py:class:`~hdmf.common.table.VectorIndex` and its target # :py:class:`~hdmf.common.table.VectorData` in for the ``columns`` # argument in the constructor. For instance, the following code creates a column # called ``col1`` where the first cell is ['1a', '1b', '1c'] and the second cell # is ['2a']. col1 = VectorData( name='col1', description='column #1', data=['1a', '1b', '1c', '2a'], ) # the 3 signifies that elements 0 to 3 (exclusive) of the target column belong to the first row # the 4 signifies that elements 3 to 4 (exclusive) of the target column belong to the second row col1_ind = VectorIndex( name='col1_index', target=col1, data=[3, 4], ) table_ragged_col = DynamicTable( name='my table', description='an example table', columns=[col1, col1_ind], ) #################################################################################### # .. note:: # By convention, the name of the :py:class:`~hdmf.common.table.VectorIndex` should be # the name of the target column with the added suffix "_index". ####################################################################################
def get_sequence_index(self, index, data): return VectorIndex('sequence_index', index, data)
# ^^^^^^^^^^^^^^^^^^^^ # A table column with a different number of elements for each row is called a # ragged array. To initialize a :py:class:`~hdmf.common.table.DynamicTable` # with a ragged array column, pass both # the :py:class:`~hdmf.common.table.VectorIndex` and its target # :py:class:`~hdmf.common.table.VectorData` object in for the ``columns`` # argument in the constructor. col1 = VectorData( name='col1', description='column #1', data=['1a', '1b', '1c', '2a'], ) col1_ind = VectorIndex( name='col1_index', target=col1, data=[3, 4], ) table_ragged_col = DynamicTable( name='my table', description='an example table', columns=[col1, col1_ind], ) ############################################################################### # You can add a ragged array column to an existing # :py:class:`~hdmf.common.table.DynamicTable` by specifying ``index=True`` # to :py:meth:`DynamicTable.add_column <hdmf.common.table.DynamicTable.add_column>`. new_table = DynamicTable(