aqnwb 0.2.0
Loading...
Searching...
No Matches
NWBFile.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstdint>
5#include <memory>
6#include <string>
7#include <string_view>
8#include <vector>
9
10#include "Types.hpp"
11#include "Utils.hpp"
12#include "io/BaseIO.hpp"
13#include "io/ReadIO.hpp"
17#include "spec/core.hpp"
18
23namespace AQNWB::NWB
24{
25
30class NWBFile : public NWBContainer
31{
32public:
33 // Register the NWBFile as a subclass of NWBContainer
35
36
41 static std::shared_ptr<NWBFile> create(std::shared_ptr<IO::BaseIO> io)
42 {
43 return RegisteredType::create<NWBFile>("/", io);
44 }
45
46protected:
51 NWBFile(std::shared_ptr<IO::BaseIO> io);
52
56 NWBFile(const std::string& path, std::shared_ptr<IO::BaseIO> io);
57
58public:
62 NWBFile(const NWBFile&) = delete;
63
67 NWBFile& operator=(const NWBFile&) = delete;
68
72 ~NWBFile();
73
87 Status initialize(const std::string& identifierText,
88 const std::string& description = "a recording session",
89 const std::string& dataCollection = "",
90 const std::string& sessionStartTime = "",
91 const std::string& timestampsReferenceTime = "");
92
100 bool isInitialized() const;
101
117 std::shared_ptr<ElectrodesTable> createElectrodesTable(
118 std::vector<Types::ChannelVector> recordingArrays,
119 bool finalizeTable = true);
120
138 std::vector<Types::ChannelVector> recordingArrays,
139 std::vector<std::string> recordingNames,
140 const IO::BaseDataType& dataType,
141 std::vector<SizeType>& containerIndexes);
142
157 std::vector<Types::ChannelVector> recordingArrays,
158 std::vector<std::string> recordingNames,
159 const IO::BaseDataType& dataType,
160 std::vector<SizeType>& containerIndexes);
161
170 Status createAnnotationSeries(std::vector<std::string> recordingNames,
171 std::vector<SizeType>& containerIndexes);
172
176 "table with the extracellular electrodes")
177
179 std::string,
180 "nwb_version",
181 File version string)
182
185 std::string,
186 "file_create_date",
187 A record of the date the file was created and of
188 subsequent modifications)
189
192 std::string,
193 "identifier",
194 A unique text identifier for the file)
195
198 std::string,
199 "session_description",
200 A description of the experimental session and data in the
201 file)
202
205 std::string,
206 "session_start_time",
207 Date and time of the experiment or session start)
208
211 std::string,
212 "timestamps_reference_time",
213 Date and time corresponding to time zero of all
214 timestamps)
215
219 "acquisition",
220 Get a TimeSeries stored in the acquisition
221 group)
222
223protected:
239 Status createFileStructure(const std::string& identifierText,
240 const std::string& description,
241 const std::string& dataCollection,
242 const std::string& sessionStartTime,
243 const std::string& timestampsReferenceTime);
244
245private:
252 void cacheSpecifications(const Types::NamespaceInfo& namespaceInfo);
253
254 inline const static std::string m_acquisitionPath = "/acquisition";
255
256 inline const static std::string m_specificationsPath = "/specifications";
257
262};
263
264} // namespace AQNWB::NWB
AQNWB::Types::Status Status
Definition BaseIO.hpp:22
#define REGISTER_SUBCLASS(T, BASE, NAMESPACE)
Macro to register a subclass with the RegisteredType class registry.
Definition RegisteredType.hpp:501
#define DEFINE_ATTRIBUTE_FIELD(name, default_type, fieldPath, description)
Defines a lazy-loaded attribute field accessor function.
Definition RegisteredType.hpp:534
#define DEFINE_DATASET_FIELD(readName, writeName, default_type, fieldPath, description)
Defines a lazy-loaded dataset field accessor function.
Definition RegisteredType.hpp:573
#define DEFINE_UNNAMED_REGISTERED_FIELD(readName, writeName, registeredType, fieldPrefixPath, description)
Defines a lazy-loaded accessor function for reading fields that are RegisteredTypes that do not have ...
Definition RegisteredType.hpp:677
#define DEFINE_REGISTERED_FIELD(name, registeredType, fieldPath, description)
Defines a lazy-loaded accessor function for reading fields that are RegisteredTypes.
Definition RegisteredType.hpp:638
Represents a base data type.
Definition BaseIO.hpp:47
Represents a table containing electrode metadata.
Definition ElectrodesTable.hpp:17
static const std::string electrodesTablePath
The path to the ElectrodesTable.
Definition ElectrodesTable.hpp:84
Status initialize()
Initialize the object.
Definition NWBContainer.cpp:17
NWBContainer(const std::string &path, std::shared_ptr< AQNWB::IO::BaseIO > io)
Constructor.
Definition NWBContainer.cpp:11
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordTimestampsReferenceTime(bool reset=false)
Status createSpikeEventSeries(std::vector< Types::ChannelVector > recordingArrays, std::vector< std::string > recordingNames, const IO::BaseDataType &dataType, std::vector< SizeType > &containerIndexes)
Create SpikeEventSeries objects to record data into. Created objects are automatically added to the I...
Definition NWBFile.cpp:297
std::unique_ptr< RTYPE > createAquisitionSeries(std::string &objectName) const
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordFileCreateDate(bool reset=false)
std::shared_ptr< ElectrodesTable > createElectrodesTable(std::vector< Types::ChannelVector > recordingArrays, bool finalizeTable=true)
Create ElectrodesTable. Note, this function will fail if the file is in a mode where new objects cann...
Definition NWBFile.cpp:197
NWBFile(std::shared_ptr< IO::BaseIO > io)
Constructor for NWBFile class.
Definition NWBFile.cpp:35
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readTimestampsReferenceTime() const
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readSessionDescription() const
NWBFile(const NWBFile &)=delete
Deleted copy constructor to prevent construction-copying.
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordIdentifier(bool reset=false)
std::shared_ptr< RTYPE > readAquisitionSeries(std::string &objectName) const
std::shared_ptr< RTYPE > readElectrodesTable() const
Status createFileStructure(const std::string &identifierText, const std::string &description, const std::string &dataCollection, const std::string &sessionStartTime, const std::string &timestampsReferenceTime)
Creates the default file structure. Note, this function will fail if the file is in a mode where new ...
Definition NWBFile.cpp:140
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordSessionStartTime(bool reset=false)
static std::shared_ptr< NWBFile > create(const std::string &path, std::shared_ptr< AQNWB::IO::BaseIO > io)
NWBFile & operator=(const NWBFile &)=delete
Deleted copy assignment operator to prevent copying.
std::unique_ptr< ElectrodesTable > m_electrodeTable
The ElectrodesTable for the file.
Definition NWBFile.hpp:261
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readIdentifier() const
~NWBFile()
Destructor for NWBFile class.
Definition NWBFile.cpp:50
Status createAnnotationSeries(std::vector< std::string > recordingNames, std::vector< SizeType > &containerIndexes)
Create AnnotationSeries objects to record data into. Created objects are automatically added to the I...
Definition NWBFile.cpp:372
void cacheSpecifications(const Types::NamespaceInfo &namespaceInfo)
Saves the specification files for the schema.
Definition NWBFile.cpp:407
bool isInitialized() const
Check if the NWB file is initialized.
Definition NWBFile.cpp:103
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::AttributeField, VTYPE > > readNWBVersion() const
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readFileCreateDate() const
Status createElectricalSeries(std::vector< Types::ChannelVector > recordingArrays, std::vector< std::string > recordingNames, const IO::BaseDataType &dataType, std::vector< SizeType > &containerIndexes)
Create ElectricalSeries objects to record data into. Created objects are automatically added to the I...
Definition NWBFile.cpp:239
static const std::string m_acquisitionPath
Definition NWBFile.hpp:254
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readSessionStartTime() const
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordSessionDescription(bool reset=false)
static const std::string m_specificationsPath
Definition NWBFile.hpp:256
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.
Definition RegisteredType.cpp:75
General purpose time series.
Definition TimeSeries.hpp:18
Provides definitions for various types used in the project.
Definition Types.hpp:17
The namespace for IO components of AqNWB.
Namespace for all classes related to the NWB data standard.
const std::string namespaceName
Definition core.hpp:21