Skip to main content
`Ctrl`+`K`

# ada.data_containers.generic

## Classes

`GenericData` | A class for storing and handling actigraphic data, both raw and epoched. Generic format compatible with various manufacturers and algorithms.

## Module Contents

class GenericData(data, metadata, fs, channel_names, epoching_method_metadata=None, scoring_method_metadata=None)

  A class for storing and handling actigraphic data, both raw and epoched. Generic format compatible with various manufacturers and algorithms.

  Parameters:

    - data (numpy.ndarray)

    - metadata (dict)

    - fs (float)

    - channel_names (list)

    - epoching_method_metadata (dict | None)

    - scoring_method_metadata (dict | None)

  cut_by_dates(start_date, end_date)

    Create new object with the data cut by given dates.

    Parameters:

      - start_date (str) – ISO-formated date of outputa data beginning.

      - end_date (str | None) – ISO-formated date of output data end. If None, last sample of output data will be last sample of input data.

    Returns:

      Object containing the cutted data of the same type as input data.

    Return type:

      _ActiData

  cut_by_samples(start_sample, end_sample)

    Create new object with the data cut by given indexes.

    Parameters:

      - start_sample (int) – First sample of output data.

      - end_sample (int) – Sample after the last sample of output data.

    Returns:

      Object containing the cutted data.

    Return type:

      GenericData

  cut_by_timestamp(start_ts, end_ts)

    Create new object with the data cut by given timestamps.

    Parameters:

      - start_ts (float) – Unix timestamp of output data beginning.

      - end_ts (float | None) – Unix timestamp of output data end. If None, last sample of output data will be last sample of input data.

    Returns:

      Object containing the cutted data.

    Return type:

      GenericData

  export(path)

    Exports object data to the generic format. All metadata are preserved in the file.

    Parameters:

      path (str) – Path to the .ada file.

  static from_nongeneric(acti_data)

    Converts any other actigraphic data object usable to the generic format. Usefull for standarization.

    Parameters:

      acti_data (_ActiData) – Actigraphic data object, either Raw or Epoched.

    Raises:

      ValueError – If the provided object is not actigraphic data.

    Returns:

      GenericData object containing the data from original object.

    Return type:

      GenericData

  static load_file(path)

    Loading file saved in the generic format provided by this package.

    Parameters:

      path (str) – Path to the .ada file.

    Returns:

      Object containing data.

    Return type:

      GenericData

  static preview_metadata(path)

    Preview of metadata without loading the file.

    Parameters:

      path (str) – Path to the file

    Raises:

      ValueError – Wrong format

    Returns:

      Metadata and channel names.

    Return type:

      tuple[dict, list[str]]

  trim(time_from_start, time_from_end)

    Removes points from the recording beginning and end by given times.

    Parameters:

      - time_from_start (str | None) – Time in HH:MM:SS.sss from the recording beginning. Microseconds can be ommited. If None, data is returned from first sample.

      - time_from_end (str | None) – Time in HH:MM:SS.sss from the recording end. Microseconds can be ommited. If None, data is returned to the end sample.

    Returns:

      Trimmed data container of the same type as input one.

    Return type:

      _ActiData

  ActiData
  property channel_names: list[str]

    List of names for the channels stored in the data field.

    Return type:

      list[str]

  property data: numpy.ndarray

    Actigraphic data in format (n_channels, n_samples).

    Return type:

      numpy.ndarray

  property dynamic_range: float

    Dynamic range (in g) of the digital converter.

    Return type:

      float

  property epoching_method_metadata: dict | None

    Metadata asssociated with the epoching method and its parameters. Returns None if data is not epoched.

    Return type:

      dict | None

  property first_sample_timestamp: float

    Unix timestamp of first sample.

    Return type:

      float

  property fs: float

    Sampling frequency of the data (not the same as recording frequency for epoched data).

    Return type:

      float

  property id: str

    ID of the recording set during device configuration.

    Return type:

      str

  property last_sample_timestamp: float

    Unix timestamp of last sample.

    Return type:

      float

  property metadata: dict

    Metadata associated with the raw recording and the device.

    Return type:

      dict

  property scoring_method_metadata: dict | None

    Metadata asssociated with the scoring algorithm and its parameters. Returns None if data is not scored.

    Return type:

      dict | None

  property stationary_variance: float

    Variance of actigraph laying still (transducer noise).

    Return type:

      float

  property timestamp: numpy.ndarray

    Unix timestamp of the data, relative to the recording beginning.

    Return type:

      numpy.ndarray

  property to_score: numpy.ndarray

    Data to be scored by scoring algorithms.

    Return type:

      numpy.ndarray

  property x: numpy.ndarray

    Data from x axis, raises Error if data is not 3-axial.

    Return type:

      numpy.ndarray

  property y: numpy.ndarray

    Data from y axis, raises Error if data is not 3-axial.

    Return type:

      numpy.ndarray

  property z: numpy.ndarray

    Data from z axis, raises Error if data is not 3-axial.

    Return type:

      numpy.ndarray