![]() |
aqnwb 0.1.0
|
For users wanting to integrate NWB with a particular data acquisition software, here we outline the steps for a single recording from file creation to saving.
/general
in NWB, e.g., the Below, we walk through these steps in more detail.
First, create an I/O object (e.g., HDF5IO) used for writing data to the file. AqNWB provides the convenience method, createIO to create this object using one of the supported backends. For more fine-grained control of different backend parameters, you can create your own std::shared_ptr
using any of the derived BaseIO classes.
Next, create a RecordingContainers object to manage the different Container objects with the datasets that you would like to write data to.
Next, constructs the NWBFile object, using the I/O object as an input. Then, initialize the object to create the basic file structure of the NWBFile.
Next, construct the ElectrodeTable object, using the recordingArrays
as an input. Note that in many cases, you will be recording from all electrodes detected by the device and this recordingArrays
structure will be the same as is used to create the ElectricalSeries. However in some cases (e.g. when using Neuropixels or multiple probes), you may be recording from a subset of all available electrodes as part of a single ElectricalSeries. In this case, you should create the ref AQNWB::NWB::ElectrodesTable "ElectrodesTable" with all electrodes detected by the acquisition system, not just those being actively recorded from. This approach is critical for mapping information about which ElectricalSeries were recorded from which electrodes.
Next, create the different data types (e.g. ElectricalSeries or other AQNWB::NWB::TimeSeries "TimeSeries") that you would like to write data into. After creation, these objects are added to the RecordingContainers object so that it can mana ge access and data writing during the recording process. When adding containers, ownership of the Container is transferred to the RecordingContainers object, so that we can access it again via its index. New containers will always be appended to the end of the private member RecordingContainers::m_containers
object and their index can be tracked using the RecordingContainers.size of the input recordingArrays
.
Then, start the recording process with a call to the startRecording
function of the I/O object.
During the recording process, use the RecordingContainers as an interface to access the various Container object and corresponding datasets and write blocks of data to the file. Calling flush()
on the I/O object at any time will ensure the data is moved to disk.
When the recording process is finished, call stopRecording
from the I/O object to flush any data and close the file.