Internal API — Python reimplementation of NIXIO (http://g-node.github.io/nix/) 1.5.3 Release documentation

# Internal API

## Subpackages

- nixio.cmd package
  - Submodules
  - nixio.cmd.validate module
  - Module contents
- nixio.exceptions package
  - Submodules
  - nixio.exceptions.exceptions module
  - Module contents
- nixio.hdf5 package
  - Submodules
  - nixio.hdf5.h5dataset module
  - nixio.hdf5.h5group module
  - Module contents
- nixio.test package
  - Subpackages
    - nixio.test.xcompat package
      - Submodules
      - nixio.test.xcompat.compile module
      - Module contents
  - Submodules
  - nixio.test.test_block module
  - nixio.test.test_compression module
  - nixio.test.test_container module
  - nixio.test.test_data_array module
  - nixio.test.test_data_frame module
  - nixio.test.test_data_view module
  - nixio.test.test_dimensions module
  - nixio.test.test_feature module
  - nixio.test.test_file module
  - nixio.test.test_group module
  - nixio.test.test_multi_tag module
  - nixio.test.test_nix_compatibility module
  - nixio.test.test_property module
  - nixio.test.test_section module
  - nixio.test.test_source module
  - nixio.test.test_tag module
  - nixio.test.test_util module
  - nixio.test.test_validator module
  - nixio.test.tmp module
  - Module contents
- nixio.util package
  - Submodules
  - nixio.util.find module
  - nixio.util.names module
  - nixio.util.units module
  - nixio.util.util module
  - Module contents

## Submodules

## nixio.block module

class nixio.block.Block(nixfile, nixparent, h5group, compression=<Compression.Auto: 'Auto'>)

  Bases: `nixio.entity.Entity`

  create_data_array(name='', array_type='', dtype=None, shape=None, data=None, compression=<Compression.Auto: 'Auto'>, copy_from=None, keep_copy_id=True, label=None, unit=None)

    Create/copy a new data array for this block. Either `shape` or `data` must be given. If both are given their shape must agree. If `dtype` is not specified it will default to 64-bit floating points.

    Parameters

      - name (str) – The name of the data array to create/copy.

      - array_type (str) – The type of the data array.

      - dtype (`numpy.dtype`) – Which data-type to use for storage

      - shape (tuple of int or long) – Layout (dimensionality and extent)

      - data (array-like data) – Data to write after storage has been created

      - compression (`Compression`) – En-/disable dataset compression.

      - copy_from (nixio.DataArray) – The DataArray to be copied, None in normal mode

      - keep_copy_id (bool) – Specify if the id should be copied in copy mode

      - label (str) – The label, defaults to None.

      - unit (str) – The unit of the stored data. Defaults to None.

    Returns

      The newly created data array.

    Return type

      `DataArray`

  create_data_frame(name='', type_='', col_dict=None, col_names=None, col_dtypes=None, data=None, compression=<Compression.No: 'None'>, copy_from=None, keep_copy_id=True)

    Create/copy a new data frame for this block. Either `col_dict` or `col_name` and `col_dtypes` must be given. If both are given, `col_dict` will be used.

    Parameters

      - name (str) – The name of the data frame to create/copy.

      - type (str) – The type of the data frame.

      - col_dict (dict or OrderedDict of {str: type}) – The dictionary that specifies column names and data type in each column

      - col_names (tuples or list or np.array of string) – The collection of name of all columns in order

      - col_dtypes (tuples or list or np.array of type) – The collection of data type of all columns in order

      - data (array-like data with compound data type as specified in the columns) – Data to write after storage has been created

      - compression (`Compression`) – En-/disable dataset compression.

      - copy_from (nixio.DataFrame) – The DataFrame to be copied, None in normal mode

      - keep_copy_id (bool) – Specify if the id should be copied in copy mode

    Returns

      The newly created data frame.

    Return type

      `DataFrame`

  create_group(name, type_)

    Create a new group on this block.

    Parameters

      - name (str) – The name of the group to create.

      - type (str) – The type of the group.

    Returns

      The newly created group.

    Return type

      nixio.Group

  create_multi_tag(name='', type_='', positions=None, extents=None, copy_from=None, keep_copy_id=True)

    Create/copy a new multi tag for this block.

    Parameters

      - name (str) – The name of the tag to create/copy.

      - type (str) – The type of tag.

      - positions (nixio.DataArray) – A data array defining all positions of the tag.

      - copy_from (nixio.MultiTag) – The MultiTag to be copied, None in normal mode

      - keep_copy_id (bool) – Specify if the id should be copied in copy mode

    Returns

      The newly created tag.

    Return type

      nixio.MultiTag

  classmethod create_new(nixparent, h5parent, name, type_, compression)
  create_source(name, type_)

    Create a new source on this block.

    Parameters

      - name (str) – The name of the source to create.

      - type (str) – The type of the source.

    Returns

      The newly created source.

    Return type

      nixio.Source

  create_tag(name='', type_='', position=0, copy_from=None, keep_copy_id=True)

    Create/copy a new tag for this block.

    Parameters

      - name (str) – The name of the tag to create/copy.

      - type (str) – The type of tag.

      - position – Coordinates of the start position in units of the respective data dimension.

      - copy_from (nixio.Tag) – The Tag to be copied, None in normal mode

      - keep_copy_id (bool) – Specify if the id should be copied in copy mode

    Returns

      The newly created tag.

    Return type

      nixio.Tag

  property data_arrays

    A property containing all data arrays of a block. DataArray entities can be obtained via their index or by their id. Data arrays can be deleted from the list. Adding a data array is done using the Blocks create_data_array method. This is a read only attribute.

  property data_frames
  find_sources(filtr=<function Block.<lambda>>, limit=None)

    Get all sources in this block recursively.

    This method traverses the tree of all sources in the block. The traversal is accomplished via breadth first and can be limited in depth. On each node or source a filter is applied. If the filter returns true the respective source will be added to the result list. By default a filter is used that accepts all sources.

    Parameters

      - filtr (function) – A filter function

      - limit (int) – The maximum depth of traversal

    Returns

      A list containing the matching sources.

    Return type

      list of nixio.Source

  property groups

    A property containing all groups of a block. Group entities can be obtained via their index or by their id. Groups can be deleted from the list. Adding a Group is done using the Blocks create_group method. This is a read only attribute.

  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  property multi_tags

    A property containing all multi tags of a block. MultiTag entities can be obtained via their index or by their id. Tags can be deleted from the list. Adding tags is done using the Blocks create_multi_tag method. This is a read only attribute.

  pprint(indent=2, max_length=120, extra=True, start_depth=0)

    Pretty Printing the Data and MetaData Tree of the whole File

    Parameters

      - indent (int) – The length of one indentation space

      - max_length (int) – Maximum length of each line of output

      - extra (bool) – True to print extra information of Entities

      - start_depth (int) – Starting depth of indentation

  property sources

    A property containing all sources of a block. Sources can be obtained via their index or by their id. Sources can be deleted from the list. Adding sources is done using the Blocks create_source method. This is a read only attribute.

  property tags

    A property containing all tags of a block. Tag entities can be obtained via their index or by their id. Tags can be deleted from the list. Adding tags is done using the Blocks create_tag method. This is a read only attribute.

## nixio.compression module

class nixio.compression.Compression(value)

  Bases: `enum.Enum`

  An enumeration.

  Auto = 'Auto'
  DeflateNormal = 'DeflateNormal'
  No = 'None'

## nixio.container module

class nixio.container.Container(name, nixfile, parent, itemclass)

  Bases: `object`

  Container acts as an interface to container groups in the backend. In the case of HDF5, this is a group that is used as a container for other groups.

  Examples of Containers:

    Block.data_arrays Block.tags Block.multi_tags Source.sources

  Parameters

    - name – Name of the container

    - parent – Parent NIX object where this container will be created

    - itemclass – The class of the objects this container holds (for

  checking and instantiations)

  items()

class nixio.container.LinkContainer(name, parent, itemclass, itemstore)

  Bases: `nixio.container.Container`

  A LinkContainer acts as an interface to container groups in the backend that hold links to objects already contained in a Container.

  Objects are added to a LinkContainer using the ‘append’ method, as opposed to Containers which get populated by the parent object ‘create’ methods.

  An important difference between a LinkContainer and a Container is that links to objects are indexed by their ‘id’ whereas objects in Containers are indexed by ‘name’.

  Examples of LinkContainers:

    Group.data_arrays Group.tags Group.multi_tags

  Parameters

    - name – Name of the container

    - parent – Parent H5Group where this container will be created

    - itemclass – The class of the objects this container holds (for checking and instantiations)

    - itemstore – The location (Container) where the original objects are stored and linked to.

  append(item)
  extend(items)

class nixio.container.SectionContainer(name, nixfile, parent, itemclass)

  Bases: `nixio.container.Container`

  SectionContainer extends Container with a new __delitem__ method. When a Section is deleted, all child sections need to be deleted individually to make sure all their references are removed.

class nixio.container.SourceContainer(name, nixfile, parent, itemclass)

  Bases: `nixio.container.Container`

  SourceContainer extends Container with a new __delitem__ method. When a Source is deleted, all child sources need to be deleted individually to make sure all their references are removed.

## nixio.data_array module

class nixio.data_array.DataArray(nixfile, nixparent, h5group)

  Bases: `nixio.entity.Entity`, `nixio.data_set.DataSet`

  append_range_dimension(ticks=None, label=None, unit=None)

    Append a new RangeDimension to the list of existing dimension descriptors.

    Parameters

      - ticks (list of float) – The ticks of the RangeDimension to create.

      - label (str) – The label of the dimension

      - unit (str) – The physical unit of the dimension

    Returns

      The newly created RangeDimension.

    Return type

      nixio.RangeDimension

  append_range_dimension_using_self(index=None)

    Convenience function to append a new RangeDimension to the list of existing dimensions that uses the DataArray itself as provider for the ticks. This is a replacement for rdim = array.append_range_dimension() rdim.link_data_array(self, index)

    Parameters

      index – The slice of the DataArray that contains the tick values. This must be a vector of the data. Defaults to [-1], i.e. the full first dimension.

    Type

      list of int

    Returns

      the newly created nixio.RangeDimension

    Return type

      nixio.RangeDimension

  append_sampled_dimension(sampling_interval, label=None, unit=None, offset=None)

    Append a new SampledDimension to the list of existing dimension descriptors.

    Parameters

      - sampling_interval (float) – The sampling interval of the SetDimension to create.

      - label (str) – The label of the dimension

      - unit (str) – The physical unit of the dimension

      - offset (float) – The offset between 0 and the first sample

    Returns

      The newly created SampledDimension.

    Return type

      nixio.SampledDimension

  append_set_dimension(labels=None)

    Append a new SetDimension to the list of existing dimension descriptors.

    Parameters

      labels (list or convertible to list) – The set of sample labels

    Returns

      The newly created SetDimension.

    Return type

      nixio.SetDimension

  classmethod create_new(nixfile, nixparent, h5parent, name, type_, data_type, shape, compression)
  property data

    DEPRECATED DO NOT USE ANYMORE! Returns self

    Type

      `DataArray`

  delete_dimensions()

    Delete all the dimension descriptors for this DataArray.

  property dimensions

    A property containing all dimensions of a DataArray. Dimensions can be obtained via their index. Adding dimensions is done using the respective append methods for dimension descriptors. This is a read only attribute.

    Type

      Container of dimension descriptors.

  property dtype

    The data type of the data stored in the DataArray. This is a read only property.

    Returns

      The data type

    Return type

      nixio.DataType

  property expansion_origin

    The expansion origin of the calibration polynomial. This is a read-write property and can be set to None. The default value is 0.

    Type

      float

  get_slice(positions, extents=None, mode=<DataSliceMode.Index: 1>)

    Reads a slice of the data. The slice can be specified either in indices or in data coordinates. For example, if the DataArray stores 1D data spanning one second in time sampled with 1kHz (1000 data points). If one wants to read the data of the interval 0.25 to 0.5 seconds, one can use either of the following statements:

    ```

      interval_data = data_array.get_slice([250], [500], mode=DataSliceMode.Index)[:] interval_data = data_array.get_slice([0.25],[0.25], mode=DataSliceMode.Data)[:]

    ```

    Note: The extents are not the end positions but the extent of the slice! In the case of regularly sampled dimensions, reaching beyond the start of end of the respective dimension will cause an exception. For irregularly sampled data no exception will be raised but the returned DataView might be invalid and empty.

    Parameters

      - positions (list length must match dimensionality of the data.) – Specifies the start of the data slice. List of either indices or data positions depending on the DataSliceMode.

      - extents (list, defaults to None) – Specifies the extents of the slice for each dimension.

      - mode (nixio.DataSliceMode) – Specifies how positions and extents are interpreted, they are either treated as indices (DataSliceMode.Index) or as positions in data coordinates (DataSliceMode.Data), Defaults to nixio.DataSliceMode.Index.

    Raises

      nixio.IncompatibleDimensions: if length of positions or, if given, extents does not match the rank of the data.

    Raises

      ValueError: if an invalid slice mode is given

    Returns

      A nixio.DataView object

    Return type

      nixio.DataView

  iter_dimensions()

    1-based index dimension iterator. The method returns a generator which returns the index starting from one and the dimensions.

  property label

    The label of the DataArray. The label corresponds to the label of the x-axis of a plot. This is a read-write property and can be set to None.

    Type

      str

  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  property polynom_coefficients

    The polynomial coefficients for the calibration. By default this is set to a {0.0, 1.0} for a linear calibration with zero offset. This is a read-write property and can be set to None

    Return type

      list of float

  property sources

    A property containing all Sources referenced by the DataArray. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.

  property unit

    The unit of the values stored in the DataArray. This is a read-write property and can be set to None.

    Type

      str

class nixio.data_array.DataSliceMode(value)

  Bases: `enum.Enum`

  An enumeration.

  Data = 2
  Index = 1

## nixio.data_frame module

class nixio.data_frame.DataFrame(nixfile, nixparent, h5group)

  Bases: `nixio.entity.Entity`, `nixio.data_set.DataSet`

  append_column(column, name, datatype=None)

    Append a new column to the DataFrame In case of string, it will be better to set explicitly the datatype.

    Parameters

      - column (array-like data) – The new column

      - name (str) – The name of new column

      - datatype (nixio.DataType) – The DataType of new column

  append_rows(data)

    Append a new row to the DataFrame. The data supplied must be iterable.

    Parameters

      data (array-like data) – The new row

  property column_names

    The dtype is the list of names of all columns in the DatFrame. This is a read only property.

    Type

      list of str

  property columns

    The dtype is the list of names and data types of all columns in the DatFrame. This is a read only property.

    Type

      list of tuples

  classmethod create_new(nixfile, nixparent, h5parent, name, type_, shape, col_dtype, compression)
  property df_shape

    The df_shape is the shape of the DataFrame in (number of rows, number of columns) format. This is a read only property.

    Type

      tuple

  property dtype

    The dtype is the list of DataTypes of all columns in the DatFrame. This is a read only property.

    Type

      list of DataType

  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  print_table(row_sl=None, col_sl=None)

    Print the whole DataFrame as a table

    Parameters

      - row_sl (slice or iterable of int) – Rows to be printed; None for printing all rows

      - col_sl (slice or iterable of int) – Columns to be printed; None for printing all columns

  read_cell(position=None, col_name=None, row_idx=None)

    Read a cell in the DataFrame

    Parameters

      - position (tuple or list or array with length 2) – Position of the targeted cell

      - col_name (str) – The column name in which the targeted cell belongs to

      - row_idx (list of int) – A length 1 list that specify on which row the targeted cell is located

  read_columns(index=None, name=None, slc=None, group_by_cols=False)

    Read one or multiple (part of) column(s) in the DataFrame

    Parameters

      - index (list of int) – Index of column(s) to be returned

      - name (list of str) – Name of column(s) to be returned

      - slc (slice) – The part of each column to be returned

      - group_by_cols (bool) – True for group return values by columns, False for group by rows. Only applicable for reading multiple columns

  read_rows(index)

    Read one or multiple row(s) in the DataFrame

    Parameters

      index (list of int) – Index of row(s) to be returned

  row_count()

    Return the total number of rows

  property units

    The unit of the values stored in the DataFrame. This is a read-write property and can be set to None.

    Type

      array of str

  write_cell(cell, position=None, col_name=None, row_idx=None)

    Overwrite a cell in the DataFrame

    Parameters

      - cell (same type as the specified column) – The new cell

      - position (tuple or list or array with length 2) – Position of the targeted cell

      - col_name (str) – The column name in which the targeted cell belongs to

      - row_idx (list of int) – A length 1 list that specify on which row the targeted cell is located

  write_column(column, index=None, name=None)

    Overwrite an existing column. Either index or name of the column should be provided.

    Parameters

      - column (array-like data) – The new column

      - index (string) – The index of the column that is written to

      - name (str) – The name of the column that is written to

  write_rows(rows, index)

    Overwrite one or multiple existing row(s)

    Parameters

      - rows ((nested) array-like data) – The new rows(s) and their data

      - index (list of int) – Index of rows(s) to be overwritten

  write_to_csv(filename, mode='w')

    Export the whole DataFrame to a CSV file

    Parameters

      - filename (str) – The resulted/ targeted CSV file to write to/ create

      - mode (str) – The column name in which the targeted cell belongs to

## nixio.data_set module

class nixio.data_set.DataSet

  Bases: `object`

  Data IO object for DataArray.

  append(data, axis=0)

    Append `data` to the DataSet along the `axis` specified.

    Parameters

      - data – The data to append. Shape must agree except for the specified axis

      - axis – Along which axis to append the data to

  property data_extent

    The size of the data.

    Type

      tuple of int

  property data_type

    The data type of the data stored in the DataArray. This is a read only property.

    Type

      nixio.DataType

  property dtype
    Type

      `numpy.dtype` object holding type information about the data stored in the DataSet.

  len()

    Length of the first dimension. Equivalent to DataSet.shape[0].

    Type

      int or long

  read_direct(data)

    Directly read all data stored in the `DataSet` into `data`. The supplied data must be a `numpy.ndarray` that matches the DataSet’s shape, must have C-style contiguous memory layout and must be writeable (see `numpy.ndarray.flags` and `ndarray` for more information).

    Parameters

      data (`numpy.ndarray`) – The array where data is being read into

  property shape
    Type

      tuple of data array dimensions.

  property size

    Number of elements in the DataSet, i.e. the product of the elements in `shape`.

    Type

      int

  write_direct(data)

    Directly write all of `data` to the `DataSet`. The supplied data must be a `numpy.ndarray` that matches the DataSet’s shape and must have C-style contiguous memory layout (see `numpy.ndarray.flags` and `ndarray` for more information).

    Parameters

      data (`numpy.ndarray`) – The array which contents is being written

## nixio.data_view module

class nixio.data_view.DataView(da, slices)

  Bases: `nixio.data_set.DataSet`

  property data_extent

    The size of the data.

    Type

      tuple of int

  property data_type

    The data type of the data stored in the DataArray. This is a read only property.

    Type

      nixio.DataType

  property debug_message
  property valid

## nixio.datatype module

class nixio.datatype.DataType

  Bases: `object`

  Bool

    alias of `numpy.bool_`

  Double

    alias of `numpy.float64`

  Float

    alias of `numpy.float32`

  FloatTypes = (<class 'numpy.float32'>, <class 'numpy.float64'>)
  Int16

    alias of `numpy.int16`

  Int32

    alias of `numpy.int32`

  Int64

    alias of `numpy.int64`

  Int8

    alias of `numpy.int8`

  IntTypes = (<class 'numpy.int8'>, <class 'numpy.int16'>, <class 'numpy.int32'>, <class 'numpy.int64'>, <class 'numpy.uint8'>, <class 'numpy.uint16'>, <class 'numpy.uint32'>, <class 'numpy.uint64'>)
  String

    alias of `numpy.str_`

  UInt16

    alias of `numpy.uint16`

  UInt32

    alias of `numpy.uint32`

  UInt64

    alias of `numpy.uint64`

  UInt8

    alias of `numpy.uint8`

  classmethod get_dtype(value)
  classmethod is_numeric_dtype(dtype)

## nixio.dimension_type module

class nixio.dimension_type.DimensionType(value)

  Bases: `enum.Enum`

  An enumeration.

  Range = 'range'
  Sample = 'sample'
  Set = 'set'

## nixio.dimensions module

class nixio.dimensions.Dimension(nixfile, data_array, index)

  Bases: `object`

  property dimension_link

    If the dimension has a DimensionLink to a data object, returns the DimensionLink object, otherwise returns None.

  property dimension_type
  property has_link

    Return True if this Dimension links to a data object (DataArray or DataFrame). Read-only property.

  property index
  property label
  link_data_array(data_array, index)
  link_data_frame(data_frame, index)
  remove_link()

class nixio.dimensions.DimensionContainer(name, nixfile, parent, itemclass)

  Bases: `nixio.container.Container`

  DimensionContainer extends Container to support returning different types of Dimension classes on return.

class nixio.dimensions.DimensionLink(nixfile, nixparent, h5group)

  Bases: `object`

  Links a Dimension to a data object (DataArray or DataFrame).

  A single vector of values from the underlying data object must be specified to serve as the ticks or labels for the associated Dimension.

  - A single vector of a DataArray.

  - A single column of a DataFrame.

  classmethod create_new(nixfile, nixparent, h5parent, dataobj, dotype, index)
  property file
  property id
  property index
  property label

    Returns the label of the linked data object: For DataArray links, returns the label. For DataFrame links, returns the name of the column specified by the LinkDimension’s index.

  property linked_data
  property unit

    Returns the unit from the linked data object (DataArray or DataFrame) specified by the LinkDimension’s index.

  property values

    Returns the values (vector or column) from the linked data object (DataArray or DataFrame) specified by the LinkDimension’s index.

class nixio.dimensions.IndexMode(value)

  Bases: `enum.Enum`

  IndexMode is used to define the behaviour of the index_of() methods.

  GEQ = 'geq'
  GreaterOrEqual = 'geq'
  LEQ = 'leq'
  Less = 'less'
  LessOrEqual = 'leq'

class nixio.dimensions.RangeDimension(data_array, index)

  Bases: `nixio.dimensions.Dimension`

  axis(count, start=0)

    Get an axis as defined by this range dimension.

    Parameters

      - count – A positive integer specifying the length of the axis (no of points).

      - start – positive integer, indicates the starting tick.

    Returns

      The created axis

    Return type

      list

  classmethod create_new(data_array, index, ticks)
  index_of(position, mode=<IndexMode.LessOrEqual: 'leq'>, ticks=None)

    Returns the index of a certain position in the dimension. Raises IndexError if the position is out of bounds (depending on mode).

    Parameters

      - position – The position.

      - mode – The IndexMode to use (default LessOrEqual). The default value (LessOrEqual) will return the index of the position that matches a tick if it matches a dimension tick exactly. If it does not match a tick, the previous index is returned. If the mode is Less, the previous index of the matching tick is always returned. If the mode is GreaterOrEqual and the position does not match a tick exactly, the next index is returned.

      - ticks (iterable) – Optional, the ticks stored in this dimension. If not passed as argument, they are (re)read from file.

    Returns

      The matching index

    Return type

      int

  property is_alias

    In versions < 1.5 a RangeDimension that was referring to the DataArray it describes was called an AliasRangeDimension. This has been made more flexible by allowing to link to any DataArray or DataFrame. For downward compatibility this method has been re-introduced in 1.5.1.

    Returns

      True, if this dimension links to a DataArray, False otherwise

    Return type

      bool

  property label
  link_data_array(data_array, index)
  link_data_frame(data_frame, index)
  range_indices(start_position, end_position, mode=<SliceMode.Exclusive: 'exclusive'>)

    Returns the start and end indices in this dimension that are matching to the given start and end position.

    Parameters

      - start_position (float) – the start position of the range.

      - end_position (float) – the end position of the range.

      - mode (nixio.SliceMode) – The nixio.SliceMode. Defaults to nixio.SliceMode.Exclusive, i.e. the end position is not part of the range.

    Returns

      The respective start and end indices. None, if range is empty

    Return type

      tuple of int

    Raises

      ValueError if invalid mode is given

    Raises

      Index Error if start position is greater than end position.

  tick_at(index)

    Returns the tick at the given index. Will throw an Exception if the index is out of bounds.

    Parameters

      index – The index.

    Returns

      The corresponding position.

    Return type

      double

  property ticks
  property unit

class nixio.dimensions.SampledDimension(data_array, index)

  Bases: `nixio.dimensions.Dimension`

  axis(count, start=None, start_position=None)

    Get an axis as defined by this nixio.SampledDimension. It either starts at the offset of the dimension, a number of sample points later, or at a given position. The latter must not be less than the offset. If start and start_position are given, start takes precedence.

    Parameters

      - count (int) – A positive integer specifying the length of the axis (no of samples).

      - start (int) – positive integer, indicates the starting sample. Defaults to None. Precedes over the start_position.

      - start_position (double) – The start position of the axis. Defaults to None.

    Raises

      ValueError if start is negative or if the start_position is given and is less than offset.

    Returns

      The created axis

    Return type

      tuple

  classmethod create_new(data_array, index, sample)
  index_of(position, mode=<IndexMode.LessOrEqual: 'leq'>)

    Returns the index of a certain position in the dimension. Raises IndexError if the position is out of bounds (depending on mode).

    Parameters

      - position – The position.

      - mode – The IndexMode to use (default LessOrEqual). The default value (LessOrEqual) will return the index of the position calculated based on the dimension offset and sampling_interval if it matches a dimension tick exactly. If it does not match a tick, the previous index is returned. If the mode is Less, the previous index of the calculated position is always returned. If the mode is GreaterOrEqual and the calculated position does not match a tick exactly, the next index is returned.

    Returns

      The matching index.

    Return type

      int

  link_data_array(*_)
  link_data_frame(*_)
  property offset
  position_at(index)

    Returns the position corresponding to a given index.

    Parameters

      index – A positive integer.

    Returns

      The position matching to the index.

    Return type

      float

  range_indices(start_position, end_position, mode=<SliceMode.Exclusive: 'exclusive'>)

    Returns the start and end indices in this dimension that are matching to the given start and end position.

    Parameters

      - start_position (float) – the start position of the range.

      - end_position (float) – the end position of the range.

      - mode (nixio.SliceMode) – The nixio.SliceMode. Defaults to nixio.SliceMode.Exclusive, i.e. the end position is not part of the range.

    Returns

      The respective start and end indices. None, if the range is empty!

    Return type

      tuple of int

    Raises

      ValueError if invalid mode is given

    Raises

      Index Error if start position is greater than end position.

  property sampling_interval
  property unit

class nixio.dimensions.SetDimension(data_array, index)

  Bases: `nixio.dimensions.Dimension`

  classmethod create_new(data_array, index)
  index_of(position, mode=<IndexMode.LessOrEqual: 'leq'>, dim_labels=None)

    Returns the index of a certain position in the dimension. Raises IndexError if the position is out of bounds (depending on mode and number of labels).

    Parameters

      - position – The position.

      - mode – The IndexMode to use (default LessOrEqual). The modes LessOrEqual and GreaterOrEqual will return the integer representation of the position if it is equal to the nearest integer. If the position is not an integer (or is not equal to the nearest integer), then the value is rounded down (for LessOrEqual) or rounded up (for GreaterOrEqual). If the mode is Less, the previous integer is always returned.

      - dim_labels (iterable) – The labels of this dimension, if None (default) the labels will be read from file.

    Returns

      The matching index

    Return type

      int

  property labels
  range_indices(start_position, end_position, mode=<SliceMode.Exclusive: 'exclusive'>)

    Returns the start and end indices in this dimension that are matching to the given start and end position.

    Parameters

      - start_position (float) – the start position of the range.

      - end_position (float) – the end position of the range.

      - mode (nixio.SliceMode) – The nixio.SliceMode. Defaults to nixio.SliceMode.Exclusive, i.e. the end position is not part of the range.

    Returns

      The respective start and end indices. None, if the range is empty

    Return type

      tuple of int

    Raises

      ValueError if invalid mode is given

    Raises

      Index Error if start position is greater than end position.

class nixio.dimensions.SliceMode(value)

  Bases: `enum.Enum`

  An enumeration.

  Exclusive = 'exclusive'
  Inclusive = 'inclusive'
  to_index_mode()

## nixio.entity module

class nixio.entity.Entity(nixfile, nixparent, h5group)

  Bases: `object`

  classmethod create_new(nixfile, nixparent, h5parent, name=None, type_=None)
  property created_at

    The creation time of the entity. This is a read-only property. Use force_created_at in order to change the creation time.

    Return type

      int

  property definition

    The definition of the entity. The definition can contain a textual description of the entity. This is an optional read-write property, and can be None if no definition is available.

    Type

      str

  property file

    Reference to the NIX File object. This is a read-only property.

    Return type

      nixio.File

  force_created_at(time=None)

    Sets the creation time created_at to the given time (default: current time).

    Parameters

      time (int) – The time to set.

  force_updated_at(time=None)

    Sets the update time updated_at to the given time. (default: current time)

    Parameters

      time (int) – The time to set.

  property id

    A property providing the ID of the Entity. The id is generated automatically, therefore the property is read-only.

    Return type

      str

  property name

    The name of an entity. The name serves as a human readable identifier. This is a read-only property; entities cannot be renamed.

    Type

      str

  property type

    The type of the entity. The type is used in order to add semantic meaning to the entity. This is a read-write property, but it can’t be set to None.

    Type

      str

  property updated_at

    The time of the last update of the entity. This is a read-only property. Use force_updated_at in order to change the update time.

    Return type

      int

## nixio.feature module

class nixio.feature.Feature(nixfile, nixparent, h5group)

  Bases: `object`

  classmethod create_new(nixfile, nixparent, h5parent, data, link_type)
  property created_at

    The creation time of the entity. This is a read-only property. Use force_created_at in order to change the creation time.

    Return type

      int

  property data
  property file
  property id
  property link_type
  property updated_at

    The time of the last update of the entity. This is a read-only property. Use force_updated_at in order to change the update time.

    Return type

      int

## nixio.file module

class nixio.file.File(path, mode='a', compression=<Compression.Auto: 'Auto'>, auto_update_timestamps=True)

  Bases: `object`

  property auto_update_timestamps

    If enabled, automatically updates the ‘updated_at’ attribute when an object’s data or attributes are changed.

    Type

      bool

  property blocks

    A property containing all blocks of a file. Blocks can be obtained by their name, id or index. Blocks can be deleted from the list, when a block is deleted all its content (data arrays, tags and sources) will be also deleted from the file. Adding new Block is done via the create_block method of File. This is a read-only attribute.

  close()

    Closes an open file.

  copy_section(obj, children=True, keep_id=True, name='')

    Copy a section to the file.

    Parameters

      - obj (nixio.Section) – The Section to be copied

      - children (bool) – Specify if the copy should be recursive

      - keep_id (bool) – Specify if the id should be kept

      - name (str) – Name of copied section, Default is name of source section

    Returns

      The copied section

    Return type

      nixio.Section

  create_block(name='', type_='', compression=<Compression.Auto: 'Auto'>, copy_from=None, keep_copy_id=True)

    Create a new block inside the file.

    Parameters

      - name (str) – The name of the block to create.

      - type (str) – The type of the block.

      - compression – No, DeflateNormal, Auto (default: Auto)

      - copy_from (nixio.Block) – The Block to be copied, None in normal mode

      - keep_copy_id (bool) – Specify if the id should be copied in copy mode

    Returns

      The newly created block.

    Return type

      nixio.Block

  create_section(name, type_='undefined', oid=None)

    Create a new metadata section inside the file.

    Parameters

      - name (str) – The name of the section to create.

      - type (str) – The type of the section.

      - oid (str) – object id, UUID string as specified in RFC 4122. If no id is provided, an id will be generated and assigned.

    Returns

      The newly created section.

    Return type

      nixio.Section

  property created_at

    The creation time of the file. This is a read-only property. Use force_created_at in order to change the creation time.

    Return type

      int

  find_sections(filtr=<function File.<lambda>>, limit=None)

    Get all sections and their child sections recursively.

    This method traverses the trees of all sections. The traversal is accomplished via breadth first and can be limited in depth. On each node or section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.

    Parameters

      - filtr (function) – A filter function

      - limit (int) – The maximum depth of traversal

    Returns

      A list containing the matching sections.

    Return type

      list of nixio.Section

  flush()
  force_created_at(time=None)

    Sets the creation time created_at to the given time (default: current time).

    Parameters

      time (int) – The time to set

  force_updated_at(time=None)

    Sets the update time updated_at to the given time. (default: current time)

    Parameters

      time (int) – The time to set (default: now)

  property format

    The format of the file. This read only property should always have the value ‘nix’.

    Type

      str

  property id
  is_open()

    Checks whether a file is open or closed.

    Returns

      True if the file is open, False otherwise.

    Return type

      bool

  classmethod open(path, mode='a', compression=<Compression.Auto: 'Auto'>, backend=None, auto_update_timestamps=True)

    Open a NIX file, or create it if it does not exist.

    Parameters

      - path – Path to file

      - mode – FileMode ReadOnly, ReadWrite, or Overwrite. (default: ReadWrite)

      - compression – No, DeflateNormal, Auto (default: Auto)

      - auto_update_timestamps – Enable/disable automatic updating of ‘updated_at’ timestamp. (default: True)

    Returns

      nixio.File object

  pprint(indent=2, max_length=120, extra=True, max_depth=3)

    Pretty Printing the Data and MetaData Tree of the whole File

    Parameters

      - indent (int) – The length of one indentation space

      - max_length (int) – Maximum length of each line of output

      - extra (bool) – True to print extra information of Entities

      - max_depth (int) – Maximum recursion being printed in MetaData tree

  property sections

    A property containing all root Sections of a file. Specific root Sections can be obtained by their name, id or index. Sections can be deleted from this list. Notice: when a section is deleted all its child section and properties will be removed too. Adding a new Section is done via the crate_section method of File. This is a read-only property.

  property updated_at

    The time of the last update of the file. This is a read-only property. Use force_updated_at in order to change the update time.

    Return type

      int

  validate()
  property version

    The file format version.

    Type

      tuple

class nixio.file.FileMode

  Bases: `object`

  Overwrite = 'w'
  ReadOnly = 'r'
  ReadWrite = 'a'

nixio.file.can_read(nixfile)

nixio.file.can_write(nixfile)

nixio.file.make_fapl()

nixio.file.make_fcpl()

nixio.file.map_file_mode(mode)

## nixio.group module

class nixio.group.Group(nixfile, nixparent, h5group)

  Bases: `nixio.entity.Entity`

  classmethod create_new(nixfile, nixparent, h5parent, name, type_)
  property data_arrays

    A property containing all data arrays referenced by the group. Referenced data arrays can be obtained by index or their id. References can be removed from the list, removing a referenced DataArray will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.

  property data_frames

    A property containing all data frames referenced by the group. Referenced data frames can be obtained by index or their id. References can be removed from the list, removing a referenced DataFrame will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.

  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  property multi_tags

    A property containing all MultiTags referenced by the group. MultiTags can be obtained by index or their id. MultiTags can be removed from the list, removing a referenced MultiTag will not remove it from the file. New MultiTags can be added using the append method of the list. This is a read only attribute.

  property sources

    A property containing all Sources referenced by the Group. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.

  property tags

    A property containing all tags referenced by the group. Tags can be obtained by index or their id. Tags can be removed from the list, removing a referenced Tag will not remove it from the file. New Tags can be added using the append method of the list. This is a read only attribute.

## nixio.info module

## nixio.link_type module

class nixio.link_type.LinkType(value)

  Bases: `enum.Enum`

  An enumeration.

  Indexed = 'indexed'
  Tagged = 'tagged'
  Untagged = 'untagged'

## nixio.multi_tag module

class nixio.multi_tag.MultiTag(nixfile, nixparent, h5group)

  Bases: `nixio.tag.BaseTag`

  classmethod create_new(nixfile, nixparent, h5parent, name, type_, positions)
  property extents

    The extents defined by the tag. This is an optional read-write property and may be set to None.

    Type

      nixio.DataArray or None

  feature_data(posidx, featidx, stop_rule=<SliceMode.Exclusive: 'exclusive'>)
  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  property positions

    The positions defined by the tag. This is a read-write property.

    Type

      nixio.DataArray

  property references

    A property containing all data arrays referenced by the tag. Referenced data arrays can be obtained by index or their id. References can be removed from the list, removing a referenced DataArray will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.

    Type

      nixio.LinkContainer of nixio.DataArray

  retrieve_data(posidx, refidx)
  retrieve_feature_data(posidx, featidx)
  property sources

    A property containing all Sources referenced by the MultiTag. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.

  tagged_data(posidx, refidx, stop_rule=<SliceMode.Exclusive: 'exclusive'>)

## nixio.property module

class nixio.property.OdmlType(value)

  Bases: `enum.Enum`

  OdmlType provides all types currently supported by the odML data format. It provides additional information about the nature of the values of an odML Property.

  Boolean = 'boolean'
  Date = 'date'
  Datetime = 'datetime'
  Float = 'float'
  Int = 'int'
  Person = 'person'
  String = 'string'
  Text = 'text'
  Time = 'time'
  URL = 'url'
  compatible(value)

    compatible returns True or False depending on whether a passed value can be mapped to an OdmlType or not.

    Parameters

      value – Any single value

    Returns

      Boolean

  classmethod get_odml_type(dtype)

    get_odml_type returns the appropriate OdmlType for a handed in nix value DataType.

    Parameters

      dtype – nix DataType

    Returns

      OdmlType

class nixio.property.Property(nixfile, nixparent, h5dataset)

  Bases: `nixio.entity.Entity`

  An odML Property

  classmethod create_new(nixfile, nixparent, h5parent, name, dtype, shape=None, oid=None)
  property data_type
  property definition

    The definition of the entity. The definition can contain a textual description of the entity. This is an optional read-write property, and can be None if no definition is available.

    Type

      str

  delete_values()
  property dependency
  property dependency_value
  extend_values(data)

    Extends values to existing data. Suitable when new data is nested or original data is long.

  property name

    The name of an entity. The name serves as a human readable identifier. This is a read-only property; entities cannot be renamed.

    Type

      str

  property odml_type
  pprint(indent=2, max_length=80, current_depth=- 1)

    Pretty print method. Method is called in Section.pprint()

  property reference
  property uncertainty
  property unit
  property value_origin
  property values

## nixio.section module

class nixio.section.S(section_type, section=None)

  Bases: `object`

class nixio.section.Section(nixfile, nixparent, h5group)

  Bases: `nixio.entity.Entity`

  copy_section(obj, children=True, keep_id=True, name='')

    Copy a section to the section.

    Parameters

      - obj (nixio.Section) – The Section to be copied

      - children (bool) – Specify if the copy should be recursive

      - keep_id (bool) – Specify if the id should be kept

      - name (str) – Name of copied section, Default is name of source section

    Returns

      The copied section

    Return type

      nixio.Section

  classmethod create_new(nixfile, nixparent, h5parent, name, type_, oid=None)
  create_property(name='', values_or_dtype=0, oid=None, copy_from=None, keep_copy_id=True)

    Add a new property to the section.

    Parameters

      - name (str) – The name of the property to create/copy.

      - values_or_dtype (list of values or a nixio.DataType) – The values of the property or a valid DataType.

      - oid (str) – object id, UUID string as specified in RFC 4122. If no id is provided, an id will be generated and assigned.

      - copy_from (nixio.Property) – The Property to be copied, None in normal mode

      - keep_copy_id (bool) – Specify if the id should be copied in copy mode

    Returns

      The newly created property.

    Return type

      nixio.Property

  create_section(name, type_='undefined', oid=None)

    Creates a new subsection that is a child of this section entity.

    Parameters

      - name (str) – The name of the section to create.

      - type (str) – The type of the section.

      - oid (str) – object id, UUID string as specified in RFC 4122. If no id is provided, an id will be generated and assigned.

    Returns

      The newly created section.

    Return type

      nixio.Section

  find_related(filtr=<function Section.<lambda>>)

    Get all related sections of this section.

    The result can be filtered. On each related section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.

    Parameters

      filtr (function) – A filter function

    Returns

      A list containing the matching related sections.

    Return type

      list of nixio.Section

  find_sections(filtr=<function Section.<lambda>>, limit=None)

    Get all child sections recursively. This method traverses the trees of all sections. The traversal is accomplished via breadth first and can be limited in depth. On each node or section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.

    Parameters

      - filtr (function) – A filter function

      - limit (int) – The maximum depth of traversal

    Returns

      A list containing the matching sections.

    Return type

      list of nixio.Section

  inherited_properties()
  items()
  property link

    Link to another section. If a section is linked to another section, the linking section inherits all properties from the target section. This is an optional read-write property and may be set to None.

    Type

      nixio.Section

  property parent

    The parent section. This is a read-only property. For root sections this property is always None.

    Accessing this property can be slow when the metadata tree is large.

    Type

      nixio.Section

  pprint(indent=2, max_depth=- 1, max_length=80, current_depth=0)

    Pretty print method.

    Parameters

      - indent (int) – The number of indentation spaces per recursion

      - max_depth (int) – The maximum times of recursion, -1 for the full depth

      - max_length (int) – The maximum length of each line of output

      - current_depth (int) – The current times of recursion

  property props

    A property containing all Property entities associated with the section. Properties can be accessed by name, index, or id. Properties can be deleted from the list. Adding new Properties is done using the create_property method. This is a read-only attribute.

    Type

      Container of nixio.Property

  property reference
  property referring_blocks
  property referring_data_arrays
  property referring_groups
  property referring_multi_tags
  property referring_objects
  property referring_sources
  property referring_tags
  property repository

    URL to the terminology repository the section is associated with. This is an optional read-write property and may be set to None.

    Type

      str

  property sections

    A property providing all child Sections of a Section. Child sections can be accessed by name, index, or id. Sections can also be deleted: if a Section is deleted, all its properties and child Sections are removed from the file too. Adding new Sections is achieved using the create_section method. This is a read-only attribute.

    Type

      Container of nixio.Section

## nixio.source module

class nixio.source.Source(nixfile, nixparent, h5group)

  Bases: `nixio.entity.Entity`

  classmethod create_new(nixfile, nixparent, h5parent, name, type_)
  create_source(name, type_)

    Create a new source as a child of the current Source.

    Parameters

      - name (str) – The name of the source to create.

      - type (str) – The type of the source.

    Returns

      The newly created source.

    Return type

      nixio.Source

  find_sources(filtr=<function Source.<lambda>>, limit=None)

    Get all child sources of this source recursively.

    This method traverses the tree of all sources. The traversal is accomplished via breadth first and can be limited in depth. On each node or source a filter is applied. If the filter returns true the respective source will be added to the result list. By default a filter is used that accepts all sources.

    Parameters

      - filtr (function) – A filter function

      - limit (int) – The maximum depth of traversal

    Returns

      A list containing the matching sources.

    Return type

      list of nixio.Source

  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  property parent_block

    Returns the block this source is contained in.

    Returns

      the Block containing this source

    Return type

      nixio.Block

  property parent_source

    Get the parent source of this source. If this source is at the root, None will be returned

    Returns

      the parent source

    Return type

      Source or None

  property referring_data_arrays

    Returns all DataArray entities linking to this source.

    Returns

      all DataArrays referring to this source.

    Return type

      list

  property referring_multi_tags

    Returns all MultiTag entities linking to this source.

    Returns

      all MultiTags referring to this source.

    Return type

      list

  property referring_objects

    Returns the list of entities that link to this source.

    Returns

      all objects referring to this source.

    Return type

      list

  property referring_tags

    Returns all Tag entities linking to this source.

    Returns

      all Tags referring to this source.

    Return type

      list

  property sources

    A property containing child sources of a Source. Sources can be obtained via their name, index, id. Sources can be deleted from the list. Adding sources is done using the Blocks create_source method. This is a read only attribute.

## nixio.source_link_container module

class nixio.source_link_container.SourceLinkContainer(parent)

  Bases: `nixio.container.LinkContainer`

  append(item)

## nixio.tag module

class nixio.tag.BaseTag(nixfile, nixparent, h5group)

  Bases: `nixio.entity.Entity`

  Base class for Tag and MultiTag

  create_feature(data, link_type)

    Create a new feature.

    Parameters

      - data (nixio.DataArray) – The data array of this feature.

      - link_type (nixio.LinkType) – The link type of this feature.

    Returns

      The created feature object.

    Return type

      nixio.Feature

  property features

    A property containing all features. Features can be obtained via their index or their ID. Features can be deleted from the list. Adding new features is done using the create_feature method. This is a read only attribute.

    Type

      Container of nixio.Feature.

  property units

    Property containing the units of the tag. The tag must provide a unit for each dimension of the position or extent vector. This is a read-write property.

    Type

      list of str

class nixio.tag.FeatureContainer(name, nixfile, parent, itemclass)

  Bases: `nixio.container.Container`

  The FeatureContainer has one minor difference from the regular Container: A Feature can be retrieved by the ID or name of the linked DataArray as well as the ID of the feature itself.

class nixio.tag.Tag(nixfile, nixparent, h5group)

  Bases: `nixio.tag.BaseTag`

  classmethod create_new(nixfile, nixparent, h5parent, name, type_, position)
  property extent

    The extent defined by the tag. This is an optional read-write property and may be set to None.

    Type

      list of float

  feature_data(featidx, stop_rule=<SliceMode.Exclusive: 'exclusive'>)
  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  property position

    The position defined by the tag. This is a read-write property.

    Type

      list of float

  property references

    A property containing all data arrays referenced by the tag. Referenced data arrays can be obtained by index or their id. References can be removed from the list, removing a referenced DataArray will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.

    Type

      Container of nixio.DataArray

  retrieve_data(refidx)
  retrieve_feature_data(featidx)
  property sources

    A property containing all Sources referenced by the Tag. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.

  tagged_data(refidx, stop_rule=<SliceMode.Exclusive: 'exclusive'>)

## nixio.validator module

class nixio.validator.ValidationError

  Bases: `object`

  Static class for defining validation error messages

  DataFrameMismatch = 'referenced data frame for dimension {} does not have the same row count as the data array'
  DimensionMismatch = 'data dimensionality does not match number of defined dimensions'
  DimensionTypeMismatch = 'dimension_type attribute for dimension {} does not match Dimension object type'
  ExtentDimensionMismatch = 'number of entries in extent does not match number of dimensions in all referenced DataArrays'
  ExtentsDimensionMismatch = 'number of entries (in 2nd dim) in extents does not match number of dimensions in all referenced DataArrays'
  IncorrectDimensionIndex = 'index for dimension {} is set to incorrect value {}'
  InvalidDimensionIndex = 'index for dimension {} is not set to a valid value (index > 0)'
  InvalidDimensionUnit = 'unit for dimension {} is set but it is not an atomic SI unit (Note: composite units are not supported)'
  InvalidSamplingInterval = 'sampling interval for dimension {} is not valid (interval > 0)'
  InvalidUnit = 'unit is invalid: not an atomic SI (Note: composite units are not supported)'
  NoData = 'data is not set'
  NoDataType = 'data type is not set'
  NoDate = 'date is not set'
  NoID = 'no ID set'
  NoLinkType = 'link_type is not set'
  NoName = 'no name set'
  NoPosition = 'position is not set'
  NoPositions = 'positions are not set'
  NoSamplingInterval = 'sampling interval for dimension {} is not set'
  NoTicks = 'ticks for dimension {} are not set'
  NoType = 'no type set'
  PositionDimensionMismatch = 'number of entries in position does not match number of dimensions in all referenced DataArrays'
  PositionExtentMismatch = 'number of entries in position and extent do not match'
  PositionsDimensionMismatch = 'number of entries (in 2nd dim) in positions does not match number of dimensions in all referenced DataArrays'
  PositionsExtentsMismatch = 'number of entries in positions and extents do not match'
  RangeDimTicksMismatch = 'number of ticks in RangeDimension ({}) differs from the number of data entries along the corresponding data dimension'
  ReferenceUnitsIncompatible = "some of the referenced DataArrays' dimensions have units that are not convertible to the units set in the Tag (Note: composite units are not supported)"
  ReferenceUnitsMismatch = "some of the referenced DataArrays' dimensions don't have units where the Tag has; make sure that all references have the same number of dimensions as the Tag has units and that each dimension has a unit set"
  SetDimLabelsMismatch = 'number of labels in SetDimension ({}) differs from the number of data entries along the corresponding data dimension'
  UnsortedTicks = 'ticks for dimension {} are not sorted'

class nixio.validator.ValidationWarning

  Bases: `object`

  InvalidUnit = 'unit is not SI or composite of SI units'
  NoExpansionOrigin = 'polynomial coefficients for calibration are set, but expansion origin is missing'
  NoFileID = 'file ID is not set'
  NoFormat = 'format is not set'
  NoPolynomialCoefficients = 'expansion origin for calibration is set, but polynomial coefficients are missing'
  NoUnit = 'unit is not set'
  NoVersion = 'version is not set'
  OffsetNoUnit = 'offset for dimension {} is set, but no valid unit is set'

nixio.validator.check_block(block)

  Validate a Block and return all errors and warnings for the block and each individual contained object.

  Returns

    A list of ‘errors’ and a list of ‘warnings’

nixio.validator.check_data_array(da)

  Validate a DataArray and its Dimensions and return all errors and warnings. Errors and warnings about Dimension objects are included in the DataArray errors and warnings lists.

  Returns

    A list of ‘errors’ and a list of ‘warnings’

nixio.validator.check_entity(entity)

  General NIX entity validator

nixio.validator.check_feature(feat, idx)

  Validate a Feature and return all errors.

  Returns

    A list of ‘errors’

nixio.validator.check_file(nixfile)

  Validate a NIX file and all contained objects and return all errors and warnings for each individual object.

  Returns

    A nested dictionary of errors and warnings. Each subdictionary

  is indexed by the object with values describing the error or warning. :rtype: Dictionary

nixio.validator.check_group(group)

  Validate a Group and return all errors and warnings. Does not check contained objects.

  Returns

    A list of ‘errors’ and a list of ‘warnings’

nixio.validator.check_multi_tag(mtag)

  Validate a MultiTag and its Features and return all errors and warnings. Errors and warnings about Features are included in the MultiTag errors and warnings lists.

  For Features, only the basic Entity requirements, LinkType, and the existence of a referenced DataArray are checked. The linked DataArray is not checked for validity (see check_data_array() for those validation checks).

  Returns

    A list of ‘errors’ and a list of ‘warnings’

nixio.validator.check_property(prop, idx)

  Validate a Property and return all errors.

  Returns

    A list of ‘errors’ and ‘warnings’

nixio.validator.check_range_dimension(dim, idx)

  Validate a RangeDimension and return all errors and warnings.

  Returns

    A list of ‘errors’ and a list of ‘warnings’

nixio.validator.check_sampled_dimension(dim, idx)

  Validate a SampledDimension and return all errors and warnings.

  Returns

    A list of ‘errors’ and a list of ‘warnings’

nixio.validator.check_section(section)

  Validate a Section and its Properties return all errors and warnings.

  Errors and warnings about Properties are included in the Section errors and warnings lists.

  Returns

    A list of ‘errors’ and a list of ‘warnings’

nixio.validator.check_set_dimension()

  Validate a SetDimension and return all errors and warnings.

  Returns

    A list of ‘errors’ and a list of ‘warnings’

nixio.validator.check_source(source)

  Validate a Source and return all errors and warnings.

  Returns

    A list of ‘errors’ and a list of ‘warnings’

nixio.validator.check_tag(tag)

  Validate a Tag and its Features and return all errors and warnings. Errors and warnings about Features are included in the Tag errors and warnings lists.

  For Features, only the basic Entity requirements, LinkType, and the existence of a referenced DataArray are checked. The linked DataArray is not checked for validity (see check_data_array() for those validation checks).

  Returns

    A list of ‘errors’ and a list of ‘warnings’

nixio.validator.get_dim_units(data_array)

  Helper function to collect the units of the dimensions of a data array

nixio.validator.tag_units_match_refs_units(tag_units, refs_units)

## Module contents

class nixio.Block(nixfile, nixparent, h5group, compression=<Compression.Auto: 'Auto'>)

  Bases: `nixio.entity.Entity`

  create_data_array(name='', array_type='', dtype=None, shape=None, data=None, compression=<Compression.Auto: 'Auto'>, copy_from=None, keep_copy_id=True, label=None, unit=None)

    Create/copy a new data array for this block. Either `shape` or `data` must be given. If both are given their shape must agree. If `dtype` is not specified it will default to 64-bit floating points.

    Parameters

      - name (str) – The name of the data array to create/copy.

      - array_type (str) – The type of the data array.

      - dtype (`numpy.dtype`) – Which data-type to use for storage

      - shape (tuple of int or long) – Layout (dimensionality and extent)

      - data (array-like data) – Data to write after storage has been created

      - compression (`Compression`) – En-/disable dataset compression.

      - copy_from (nixio.DataArray) – The DataArray to be copied, None in normal mode

      - keep_copy_id (bool) – Specify if the id should be copied in copy mode

      - label (str) – The label, defaults to None.

      - unit (str) – The unit of the stored data. Defaults to None.

    Returns

      The newly created data array.

    Return type

      `DataArray`

  create_data_frame(name='', type_='', col_dict=None, col_names=None, col_dtypes=None, data=None, compression=<Compression.No: 'None'>, copy_from=None, keep_copy_id=True)

    Create/copy a new data frame for this block. Either `col_dict` or `col_name` and `col_dtypes` must be given. If both are given, `col_dict` will be used.

    Parameters

      - name (str) – The name of the data frame to create/copy.

      - type (str) – The type of the data frame.

      - col_dict (dict or OrderedDict of {str: type}) – The dictionary that specifies column names and data type in each column

      - col_names (tuples or list or np.array of string) – The collection of name of all columns in order

      - col_dtypes (tuples or list or np.array of type) – The collection of data type of all columns in order

      - data (array-like data with compound data type as specified in the columns) – Data to write after storage has been created

      - compression (`Compression`) – En-/disable dataset compression.

      - copy_from (nixio.DataFrame) – The DataFrame to be copied, None in normal mode

      - keep_copy_id (bool) – Specify if the id should be copied in copy mode

    Returns

      The newly created data frame.

    Return type

      `DataFrame`

  create_group(name, type_)

    Create a new group on this block.

    Parameters

      - name (str) – The name of the group to create.

      - type (str) – The type of the group.

    Returns

      The newly created group.

    Return type

      nixio.Group

  create_multi_tag(name='', type_='', positions=None, extents=None, copy_from=None, keep_copy_id=True)

    Create/copy a new multi tag for this block.

    Parameters

      - name (str) – The name of the tag to create/copy.

      - type (str) – The type of tag.

      - positions (nixio.DataArray) – A data array defining all positions of the tag.

      - copy_from (nixio.MultiTag) – The MultiTag to be copied, None in normal mode

      - keep_copy_id (bool) – Specify if the id should be copied in copy mode

    Returns

      The newly created tag.

    Return type

      nixio.MultiTag

  classmethod create_new(nixparent, h5parent, name, type_, compression)
  create_source(name, type_)

    Create a new source on this block.

    Parameters

      - name (str) – The name of the source to create.

      - type (str) – The type of the source.

    Returns

      The newly created source.

    Return type

      nixio.Source

  create_tag(name='', type_='', position=0, copy_from=None, keep_copy_id=True)

    Create/copy a new tag for this block.

    Parameters

      - name (str) – The name of the tag to create/copy.

      - type (str) – The type of tag.

      - position – Coordinates of the start position in units of the respective data dimension.

      - copy_from (nixio.Tag) – The Tag to be copied, None in normal mode

      - keep_copy_id (bool) – Specify if the id should be copied in copy mode

    Returns

      The newly created tag.

    Return type

      nixio.Tag

  property data_arrays

    A property containing all data arrays of a block. DataArray entities can be obtained via their index or by their id. Data arrays can be deleted from the list. Adding a data array is done using the Blocks create_data_array method. This is a read only attribute.

  property data_frames
  find_sources(filtr=<function Block.<lambda>>, limit=None)

    Get all sources in this block recursively.

    This method traverses the tree of all sources in the block. The traversal is accomplished via breadth first and can be limited in depth. On each node or source a filter is applied. If the filter returns true the respective source will be added to the result list. By default a filter is used that accepts all sources.

    Parameters

      - filtr (function) – A filter function

      - limit (int) – The maximum depth of traversal

    Returns

      A list containing the matching sources.

    Return type

      list of nixio.Source

  property groups

    A property containing all groups of a block. Group entities can be obtained via their index or by their id. Groups can be deleted from the list. Adding a Group is done using the Blocks create_group method. This is a read only attribute.

  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  property multi_tags

    A property containing all multi tags of a block. MultiTag entities can be obtained via their index or by their id. Tags can be deleted from the list. Adding tags is done using the Blocks create_multi_tag method. This is a read only attribute.

  pprint(indent=2, max_length=120, extra=True, start_depth=0)

    Pretty Printing the Data and MetaData Tree of the whole File

    Parameters

      - indent (int) – The length of one indentation space

      - max_length (int) – Maximum length of each line of output

      - extra (bool) – True to print extra information of Entities

      - start_depth (int) – Starting depth of indentation

  property sources

    A property containing all sources of a block. Sources can be obtained via their index or by their id. Sources can be deleted from the list. Adding sources is done using the Blocks create_source method. This is a read only attribute.

  property tags

    A property containing all tags of a block. Tag entities can be obtained via their index or by their id. Tags can be deleted from the list. Adding tags is done using the Blocks create_tag method. This is a read only attribute.

class nixio.Compression(value)

  Bases: `enum.Enum`

  An enumeration.

  Auto = 'Auto'
  DeflateNormal = 'DeflateNormal'
  No = 'None'

class nixio.DataArray(nixfile, nixparent, h5group)

  Bases: `nixio.entity.Entity`, `nixio.data_set.DataSet`

  append_range_dimension(ticks=None, label=None, unit=None)

    Append a new RangeDimension to the list of existing dimension descriptors.

    Parameters

      - ticks (list of float) – The ticks of the RangeDimension to create.

      - label (str) – The label of the dimension

      - unit (str) – The physical unit of the dimension

    Returns

      The newly created RangeDimension.

    Return type

      nixio.RangeDimension

  append_range_dimension_using_self(index=None)

    Convenience function to append a new RangeDimension to the list of existing dimensions that uses the DataArray itself as provider for the ticks. This is a replacement for rdim = array.append_range_dimension() rdim.link_data_array(self, index)

    Parameters

      index – The slice of the DataArray that contains the tick values. This must be a vector of the data. Defaults to [-1], i.e. the full first dimension.

    Type

      list of int

    Returns

      the newly created nixio.RangeDimension

    Return type

      nixio.RangeDimension

  append_sampled_dimension(sampling_interval, label=None, unit=None, offset=None)

    Append a new SampledDimension to the list of existing dimension descriptors.

    Parameters

      - sampling_interval (float) – The sampling interval of the SetDimension to create.

      - label (str) – The label of the dimension

      - unit (str) – The physical unit of the dimension

      - offset (float) – The offset between 0 and the first sample

    Returns

      The newly created SampledDimension.

    Return type

      nixio.SampledDimension

  append_set_dimension(labels=None)

    Append a new SetDimension to the list of existing dimension descriptors.

    Parameters

      labels (list or convertible to list) – The set of sample labels

    Returns

      The newly created SetDimension.

    Return type

      nixio.SetDimension

  classmethod create_new(nixfile, nixparent, h5parent, name, type_, data_type, shape, compression)
  property data

    DEPRECATED DO NOT USE ANYMORE! Returns self

    Type

      `DataArray`

  delete_dimensions()

    Delete all the dimension descriptors for this DataArray.

  property dimensions

    A property containing all dimensions of a DataArray. Dimensions can be obtained via their index. Adding dimensions is done using the respective append methods for dimension descriptors. This is a read only attribute.

    Type

      Container of dimension descriptors.

  property dtype

    The data type of the data stored in the DataArray. This is a read only property.

    Returns

      The data type

    Return type

      nixio.DataType

  property expansion_origin

    The expansion origin of the calibration polynomial. This is a read-write property and can be set to None. The default value is 0.

    Type

      float

  get_slice(positions, extents=None, mode=<DataSliceMode.Index: 1>)

    Reads a slice of the data. The slice can be specified either in indices or in data coordinates. For example, if the DataArray stores 1D data spanning one second in time sampled with 1kHz (1000 data points). If one wants to read the data of the interval 0.25 to 0.5 seconds, one can use either of the following statements:

    ```

      interval_data = data_array.get_slice([250], [500], mode=DataSliceMode.Index)[:] interval_data = data_array.get_slice([0.25],[0.25], mode=DataSliceMode.Data)[:]

    ```

    Note: The extents are not the end positions but the extent of the slice! In the case of regularly sampled dimensions, reaching beyond the start of end of the respective dimension will cause an exception. For irregularly sampled data no exception will be raised but the returned DataView might be invalid and empty.

    Parameters

      - positions (list length must match dimensionality of the data.) – Specifies the start of the data slice. List of either indices or data positions depending on the DataSliceMode.

      - extents (list, defaults to None) – Specifies the extents of the slice for each dimension.

      - mode (nixio.DataSliceMode) – Specifies how positions and extents are interpreted, they are either treated as indices (DataSliceMode.Index) or as positions in data coordinates (DataSliceMode.Data), Defaults to nixio.DataSliceMode.Index.

    Raises

      nixio.IncompatibleDimensions: if length of positions or, if given, extents does not match the rank of the data.

    Raises

      ValueError: if an invalid slice mode is given

    Returns

      A nixio.DataView object

    Return type

      nixio.DataView

  iter_dimensions()

    1-based index dimension iterator. The method returns a generator which returns the index starting from one and the dimensions.

  property label

    The label of the DataArray. The label corresponds to the label of the x-axis of a plot. This is a read-write property and can be set to None.

    Type

      str

  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  property polynom_coefficients

    The polynomial coefficients for the calibration. By default this is set to a {0.0, 1.0} for a linear calibration with zero offset. This is a read-write property and can be set to None

    Return type

      list of float

  property sources

    A property containing all Sources referenced by the DataArray. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.

  property unit

    The unit of the values stored in the DataArray. This is a read-write property and can be set to None.

    Type

      str

class nixio.DataFrame(nixfile, nixparent, h5group)

  Bases: `nixio.entity.Entity`, `nixio.data_set.DataSet`

  append_column(column, name, datatype=None)

    Append a new column to the DataFrame In case of string, it will be better to set explicitly the datatype.

    Parameters

      - column (array-like data) – The new column

      - name (str) – The name of new column

      - datatype (nixio.DataType) – The DataType of new column

  append_rows(data)

    Append a new row to the DataFrame. The data supplied must be iterable.

    Parameters

      data (array-like data) – The new row

  property column_names

    The dtype is the list of names of all columns in the DatFrame. This is a read only property.

    Type

      list of str

  property columns

    The dtype is the list of names and data types of all columns in the DatFrame. This is a read only property.

    Type

      list of tuples

  classmethod create_new(nixfile, nixparent, h5parent, name, type_, shape, col_dtype, compression)
  property df_shape

    The df_shape is the shape of the DataFrame in (number of rows, number of columns) format. This is a read only property.

    Type

      tuple

  property dtype

    The dtype is the list of DataTypes of all columns in the DatFrame. This is a read only property.

    Type

      list of DataType

  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  print_table(row_sl=None, col_sl=None)

    Print the whole DataFrame as a table

    Parameters

      - row_sl (slice or iterable of int) – Rows to be printed; None for printing all rows

      - col_sl (slice or iterable of int) – Columns to be printed; None for printing all columns

  read_cell(position=None, col_name=None, row_idx=None)

    Read a cell in the DataFrame

    Parameters

      - position (tuple or list or array with length 2) – Position of the targeted cell

      - col_name (str) – The column name in which the targeted cell belongs to

      - row_idx (list of int) – A length 1 list that specify on which row the targeted cell is located

  read_columns(index=None, name=None, slc=None, group_by_cols=False)

    Read one or multiple (part of) column(s) in the DataFrame

    Parameters

      - index (list of int) – Index of column(s) to be returned

      - name (list of str) – Name of column(s) to be returned

      - slc (slice) – The part of each column to be returned

      - group_by_cols (bool) – True for group return values by columns, False for group by rows. Only applicable for reading multiple columns

  read_rows(index)

    Read one or multiple row(s) in the DataFrame

    Parameters

      index (list of int) – Index of row(s) to be returned

  row_count()

    Return the total number of rows

  property units

    The unit of the values stored in the DataFrame. This is a read-write property and can be set to None.

    Type

      array of str

  write_cell(cell, position=None, col_name=None, row_idx=None)

    Overwrite a cell in the DataFrame

    Parameters

      - cell (same type as the specified column) – The new cell

      - position (tuple or list or array with length 2) – Position of the targeted cell

      - col_name (str) – The column name in which the targeted cell belongs to

      - row_idx (list of int) – A length 1 list that specify on which row the targeted cell is located

  write_column(column, index=None, name=None)

    Overwrite an existing column. Either index or name of the column should be provided.

    Parameters

      - column (array-like data) – The new column

      - index (string) – The index of the column that is written to

      - name (str) – The name of the column that is written to

  write_rows(rows, index)

    Overwrite one or multiple existing row(s)

    Parameters

      - rows ((nested) array-like data) – The new rows(s) and their data

      - index (list of int) – Index of rows(s) to be overwritten

  write_to_csv(filename, mode='w')

    Export the whole DataFrame to a CSV file

    Parameters

      - filename (str) – The resulted/ targeted CSV file to write to/ create

      - mode (str) – The column name in which the targeted cell belongs to

class nixio.DataSliceMode(value)

  Bases: `enum.Enum`

  An enumeration.

  Data = 2
  Index = 1

class nixio.DataType

  Bases: `object`

  Bool

    alias of `numpy.bool_`

  Double

    alias of `numpy.float64`

  Float

    alias of `numpy.float32`

  FloatTypes = (<class 'numpy.float32'>, <class 'numpy.float64'>)
  Int16

    alias of `numpy.int16`

  Int32

    alias of `numpy.int32`

  Int64

    alias of `numpy.int64`

  Int8

    alias of `numpy.int8`

  IntTypes = (<class 'numpy.int8'>, <class 'numpy.int16'>, <class 'numpy.int32'>, <class 'numpy.int64'>, <class 'numpy.uint8'>, <class 'numpy.uint16'>, <class 'numpy.uint32'>, <class 'numpy.uint64'>)
  String

    alias of `numpy.str_`

  UInt16

    alias of `numpy.uint16`

  UInt32

    alias of `numpy.uint32`

  UInt64

    alias of `numpy.uint64`

  UInt8

    alias of `numpy.uint8`

  classmethod get_dtype(value)
  classmethod is_numeric_dtype(dtype)

class nixio.DimensionType(value)

  Bases: `enum.Enum`

  An enumeration.

  Range = 'range'
  Sample = 'sample'
  Set = 'set'

class nixio.Feature(nixfile, nixparent, h5group)

  Bases: `object`

  classmethod create_new(nixfile, nixparent, h5parent, data, link_type)
  property created_at

    The creation time of the entity. This is a read-only property. Use force_created_at in order to change the creation time.

    Return type

      int

  property data
  property file
  property id
  property link_type
  property updated_at

    The time of the last update of the entity. This is a read-only property. Use force_updated_at in order to change the update time.

    Return type

      int

class nixio.File(path, mode='a', compression=<Compression.Auto: 'Auto'>, auto_update_timestamps=True)

  Bases: `object`

  property auto_update_timestamps

    If enabled, automatically updates the ‘updated_at’ attribute when an object’s data or attributes are changed.

    Type

      bool

  property blocks

    A property containing all blocks of a file. Blocks can be obtained by their name, id or index. Blocks can be deleted from the list, when a block is deleted all its content (data arrays, tags and sources) will be also deleted from the file. Adding new Block is done via the create_block method of File. This is a read-only attribute.

  close()

    Closes an open file.

  copy_section(obj, children=True, keep_id=True, name='')

    Copy a section to the file.

    Parameters

      - obj (nixio.Section) – The Section to be copied

      - children (bool) – Specify if the copy should be recursive

      - keep_id (bool) – Specify if the id should be kept

      - name (str) – Name of copied section, Default is name of source section

    Returns

      The copied section

    Return type

      nixio.Section

  create_block(name='', type_='', compression=<Compression.Auto: 'Auto'>, copy_from=None, keep_copy_id=True)

    Create a new block inside the file.

    Parameters

      - name (str) – The name of the block to create.

      - type (str) – The type of the block.

      - compression – No, DeflateNormal, Auto (default: Auto)

      - copy_from (nixio.Block) – The Block to be copied, None in normal mode

      - keep_copy_id (bool) – Specify if the id should be copied in copy mode

    Returns

      The newly created block.

    Return type

      nixio.Block

  create_section(name, type_='undefined', oid=None)

    Create a new metadata section inside the file.

    Parameters

      - name (str) – The name of the section to create.

      - type (str) – The type of the section.

      - oid (str) – object id, UUID string as specified in RFC 4122. If no id is provided, an id will be generated and assigned.

    Returns

      The newly created section.

    Return type

      nixio.Section

  property created_at

    The creation time of the file. This is a read-only property. Use force_created_at in order to change the creation time.

    Return type

      int

  find_sections(filtr=<function File.<lambda>>, limit=None)

    Get all sections and their child sections recursively.

    This method traverses the trees of all sections. The traversal is accomplished via breadth first and can be limited in depth. On each node or section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.

    Parameters

      - filtr (function) – A filter function

      - limit (int) – The maximum depth of traversal

    Returns

      A list containing the matching sections.

    Return type

      list of nixio.Section

  flush()
  force_created_at(time=None)

    Sets the creation time created_at to the given time (default: current time).

    Parameters

      time (int) – The time to set

  force_updated_at(time=None)

    Sets the update time updated_at to the given time. (default: current time)

    Parameters

      time (int) – The time to set (default: now)

  property format

    The format of the file. This read only property should always have the value ‘nix’.

    Type

      str

  property id
  is_open()

    Checks whether a file is open or closed.

    Returns

      True if the file is open, False otherwise.

    Return type

      bool

  classmethod open(path, mode='a', compression=<Compression.Auto: 'Auto'>, backend=None, auto_update_timestamps=True)

    Open a NIX file, or create it if it does not exist.

    Parameters

      - path – Path to file

      - mode – FileMode ReadOnly, ReadWrite, or Overwrite. (default: ReadWrite)

      - compression – No, DeflateNormal, Auto (default: Auto)

      - auto_update_timestamps – Enable/disable automatic updating of ‘updated_at’ timestamp. (default: True)

    Returns

      nixio.File object

  pprint(indent=2, max_length=120, extra=True, max_depth=3)

    Pretty Printing the Data and MetaData Tree of the whole File

    Parameters

      - indent (int) – The length of one indentation space

      - max_length (int) – Maximum length of each line of output

      - extra (bool) – True to print extra information of Entities

      - max_depth (int) – Maximum recursion being printed in MetaData tree

  property sections

    A property containing all root Sections of a file. Specific root Sections can be obtained by their name, id or index. Sections can be deleted from this list. Notice: when a section is deleted all its child section and properties will be removed too. Adding a new Section is done via the crate_section method of File. This is a read-only property.

  property updated_at

    The time of the last update of the file. This is a read-only property. Use force_updated_at in order to change the update time.

    Return type

      int

  validate()
  property version

    The file format version.

    Type

      tuple

class nixio.FileMode

  Bases: `object`

  Overwrite = 'w'
  ReadOnly = 'r'
  ReadWrite = 'a'

class nixio.Group(nixfile, nixparent, h5group)

  Bases: `nixio.entity.Entity`

  classmethod create_new(nixfile, nixparent, h5parent, name, type_)
  property data_arrays

    A property containing all data arrays referenced by the group. Referenced data arrays can be obtained by index or their id. References can be removed from the list, removing a referenced DataArray will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.

  property data_frames

    A property containing all data frames referenced by the group. Referenced data frames can be obtained by index or their id. References can be removed from the list, removing a referenced DataFrame will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.

  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  property multi_tags

    A property containing all MultiTags referenced by the group. MultiTags can be obtained by index or their id. MultiTags can be removed from the list, removing a referenced MultiTag will not remove it from the file. New MultiTags can be added using the append method of the list. This is a read only attribute.

  property sources

    A property containing all Sources referenced by the Group. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.

  property tags

    A property containing all tags referenced by the group. Tags can be obtained by index or their id. Tags can be removed from the list, removing a referenced Tag will not remove it from the file. New Tags can be added using the append method of the list. This is a read only attribute.

class nixio.IndexMode(value)

  Bases: `enum.Enum`

  IndexMode is used to define the behaviour of the index_of() methods.

  GEQ = 'geq'
  GreaterOrEqual = 'geq'
  LEQ = 'leq'
  Less = 'less'
  LessOrEqual = 'leq'

class nixio.LinkType(value)

  Bases: `enum.Enum`

  An enumeration.

  Indexed = 'indexed'
  Tagged = 'tagged'
  Untagged = 'untagged'

class nixio.MultiTag(nixfile, nixparent, h5group)

  Bases: `nixio.tag.BaseTag`

  classmethod create_new(nixfile, nixparent, h5parent, name, type_, positions)
  property extents

    The extents defined by the tag. This is an optional read-write property and may be set to None.

    Type

      nixio.DataArray or None

  feature_data(posidx, featidx, stop_rule=<SliceMode.Exclusive: 'exclusive'>)
  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  property positions

    The positions defined by the tag. This is a read-write property.

    Type

      nixio.DataArray

  property references

    A property containing all data arrays referenced by the tag. Referenced data arrays can be obtained by index or their id. References can be removed from the list, removing a referenced DataArray will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.

    Type

      nixio.LinkContainer of nixio.DataArray

  retrieve_data(posidx, refidx)
  retrieve_feature_data(posidx, featidx)
  property sources

    A property containing all Sources referenced by the MultiTag. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.

  tagged_data(posidx, refidx, stop_rule=<SliceMode.Exclusive: 'exclusive'>)

class nixio.OdmlType(value)

  Bases: `enum.Enum`

  OdmlType provides all types currently supported by the odML data format. It provides additional information about the nature of the values of an odML Property.

  Boolean = 'boolean'
  Date = 'date'
  Datetime = 'datetime'
  Float = 'float'
  Int = 'int'
  Person = 'person'
  String = 'string'
  Text = 'text'
  Time = 'time'
  URL = 'url'
  compatible(value)

    compatible returns True or False depending on whether a passed value can be mapped to an OdmlType or not.

    Parameters

      value – Any single value

    Returns

      Boolean

  classmethod get_odml_type(dtype)

    get_odml_type returns the appropriate OdmlType for a handed in nix value DataType.

    Parameters

      dtype – nix DataType

    Returns

      OdmlType

class nixio.Property(nixfile, nixparent, h5dataset)

  Bases: `nixio.entity.Entity`

  An odML Property

  classmethod create_new(nixfile, nixparent, h5parent, name, dtype, shape=None, oid=None)
  property data_type
  property definition

    The definition of the entity. The definition can contain a textual description of the entity. This is an optional read-write property, and can be None if no definition is available.

    Type

      str

  delete_values()
  property dependency
  property dependency_value
  extend_values(data)

    Extends values to existing data. Suitable when new data is nested or original data is long.

  property name

    The name of an entity. The name serves as a human readable identifier. This is a read-only property; entities cannot be renamed.

    Type

      str

  property odml_type
  pprint(indent=2, max_length=80, current_depth=- 1)

    Pretty print method. Method is called in Section.pprint()

  property reference
  property uncertainty
  property unit
  property value_origin
  property values

class nixio.RangeDimension(data_array, index)

  Bases: `nixio.dimensions.Dimension`

  axis(count, start=0)

    Get an axis as defined by this range dimension.

    Parameters

      - count – A positive integer specifying the length of the axis (no of points).

      - start – positive integer, indicates the starting tick.

    Returns

      The created axis

    Return type

      list

  classmethod create_new(data_array, index, ticks)
  index_of(position, mode=<IndexMode.LessOrEqual: 'leq'>, ticks=None)

    Returns the index of a certain position in the dimension. Raises IndexError if the position is out of bounds (depending on mode).

    Parameters

      - position – The position.

      - mode – The IndexMode to use (default LessOrEqual). The default value (LessOrEqual) will return the index of the position that matches a tick if it matches a dimension tick exactly. If it does not match a tick, the previous index is returned. If the mode is Less, the previous index of the matching tick is always returned. If the mode is GreaterOrEqual and the position does not match a tick exactly, the next index is returned.

      - ticks (iterable) – Optional, the ticks stored in this dimension. If not passed as argument, they are (re)read from file.

    Returns

      The matching index

    Return type

      int

  property is_alias

    In versions < 1.5 a RangeDimension that was referring to the DataArray it describes was called an AliasRangeDimension. This has been made more flexible by allowing to link to any DataArray or DataFrame. For downward compatibility this method has been re-introduced in 1.5.1.

    Returns

      True, if this dimension links to a DataArray, False otherwise

    Return type

      bool

  property label
  link_data_array(data_array, index)
  link_data_frame(data_frame, index)
  range_indices(start_position, end_position, mode=<SliceMode.Exclusive: 'exclusive'>)

    Returns the start and end indices in this dimension that are matching to the given start and end position.

    Parameters

      - start_position (float) – the start position of the range.

      - end_position (float) – the end position of the range.

      - mode (nixio.SliceMode) – The nixio.SliceMode. Defaults to nixio.SliceMode.Exclusive, i.e. the end position is not part of the range.

    Returns

      The respective start and end indices. None, if range is empty

    Return type

      tuple of int

    Raises

      ValueError if invalid mode is given

    Raises

      Index Error if start position is greater than end position.

  tick_at(index)

    Returns the tick at the given index. Will throw an Exception if the index is out of bounds.

    Parameters

      index – The index.

    Returns

      The corresponding position.

    Return type

      double

  property ticks
  property unit

class nixio.S(section_type, section=None)

  Bases: `object`

class nixio.SampledDimension(data_array, index)

  Bases: `nixio.dimensions.Dimension`

  axis(count, start=None, start_position=None)

    Get an axis as defined by this nixio.SampledDimension. It either starts at the offset of the dimension, a number of sample points later, or at a given position. The latter must not be less than the offset. If start and start_position are given, start takes precedence.

    Parameters

      - count (int) – A positive integer specifying the length of the axis (no of samples).

      - start (int) – positive integer, indicates the starting sample. Defaults to None. Precedes over the start_position.

      - start_position (double) – The start position of the axis. Defaults to None.

    Raises

      ValueError if start is negative or if the start_position is given and is less than offset.

    Returns

      The created axis

    Return type

      tuple

  classmethod create_new(data_array, index, sample)
  index_of(position, mode=<IndexMode.LessOrEqual: 'leq'>)

    Returns the index of a certain position in the dimension. Raises IndexError if the position is out of bounds (depending on mode).

    Parameters

      - position – The position.

      - mode – The IndexMode to use (default LessOrEqual). The default value (LessOrEqual) will return the index of the position calculated based on the dimension offset and sampling_interval if it matches a dimension tick exactly. If it does not match a tick, the previous index is returned. If the mode is Less, the previous index of the calculated position is always returned. If the mode is GreaterOrEqual and the calculated position does not match a tick exactly, the next index is returned.

    Returns

      The matching index.

    Return type

      int

  link_data_array(*_)
  link_data_frame(*_)
  property offset
  position_at(index)

    Returns the position corresponding to a given index.

    Parameters

      index – A positive integer.

    Returns

      The position matching to the index.

    Return type

      float

  range_indices(start_position, end_position, mode=<SliceMode.Exclusive: 'exclusive'>)

    Returns the start and end indices in this dimension that are matching to the given start and end position.

    Parameters

      - start_position (float) – the start position of the range.

      - end_position (float) – the end position of the range.

      - mode (nixio.SliceMode) – The nixio.SliceMode. Defaults to nixio.SliceMode.Exclusive, i.e. the end position is not part of the range.

    Returns

      The respective start and end indices. None, if the range is empty!

    Return type

      tuple of int

    Raises

      ValueError if invalid mode is given

    Raises

      Index Error if start position is greater than end position.

  property sampling_interval
  property unit

class nixio.Section(nixfile, nixparent, h5group)

  Bases: `nixio.entity.Entity`

  copy_section(obj, children=True, keep_id=True, name='')

    Copy a section to the section.

    Parameters

      - obj (nixio.Section) – The Section to be copied

      - children (bool) – Specify if the copy should be recursive

      - keep_id (bool) – Specify if the id should be kept

      - name (str) – Name of copied section, Default is name of source section

    Returns

      The copied section

    Return type

      nixio.Section

  classmethod create_new(nixfile, nixparent, h5parent, name, type_, oid=None)
  create_property(name='', values_or_dtype=0, oid=None, copy_from=None, keep_copy_id=True)

    Add a new property to the section.

    Parameters

      - name (str) – The name of the property to create/copy.

      - values_or_dtype (list of values or a nixio.DataType) – The values of the property or a valid DataType.

      - oid (str) – object id, UUID string as specified in RFC 4122. If no id is provided, an id will be generated and assigned.

      - copy_from (nixio.Property) – The Property to be copied, None in normal mode

      - keep_copy_id (bool) – Specify if the id should be copied in copy mode

    Returns

      The newly created property.

    Return type

      nixio.Property

  create_section(name, type_='undefined', oid=None)

    Creates a new subsection that is a child of this section entity.

    Parameters

      - name (str) – The name of the section to create.

      - type (str) – The type of the section.

      - oid (str) – object id, UUID string as specified in RFC 4122. If no id is provided, an id will be generated and assigned.

    Returns

      The newly created section.

    Return type

      nixio.Section

  find_related(filtr=<function Section.<lambda>>)

    Get all related sections of this section.

    The result can be filtered. On each related section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.

    Parameters

      filtr (function) – A filter function

    Returns

      A list containing the matching related sections.

    Return type

      list of nixio.Section

  find_sections(filtr=<function Section.<lambda>>, limit=None)

    Get all child sections recursively. This method traverses the trees of all sections. The traversal is accomplished via breadth first and can be limited in depth. On each node or section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.

    Parameters

      - filtr (function) – A filter function

      - limit (int) – The maximum depth of traversal

    Returns

      A list containing the matching sections.

    Return type

      list of nixio.Section

  inherited_properties()
  items()
  property link

    Link to another section. If a section is linked to another section, the linking section inherits all properties from the target section. This is an optional read-write property and may be set to None.

    Type

      nixio.Section

  property parent

    The parent section. This is a read-only property. For root sections this property is always None.

    Accessing this property can be slow when the metadata tree is large.

    Type

      nixio.Section

  pprint(indent=2, max_depth=- 1, max_length=80, current_depth=0)

    Pretty print method.

    Parameters

      - indent (int) – The number of indentation spaces per recursion

      - max_depth (int) – The maximum times of recursion, -1 for the full depth

      - max_length (int) – The maximum length of each line of output

      - current_depth (int) – The current times of recursion

  property props

    A property containing all Property entities associated with the section. Properties can be accessed by name, index, or id. Properties can be deleted from the list. Adding new Properties is done using the create_property method. This is a read-only attribute.

    Type

      Container of nixio.Property

  property reference
  property referring_blocks
  property referring_data_arrays
  property referring_groups
  property referring_multi_tags
  property referring_objects
  property referring_sources
  property referring_tags
  property repository

    URL to the terminology repository the section is associated with. This is an optional read-write property and may be set to None.

    Type

      str

  property sections

    A property providing all child Sections of a Section. Child sections can be accessed by name, index, or id. Sections can also be deleted: if a Section is deleted, all its properties and child Sections are removed from the file too. Adding new Sections is achieved using the create_section method. This is a read-only attribute.

    Type

      Container of nixio.Section

class nixio.SetDimension(data_array, index)

  Bases: `nixio.dimensions.Dimension`

  classmethod create_new(data_array, index)
  index_of(position, mode=<IndexMode.LessOrEqual: 'leq'>, dim_labels=None)

    Returns the index of a certain position in the dimension. Raises IndexError if the position is out of bounds (depending on mode and number of labels).

    Parameters

      - position – The position.

      - mode – The IndexMode to use (default LessOrEqual). The modes LessOrEqual and GreaterOrEqual will return the integer representation of the position if it is equal to the nearest integer. If the position is not an integer (or is not equal to the nearest integer), then the value is rounded down (for LessOrEqual) or rounded up (for GreaterOrEqual). If the mode is Less, the previous integer is always returned.

      - dim_labels (iterable) – The labels of this dimension, if None (default) the labels will be read from file.

    Returns

      The matching index

    Return type

      int

  property labels
  range_indices(start_position, end_position, mode=<SliceMode.Exclusive: 'exclusive'>)

    Returns the start and end indices in this dimension that are matching to the given start and end position.

    Parameters

      - start_position (float) – the start position of the range.

      - end_position (float) – the end position of the range.

      - mode (nixio.SliceMode) – The nixio.SliceMode. Defaults to nixio.SliceMode.Exclusive, i.e. the end position is not part of the range.

    Returns

      The respective start and end indices. None, if the range is empty

    Return type

      tuple of int

    Raises

      ValueError if invalid mode is given

    Raises

      Index Error if start position is greater than end position.

class nixio.SliceMode(value)

  Bases: `enum.Enum`

  An enumeration.

  Exclusive = 'exclusive'
  Inclusive = 'inclusive'
  to_index_mode()

class nixio.Source(nixfile, nixparent, h5group)

  Bases: `nixio.entity.Entity`

  classmethod create_new(nixfile, nixparent, h5parent, name, type_)
  create_source(name, type_)

    Create a new source as a child of the current Source.

    Parameters

      - name (str) – The name of the source to create.

      - type (str) – The type of the source.

    Returns

      The newly created source.

    Return type

      nixio.Source

  find_sources(filtr=<function Source.<lambda>>, limit=None)

    Get all child sources of this source recursively.

    This method traverses the tree of all sources. The traversal is accomplished via breadth first and can be limited in depth. On each node or source a filter is applied. If the filter returns true the respective source will be added to the result list. By default a filter is used that accepts all sources.

    Parameters

      - filtr (function) – A filter function

      - limit (int) – The maximum depth of traversal

    Returns

      A list containing the matching sources.

    Return type

      list of nixio.Source

  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  property parent_block

    Returns the block this source is contained in.

    Returns

      the Block containing this source

    Return type

      nixio.Block

  property parent_source

    Get the parent source of this source. If this source is at the root, None will be returned

    Returns

      the parent source

    Return type

      Source or None

  property referring_data_arrays

    Returns all DataArray entities linking to this source.

    Returns

      all DataArrays referring to this source.

    Return type

      list

  property referring_multi_tags

    Returns all MultiTag entities linking to this source.

    Returns

      all MultiTags referring to this source.

    Return type

      list

  property referring_objects

    Returns the list of entities that link to this source.

    Returns

      all objects referring to this source.

    Return type

      list

  property referring_tags

    Returns all Tag entities linking to this source.

    Returns

      all Tags referring to this source.

    Return type

      list

  property sources

    A property containing child sources of a Source. Sources can be obtained via their name, index, id. Sources can be deleted from the list. Adding sources is done using the Blocks create_source method. This is a read only attribute.

class nixio.Tag(nixfile, nixparent, h5group)

  Bases: `nixio.tag.BaseTag`

  classmethod create_new(nixfile, nixparent, h5parent, name, type_, position)
  property extent

    The extent defined by the tag. This is an optional read-write property and may be set to None.

    Type

      list of float

  feature_data(featidx, stop_rule=<SliceMode.Exclusive: 'exclusive'>)
  property metadata

    Associated metadata of the entity. Sections attached to the entity via this attribute can provide additional annotations. This is an optional read-write property, and can be None if no metadata is available.

    Type

      nixio.Section

  property position

    The position defined by the tag. This is a read-write property.

    Type

      list of float

  property references

    A property containing all data arrays referenced by the tag. Referenced data arrays can be obtained by index or their id. References can be removed from the list, removing a referenced DataArray will not remove it from the file. New references can be added using the append method of the list. This is a read only attribute.

    Type

      Container of nixio.DataArray

  retrieve_data(refidx)
  retrieve_feature_data(featidx)
  property sources

    A property containing all Sources referenced by the Tag. Sources can be obtained by index or their id. Sources can be removed from the list, but removing a referenced Source will not remove it from the file. New Sources can be added using the append method of the list. This is a read only attribute.

  tagged_data(refidx, stop_rule=<SliceMode.Exclusive: 'exclusive'>)