aqnwb 0.3.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"
18#include "spec/core.hpp"
19
24namespace AQNWB::NWB
25{
26
31class NWBFile : public NWBContainer
32{
33public:
34 // Register the NWBFile as a subclass of NWBContainer
36
37 // Static paths for NWB file structure
39 inline const static std::string ACQUISITION_PATH = "/acquisition";
41 inline const static std::string SPECIFICATIONS_PATH = "/specifications";
43 inline const static std::string PROCESSING_PATH = "/processing";
45 inline const static std::string STIMULUS_PATH = "/stimulus";
47 inline const static std::string GENERAL_PATH = "/general";
49 inline const static std::string ANALYSIS_PATH = "/analysis";
50
56 static std::shared_ptr<NWBFile> create(std::shared_ptr<IO::BaseIO> io)
57 {
58 return RegisteredType::create<NWBFile>("/", io);
59 }
60
61protected:
66 explicit NWBFile(std::shared_ptr<IO::BaseIO> io);
67
71 NWBFile(const std::string& path, std::shared_ptr<IO::BaseIO> io);
72
73public:
77 NWBFile(const NWBFile&) = delete;
78
82 NWBFile& operator=(const NWBFile&) = delete;
83
87 ~NWBFile() override;
88
102 Status initialize(const std::string& identifierText,
103 const std::string& description = "a recording session",
104 const std::string& dataCollection = "",
105 const std::string& sessionStartTime = "",
106 const std::string& timestampsReferenceTime = "");
107
115 bool isInitialized() const;
116
132 std::shared_ptr<ElectrodesTable> createElectrodesTable(
133 std::vector<Types::ChannelVector> recordingArrays,
134 bool finalizeTable = true);
135
153 std::vector<Types::ChannelVector> recordingArrays,
154 std::vector<std::string> recordingNames,
155 const IO::BaseDataType& dataType,
156 std::vector<SizeType>& containerIndexes);
157
172 std::vector<Types::ChannelVector> recordingArrays,
173 std::vector<std::string> recordingNames,
174 const IO::BaseDataType& dataType,
175 std::vector<SizeType>& containerIndexes);
176
185 Status createAnnotationSeries(const std::vector<std::string>& recordingNames,
186 std::vector<SizeType>& containerIndexes);
187
191 "table with the extracellular electrodes")
192
194 std::string,
195 "nwb_version",
196 File version string)
197
200 std::string,
201 "file_create_date",
202 A record of the date the file was created and of
203 subsequent modifications)
204
207 std::string,
208 "identifier",
209 A unique text identifier for the file)
210
213 std::string,
214 "session_description",
215 A description of the experimental session and data in the
216 file)
217
220 std::string,
221 "session_start_time",
222 Date and time of the experiment or session start)
223
226 std::string,
227 "timestamps_reference_time",
228 Date and time corresponding to time zero of all
229 timestamps)
230
234 "acquisition",
235 Get a TimeSeries stored in the acquisition
236 group)
237
241 "processing",
242 Get a ProcessingModule stored in the
243 processing group)
244
245protected:
261 Status createFileStructure(const std::string& identifierText,
262 const std::string& description,
263 const std::string& dataCollection,
264 const std::string& sessionStartTime,
265 const std::string& timestampsReferenceTime);
266
267private:
274 void cacheSpecifications(const Types::NamespaceInfo& namespaceInfo);
275
280};
281
282} // namespace AQNWB::NWB
AQNWB::Types::Status Status
Definition BaseIO.hpp:21
#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
static const std::string STIMULUS_PATH
The path to the stimulus group in the NWB file.
Definition NWBFile.hpp:45
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:299
std::unique_ptr< RTYPE > createAquisitionSeries(std::string &objectName) const
std::unique_ptr< RTYPE > createProcessingModule(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:199
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.
static const std::string ACQUISITION_PATH
The path to the acquisition group in the NWB file.
Definition NWBFile.hpp:39
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)
std::shared_ptr< RTYPE > readProcessingModule(std::string &objectName) const
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:279
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readIdentifier() const
Status createAnnotationSeries(const 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:374
void cacheSpecifications(const Types::NamespaceInfo &namespaceInfo)
Saves the specification files for the schema.
Definition NWBFile.cpp:410
static const std::string GENERAL_PATH
The path to the general group in the NWB file.
Definition NWBFile.hpp:47
bool isInitialized() const
Check if the NWB file is initialized.
Definition NWBFile.cpp:103
~NWBFile() override
Destructor for NWBFile class.
Definition NWBFile.cpp:50
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::AttributeField, VTYPE > > readNWBVersion() const
static const std::string PROCESSING_PATH
The path to the processing group in the NWB file.
Definition NWBFile.hpp:43
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:241
static const std::string SPECIFICATIONS_PATH
The path to the specification group in the NWB file.
Definition NWBFile.hpp:41
static const std::string ANALYSIS_PATH
The path to the analysis group in the NWB file.
Definition NWBFile.hpp:49
std::unique_ptr< AQNWB::IO::ReadDataWrapper< AQNWB::NWB::DatasetField, VTYPE > > readSessionStartTime() const
std::shared_ptr< AQNWB::IO::BaseRecordingData > recordSessionDescription(bool reset=false)
A collection of processed data.
Definition ProcessingModule.hpp:27
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:19
Provides definitions for various types used in the project.
Definition Types.hpp:19
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