aqnwb 0.1.0
Loading...
Searching...
No Matches
AQNWB::NWB::TimeSeries Class Reference

General purpose time series. More...

#include <TimeSeries.hpp>

Inheritance diagram for AQNWB::NWB::TimeSeries:
[legend]
Collaboration diagram for AQNWB::NWB::TimeSeries:
[legend]

Public Types

enum  ContinuityType { Continuous = 0 , Instantaneous = 1 , Step = 2 , Undefined = -1 }
 

Public Member Functions

 TimeSeries (const std::string &path, std::shared_ptr< IO::BaseIO > io)
 Constructor.
 
 ~TimeSeries ()
 Destructor.
 
Status writeData (const std::vector< SizeType > &dataShape, const std::vector< SizeType > &positionOffset, const void *dataInput, const void *timestampsInput=nullptr, const void *controlInput=nullptr)
 Writes a timeseries data block to the file.
 
void initialize (const IO::ArrayDataSetConfig &dataConfig, const std::string &unit, const std::string &description="no description", const std::string &comments="no comments", const float &conversion=1.0f, const float &resolution=-1.0f, const float &offset=0.0f, const ContinuityType &continuity=ContinuityType::Undefined, const double &startingTime=-1.0, const float &startingTimeRate=1.0f, const std::vector< std::string > &controlDescription={})
 Initializes the TimeSeries by creating NWB related attributes and writing the description and comment metadata.
 
template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readDescription () const
 
template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readComments () const
 
template<typename VTYPE = std::any>
std::unique_ptr< IO::ReadDataWrapper< DatasetField, VTYPE > > readData () const
 
template<typename VTYPE = float>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readDataConversion () const
 
template<typename VTYPE = float>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readDataOffset () const
 
template<typename VTYPE = float>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readDataResolution () const
 
template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readDataUnit () const
 
template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readDataContinuity () const
 
template<typename VTYPE = double>
std::unique_ptr< IO::ReadDataWrapper< DatasetField, VTYPE > > readStartingTime () const
 
template<typename VTYPE = float>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readStartingTimeRate () const
 
template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readStartingTimeUnit () const
 
template<typename VTYPE = double>
std::unique_ptr< IO::ReadDataWrapper< DatasetField, VTYPE > > readTimestamps () const
 
template<typename VTYPE = int>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readTimestampsInterval () const
 
template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readTimestampsUnit () const
 
template<typename VTYPE = uint8_t>
std::unique_ptr< IO::ReadDataWrapper< DatasetField, VTYPE > > readControl () const
 
template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< DatasetField, VTYPE > > readControlDescription () const
 
- Public Member Functions inherited from AQNWB::NWB::Container
 Container (const std::string &path, std::shared_ptr< IO::BaseIO > io)
 Constructor.
 
virtual ~Container ()
 Destructor.
 
Status initialize ()
 Initialize the container.
 
template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readNeurodataType () const
 
template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readNamespace () const
 
- Public Member Functions inherited from AQNWB::NWB::RegisteredType
 RegisteredType (const std::string &path, std::shared_ptr< IO::BaseIO > io)
 Constructor.
 
virtual ~RegisteredType ()
 Destructor.
 
std::string getPath () const
 Gets the path of the registered type.
 
std::string getName () const
 Get the name of the object.
 
std::shared_ptr< IO::BaseIOgetIO () const
 Get a shared pointer to the IO object.
 
virtual std::string getTypeName () const
 Get the name of the class type.
 
virtual std::string getNamespace () const
 Get the schema namespace of the class type.
 
std::string getFullTypeName () const
 Get the full name of the type, i.e., namespace::typename
 
template<StorageObjectType SOT, typename VTYPE, typename std::enable_if< Types::IsDataStorageObjectType< SOT >::value, int >::type = 0>
std::unique_ptr< IO::ReadDataWrapper< SOT, VTYPE > > readField (const std::string &fieldPath) const
 Support reading of arbitrary fields by their relative path.
 
std::shared_ptr< AQNWB::NWB::RegisteredTypereadField (const std::string &fieldPath) const
 Read a field that is itself a RegisteredType.
 
virtual std::unordered_map< std::string, std::string > findOwnedTypes (const std::unordered_set< std::string > &types={}, const IO::SearchMode &search_mode=IO::SearchMode::STOP_ON_TYPE) const
 Find all typed objects that are owned by this object, i.e., objects that have a neurodata_type and namespace attribute and have this object as there closest parent with an assigned type.
 

Public Attributes

std::unique_ptr< IO::BaseRecordingDatadata
 Pointer to data values.
 
std::unique_ptr< IO::BaseRecordingDatatimestamps
 Pointer to timestamp values. This may be a nullptr if starting_time is used.
 
std::unique_ptr< IO::BaseRecordingDatastarting_time
 Pointer to starting_time values. This may be a nullptr if timestamps are used.
 
std::unique_ptr< IO::BaseRecordingDatacontrol
 Pointer to control values. This may be a nullptr if useControl is false.
 
std::unique_ptr< IO::BaseRecordingDatacontrol_description
 Pointer to control_description values. This may be a nullptr if useControl is false.
 
IO::BaseDataType m_dataType
 Data type of the data.
 
IO::BaseDataType timestampsType = IO::BaseDataType::F64
 Data type of the timestamps (float64).
 
IO::BaseDataType controlType = IO::BaseDataType::U8
 Data type of the control (uint8).
 

Static Public Attributes

static std::map< ContinuityType, std::string > ContinuityTypeNames
 String names corresponding to the ContinuityType enum.
 

Private Member Functions

Status createTimestampsAttributes (const std::string &path)
 Convenience function for creating timestamp related attributes.
 
Status createDataAttributes (const std::string &path, const float &conversion, const float &resolution, const float &offset, const std::string &unit, const ContinuityType &continuity)
 Convenience function for creating data related attributes.
 

Additional Inherited Members

- Static Public Member Functions inherited from AQNWB::NWB::RegisteredType
static std::unordered_set< std::string > & getRegistry ()
 Get the registry of subclass names.
 
static std::unordered_map< std::string, std::pair< std::function< std::unique_ptr< RegisteredType >(const std::string &, std::shared_ptr< IO::BaseIO >)>, std::pair< std::string, std::string > > > & getFactoryMap ()
 Get the factory map for creating instances of subclasses.
 
static std::shared_ptr< RegisteredTypecreate (const std::string &fullClassName, const std::string &path, std::shared_ptr< IO::BaseIO > io, bool fallbackToBase=false)
 Create an instance of a registered subclass by name.
 
static std::shared_ptr< AQNWB::NWB::RegisteredTypecreate (const std::string &path, std::shared_ptr< IO::BaseIO > io, bool fallbackToBase=false)
 Factory method to create an instance of a subclass of RegisteredType from file.
 
template<typename T>
static std::shared_ptr< T > create (const std::string &path, std::shared_ptr< IO::BaseIO > io)
 Factory method to create an instance of a subclass of RegisteredType by type.
 
- Static Protected Member Functions inherited from AQNWB::NWB::RegisteredType
static void registerSubclass (const std::string &fullClassName, std::function< std::unique_ptr< RegisteredType >(const std::string &, std::shared_ptr< IO::BaseIO >)> factoryFunction, const std::string &typeName, const std::string &typeNamespace)
 Register a subclass name and its factory function in the registry.
 
- Protected Attributes inherited from AQNWB::NWB::RegisteredType
std::string m_path
 The path of the registered type.
 
std::shared_ptr< IO::BaseIOm_io
 A shared pointer to the IO object.
 
- Static Protected Attributes inherited from AQNWB::NWB::RegisteredType
static const std::string m_defaultUnregisteredGroupTypeClass
 Save the default RegisteredType to use for reading Group types that are not registered.
 
static const std::string m_defaultUnregisteredDatasetTypeClass
 Save the default RegisteredType to use for reading Dataset types that are not registered.
 

Detailed Description

General purpose time series.

Member Enumeration Documentation

◆ ContinuityType

Used to describe the continuity of the data in a time series.

Enumerator
Continuous 

Data is recorded from a continuous process

Instantaneous 

Data describes instantious evnets in time, e.g., moments of licking.

Step 

Data describes a step-function, e.g., image presented to a subject that remain until the next timpoint.

Undefined 

The continuity of the data is not defined.

Constructor & Destructor Documentation

◆ TimeSeries()

TimeSeries::TimeSeries ( const std::string & path,
std::shared_ptr< IO::BaseIO > io )

Constructor.

Parameters
pathThe location of the TimeSeries in the file.
ioA shared pointer to the IO object.

Constructor

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~TimeSeries()

TimeSeries::~TimeSeries ( )

Destructor.

Destructor

Member Function Documentation

◆ createDataAttributes()

Status TimeSeries::createDataAttributes ( const std::string & path,
const float & conversion,
const float & resolution,
const float & offset,
const std::string & unit,
const ContinuityType & continuity )
private

Convenience function for creating data related attributes.

Parameters
pathThe location of the object in the file.
conversionScalar to multiply each element in data to convert it to the specified ‘unit’.
resolutionSmallest meaningful difference between values in data.
offsetScalar to add to the data after scaling by ‘conversion’ to finalize its coercion to the specified ‘unit’.
unitBase unit of measurement for working with the data.
continuityContinuity of the data
Returns
The status of the operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createTimestampsAttributes()

Status TimeSeries::createTimestampsAttributes ( const std::string & path)
private

Convenience function for creating timestamp related attributes.

Parameters
pathThe location of the object in the file.
Returns
The status of the operation.
Here is the caller graph for this function:

◆ initialize()

void TimeSeries::initialize ( const IO::ArrayDataSetConfig & dataConfig,
const std::string & unit,
const std::string & description = "no description",
const std::string & comments = "no comments",
const float & conversion = 1.0f,
const float & resolution = -1.0f,
const float & offset = 0.0f,
const ContinuityType & continuity = ContinuityType::Undefined,
const double & startingTime = -1.0,
const float & startingTimeRate = 1.0f,
const std::vector< std::string > & controlDescription = {} )

Initializes the TimeSeries by creating NWB related attributes and writing the description and comment metadata.

Parameters
dataConfigConfiguration for the dataset including data type, shape and chunking
unitUnit for the electrical signal. Must be "volts"
descriptionThe description of the TimeSeries.
commentsHuman-readable comments about the TimeSeries
conversionScalar to multiply each element in data to convert it to the specified ‘unit’
resolutionSmallest meaningful difference between values in data, stored in the specified by unit
offsetScalar to add to the data after scaling by ‘conversion’ to finalize its coercion to the specified ‘unit'
continuityContinuity of the data
startingTimeTimestamp of the first sample in seconds. Used when timestamps are uniformly spaced, such that the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute. Set to -1.0 to indicate that recorded timestamps should be used such that no starting_time dataset will be created. If set to a value >= 0 then no timestamps dataset will be created.
startingTimeRateSampling rate in Hz. Used only when timestamps are uniformly spaced via startingTime.
controlDescriptionDescription of each control value to be used during the recording. If a non-empty vector is provided then control and control_description data will be created (otherwise they will be nullptr). We can update the control_description values later if needed via the TimeSeries.control_description->writeStringDataBlock() method.
Here is the call graph for this function:

◆ readComments()

template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > AQNWB::NWB::TimeSeries::readComments ( ) const
inline

Human - readable comments about the TimeSeries

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readControl()

template<typename VTYPE = uint8_t>
std::unique_ptr< IO::ReadDataWrapper< DatasetField, VTYPE > > AQNWB::NWB::TimeSeries::readControl ( ) const
inline

Numerical labels that apply to each time point in data

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readControlDescription()

template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< DatasetField, VTYPE > > AQNWB::NWB::TimeSeries::readControlDescription ( ) const
inline

Description of each control value

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readData()

template<typename VTYPE = std::any>
std::unique_ptr< IO::ReadDataWrapper< DatasetField, VTYPE > > AQNWB::NWB::TimeSeries::readData ( ) const
inline

The main data

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readDataContinuity()

template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > AQNWB::NWB::TimeSeries::readDataContinuity ( ) const
inline

Continuity of the data

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readDataConversion()

template<typename VTYPE = float>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > AQNWB::NWB::TimeSeries::readDataConversion ( ) const
inline

Scalar to multiply each element in data to convert it to the specified unit

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readDataOffset()

template<typename VTYPE = float>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > AQNWB::NWB::TimeSeries::readDataOffset ( ) const
inline

Scalar to add to the data after scaling by conversion to finalize its coercion to the specified unit

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readDataResolution()

template<typename VTYPE = float>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > AQNWB::NWB::TimeSeries::readDataResolution ( ) const
inline

Smallest meaningful difference between values in data

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readDataUnit()

template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > AQNWB::NWB::TimeSeries::readDataUnit ( ) const
inline

Base unit of measurement for working with the data

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readDescription()

template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > AQNWB::NWB::TimeSeries::readDescription ( ) const
inline

Description of the series

Here is the call graph for this function:

◆ readStartingTime()

template<typename VTYPE = double>
std::unique_ptr< IO::ReadDataWrapper< DatasetField, VTYPE > > AQNWB::NWB::TimeSeries::readStartingTime ( ) const
inline

Timestamp of the first sample in seconds

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readStartingTimeRate()

template<typename VTYPE = float>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > AQNWB::NWB::TimeSeries::readStartingTimeRate ( ) const
inline

Sampling rate in Hz

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readStartingTimeUnit()

template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > AQNWB::NWB::TimeSeries::readStartingTimeUnit ( ) const
inline

Unit of measurement for time fixed to seconds

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readTimestamps()

template<typename VTYPE = double>
std::unique_ptr< IO::ReadDataWrapper< DatasetField, VTYPE > > AQNWB::NWB::TimeSeries::readTimestamps ( ) const
inline

Timestamps offset in seconds relative to the master time for samples stored in data

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readTimestampsInterval()

template<typename VTYPE = int>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > AQNWB::NWB::TimeSeries::readTimestampsInterval ( ) const
inline

Interval value is 1

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readTimestampsUnit()

template<typename VTYPE = std::string>
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > AQNWB::NWB::TimeSeries::readTimestampsUnit ( ) const
inline

Unit of measurement for timestamps fixed to seconds

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeData()

Status TimeSeries::writeData ( const std::vector< SizeType > & dataShape,
const std::vector< SizeType > & positionOffset,
const void * dataInput,
const void * timestampsInput = nullptr,
const void * controlInput = nullptr )

Writes a timeseries data block to the file.

Parameters
dataShapeThe size of the data block.
positionOffsetThe position of the data block to write to.
dataInputA pointer to the data block.
timestampsInputA pointer to the timestamps block. May be null if multidimensional TimeSeries and only need to write the timestamps once but write data in separate blocks.
controlInputA pointer to the control block data (optional)
Returns
The status of the write operation.
Here is the caller graph for this function:

Member Data Documentation

◆ ContinuityTypeNames

std::map< TimeSeries::ContinuityType, std::string > TimeSeries::ContinuityTypeNames
static
Initial value:
= {
{TimeSeries::Continuous, "continuous"},
{TimeSeries::Instantaneous, "instantaneous"},
{TimeSeries::Step, "step"}}
@ Continuous
Definition TimeSeries.hpp:28
@ Instantaneous
Definition TimeSeries.hpp:30
@ Step
Definition TimeSeries.hpp:33

String names corresponding to the ContinuityType enum.

These are the values to optionally describe the continuity of the data. Can be “continuous”, “instantaneous”, or “step”. For example, a voltage trace would be “continuous”, because samples are recorded from a continuous process. An array of lick times would be “instantaneous”, because the data represents distinct moments in time. Times of image presentations would be “step” because the picture remains the same until the next timepoint. This field is optional, but is useful in providing information about the underlying data. It may inform the way this data is interpreted, the way it is visualized, and what analysis methods are applicable.

◆ control

std::unique_ptr<IO::BaseRecordingData> AQNWB::NWB::TimeSeries::control

Pointer to control values. This may be a nullptr if useControl is false.

◆ control_description

std::unique_ptr<IO::BaseRecordingData> AQNWB::NWB::TimeSeries::control_description

Pointer to control_description values. This may be a nullptr if useControl is false.

◆ controlType

IO::BaseDataType AQNWB::NWB::TimeSeries::controlType = IO::BaseDataType::U8

Data type of the control (uint8).

◆ data

std::unique_ptr<IO::BaseRecordingData> AQNWB::NWB::TimeSeries::data

Pointer to data values.

◆ m_dataType

IO::BaseDataType AQNWB::NWB::TimeSeries::m_dataType

Data type of the data.

◆ starting_time

std::unique_ptr<IO::BaseRecordingData> AQNWB::NWB::TimeSeries::starting_time

Pointer to starting_time values. This may be a nullptr if timestamps are used.

The starting_time is usually set when calling initialize(), but is exposed here to allow overwriting of the initial starting_time value in case that the correct starting_time is not known until later.

◆ timestamps

std::unique_ptr<IO::BaseRecordingData> AQNWB::NWB::TimeSeries::timestamps

Pointer to timestamp values. This may be a nullptr if starting_time is used.

◆ timestampsType

IO::BaseDataType AQNWB::NWB::TimeSeries::timestampsType = IO::BaseDataType::F64

Data type of the timestamps (float64).


The documentation for this class was generated from the following files: