![]() |
aqnwb 0.1.0
|
General purpose time series. More...
#include <TimeSeries.hpp>
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 |
![]() | |
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 |
![]() | |
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::BaseIO > | getIO () 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::RegisteredType > | readField (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::BaseRecordingData > | data |
Pointer to data values. | |
std::unique_ptr< IO::BaseRecordingData > | timestamps |
Pointer to timestamp values. This may be a nullptr if starting_time is used. | |
std::unique_ptr< IO::BaseRecordingData > | starting_time |
Pointer to starting_time values. This may be a nullptr if timestamps are used. | |
std::unique_ptr< IO::BaseRecordingData > | control |
Pointer to control values. This may be a nullptr if useControl is false. | |
std::unique_ptr< IO::BaseRecordingData > | control_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 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< RegisteredType > | create (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::RegisteredType > | create (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 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. | |
![]() | |
std::string | m_path |
The path of the registered type. | |
std::shared_ptr< IO::BaseIO > | m_io |
A shared pointer to the IO object. | |
![]() | |
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. | |
General purpose time series.
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. |
TimeSeries::TimeSeries | ( | const std::string & | path, |
std::shared_ptr< IO::BaseIO > | io ) |
Constructor.
path | The location of the TimeSeries in the file. |
io | A shared pointer to the IO object. |
Constructor
TimeSeries::~TimeSeries | ( | ) |
Destructor.
Destructor
|
private |
Convenience function for creating data related attributes.
path | The location of the object in the file. |
conversion | Scalar to multiply each element in data to convert it to the specified ‘unit’. |
resolution | Smallest meaningful difference between values in data. |
offset | Scalar to add to the data after scaling by ‘conversion’ to finalize its coercion to the specified ‘unit’. |
unit | Base unit of measurement for working with the data. |
continuity | Continuity of the data |
|
private |
Convenience function for creating timestamp related attributes.
path | The location of the object in the file. |
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.
dataConfig | Configuration for the dataset including data type, shape and chunking |
unit | Unit for the electrical signal. Must be "volts" |
description | The description of the TimeSeries. |
comments | Human-readable comments about the TimeSeries |
conversion | Scalar to multiply each element in data to convert it to the specified ‘unit’ |
resolution | Smallest meaningful difference between values in data, stored in the specified by unit |
offset | Scalar to add to the data after scaling by ‘conversion’ to finalize its coercion to the specified ‘unit' |
continuity | Continuity of the data |
startingTime | Timestamp 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. |
startingTimeRate | Sampling rate in Hz. Used only when timestamps are uniformly spaced via startingTime. |
controlDescription | Description 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. |
|
inline |
Human - readable comments about the TimeSeries
|
inline |
Numerical labels that apply to each time point in data
|
inline |
Description of each control value
|
inline |
The main data
|
inline |
Continuity of the data
|
inline |
Scalar to multiply each element in data to convert it to the specified unit
|
inline |
Scalar to add to the data after scaling by conversion to finalize its coercion to the specified unit
|
inline |
Smallest meaningful difference between values in data
|
inline |
Base unit of measurement for working with the data
|
inline |
Description of the series
|
inline |
Timestamp of the first sample in seconds
|
inline |
Sampling rate in Hz
|
inline |
Unit of measurement for time fixed to seconds
|
inline |
Timestamps offset in seconds relative to the master time for samples stored in data
|
inline |
Interval value is 1
|
inline |
Unit of measurement for timestamps fixed to seconds
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.
dataShape | The size of the data block. |
positionOffset | The position of the data block to write to. |
dataInput | A pointer to the data block. |
timestampsInput | A 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. |
controlInput | A pointer to the control block data (optional) |
|
static |
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.
std::unique_ptr<IO::BaseRecordingData> AQNWB::NWB::TimeSeries::control |
Pointer to control values. This may be a nullptr if useControl is false.
std::unique_ptr<IO::BaseRecordingData> AQNWB::NWB::TimeSeries::control_description |
Pointer to control_description values. This may be a nullptr if useControl is false.
IO::BaseDataType AQNWB::NWB::TimeSeries::controlType = IO::BaseDataType::U8 |
Data type of the control (uint8).
std::unique_ptr<IO::BaseRecordingData> AQNWB::NWB::TimeSeries::data |
Pointer to data values.
IO::BaseDataType AQNWB::NWB::TimeSeries::m_dataType |
Data type of the data.
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.
std::unique_ptr<IO::BaseRecordingData> AQNWB::NWB::TimeSeries::timestamps |
Pointer to timestamp values. This may be a nullptr if starting_time is used.
IO::BaseDataType AQNWB::NWB::TimeSeries::timestampsType = IO::BaseDataType::F64 |
Data type of the timestamps (float64).