Skip to content

Commit

Permalink
Fix formatting and docs error after merge with main
Browse files Browse the repository at this point in the history
oruebel committed Sep 20, 2024
1 parent dd01ad3 commit 968fcf0
Showing 15 changed files with 56 additions and 75 deletions.
6 changes: 3 additions & 3 deletions docs/pages/userdocs/workflow.dox
Original file line number Diff line number Diff line change
@@ -60,9 +60,9 @@
* object so that it can mana ge access and data writing during the recording process.
* When adding containers, ownership of the \ref AQNWB::NWB::Container "Container" is transferred to the
* \ref AQNWB::NWB::RecordingContainers "RecordingContainers" object, so that we can access it again via
* its index. New containers will always be appended to the end of the
* \ref AQNWB::NWB::RecordingContainers::containers "containers" object and their index can be tracked
* using the size of the input `recordingArrays`.
* 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 \ref AQNWB::NWB::RecordingContainers::size "RecordingContainers.size" of the input `recordingArrays`.
*
* \snippet tests/examples/testWorkflowExamples.cpp example_workflow_datasets_snippet
*
9 changes: 4 additions & 5 deletions src/io/hdf5/HDF5IO.cpp
Original file line number Diff line number Diff line change
@@ -96,12 +96,12 @@ std::unique_ptr<H5::Attribute> HDF5IO::getAttribute(const std::string& path)

try {
// Try to open the parent object as a group
H5::Group parentGroup = this->file->openGroup(parentPath);
H5::Group parentGroup = m_file->openGroup(parentPath);
return std::make_unique<H5::Attribute>(parentGroup.openAttribute(attrName));
} catch (const H5::Exception& e) {
// If it's not a group, try to open it as a dataset
try {
H5::DataSet parentDataset = this->file->openDataSet(parentPath);
H5::DataSet parentDataset = m_file->openDataSet(parentPath);
return std::make_unique<H5::Attribute>(
parentDataset.openAttribute(attrName));
} catch (const H5::Exception& e) {
@@ -284,7 +284,7 @@ AQNWB::IO::DataBlockGeneric HDF5IO::readDataset(
const std::vector<SizeType>& block)
{
// Check that the dataset exists
assert(H5Lexists(this->file->getId(), dataPath.c_str(), H5P_DEFAULT) > 0);
assert(H5Lexists(m_file->getId(), dataPath.c_str(), H5P_DEFAULT) > 0);
// create the return value to fill
IO::DataBlockGeneric result;

@@ -297,7 +297,7 @@ AQNWB::IO::DataBlockGeneric HDF5IO::readDataset(
std::copy(block.begin(), block.end(), block_hsize.begin());

// Read the dataset
H5::DataSet dataset = file->openDataSet(dataPath);
H5::DataSet dataset = m_file->openDataSet(dataPath);

// Get the dataspace of the dataset
H5::DataSpace dataspace = dataset.getSpace();
@@ -738,7 +738,6 @@ bool HDF5IO::objectExists(const std::string& path)
}
}


std::unique_ptr<AQNWB::IO::BaseRecordingData> HDF5IO::getDataSet(
const std::string& path)
{
1 change: 0 additions & 1 deletion src/io/hdf5/HDF5IO.hpp
Original file line number Diff line number Diff line change
@@ -409,4 +409,3 @@ class HDF5IO : public BaseIO
};

} // namespace AQNWB::IO::HDF5

18 changes: 5 additions & 13 deletions src/io/hdf5/HDF5RecordingData.cpp
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
using namespace H5;
using namespace AQNWB::IO::HDF5;

// HDF5RecordingData
HDF5RecordingData::HDF5RecordingData(std::unique_ptr<H5::DataSet> data)
{
DataSpace dSpace = data->getSpace();
@@ -34,15 +33,13 @@ HDF5RecordingData::HDF5RecordingData(std::unique_ptr<H5::DataSet> data)
this->nDimensions = nDimensions;
this->position = std::vector<SizeType>(
nDimensions, 0); // Initialize position with 0 for each dimension
this->dSet = std::make_unique<H5::DataSet>(*data);
m_dataset = std::make_unique<H5::DataSet>(*data);
}

// HDF5RecordingData

HDF5RecordingData::~HDF5RecordingData()
{
// Safety
dSet->flush(H5F_SCOPE_GLOBAL);
m_dataset->flush(H5F_SCOPE_GLOBAL);
}

Status HDF5RecordingData::writeDataBlock(
@@ -71,10 +68,10 @@ Status HDF5RecordingData::writeDataBlock(
}

// Adjust dataset dimensions if necessary
dSet->extend(dSetDims.data());
m_dataset->extend(dSetDims.data());

// Set size to new size based on updated dimensionality
DataSpace fSpace = dSet->getSpace();
DataSpace fSpace = m_dataset->getSpace();
fSpace.getSimpleExtentDims(dSetDims.data());
for (int i = 0; i < nDimensions; ++i) {
size[i] = dSetDims[i];
@@ -97,7 +94,7 @@ Status HDF5RecordingData::writeDataBlock(

// Write the data
DataType nativeType = HDF5IO::getNativeType(type);
dSet->write(data, nativeType, mSpace, fSpace);
m_dataset->write(data, nativeType, mSpace, fSpace);

// Update position for simple extension
for (int i = 0; i < dataShape.size(); ++i) {
@@ -112,8 +109,3 @@ Status HDF5RecordingData::writeDataBlock(
}
return Status::Success;
}

const H5::DataSet* HDF5RecordingData::getDataSet()
{
return dSet.get();
};
10 changes: 5 additions & 5 deletions src/io/hdf5/HDF5RecordingData.hpp
Original file line number Diff line number Diff line change
@@ -57,17 +57,17 @@ class HDF5RecordingData : public AQNWB::IO::BaseRecordingData
* @brief Gets a const pointer to the HDF5 dataset.
* @return A const pointer to the HDF5 dataset.
*/
const H5::DataSet* getDataSet();
inline const H5::DataSet* getDataSet() const { return m_dataset.get(); }

private:
/**
* @brief Pointer to an extendable HDF5 dataset
* @brief Return status of HDF5 operations.
*/
std::unique_ptr<H5::DataSet> dSet;
Status checkStatus(int status);

/**
* @brief Return status of HDF5 operations.
* @brief Pointer to an extendable HDF5 dataset
*/
Status checkStatus(int status);
std::unique_ptr<H5::DataSet> m_dataset;
};
} // namespace AQNWB::IO::HDF5
26 changes: 9 additions & 17 deletions src/nwb/NWBFile.cpp
Original file line number Diff line number Diff line change
@@ -71,14 +71,11 @@ Status NWBFile::createFileStructure(const std::string& identifierText,
m_io->createGroup("/general");
m_io->createGroup("/general/devices");
m_io->createGroup("/general/extracellular_ephys");

if (dataCollection != "") {
m_io->createStringDataSet("/general/data_collection", dataCollection);
}

m_io->createGroup("/specifications");
m_io->createReferenceAttribute("/specifications", "/", ".specloc");

cacheSpecifications(
"core", AQNWB::SPEC::CORE::version, AQNWB::SPEC::CORE::specVariables);
cacheSpecifications("hdmf-common",
@@ -87,16 +84,13 @@ Status NWBFile::createFileStructure(const std::string& identifierText,
cacheSpecifications("hdmf-experimental",
AQNWB::SPEC::HDMF_EXPERIMENTAL::version,
AQNWB::SPEC::HDMF_EXPERIMENTAL::specVariables);

std::string time = getCurrentTime();
std::vector<std::string> timeVec = {time};

m_io->createStringDataSet("/file_create_date", timeVec);
m_io->createStringDataSet("/session_description", description);
m_io->createStringDataSet("/session_start_time", time);
m_io->createStringDataSet("/timestamps_reference_time", time);
m_io->createStringDataSet("/identifier", m_identifierText);

m_io->createStringDataSet("/identifier", identifierText);
return Status::Success;
}

@@ -141,11 +135,11 @@ Status NWBFile::createElectricalSeries(

// Check if device exists for groupName, create device and electrode group
// if not
if (!io->objectExists(devicePath)) {
Device device = Device(devicePath, io);
if (!m_io->objectExists(devicePath)) {
Device device = Device(devicePath, m_io);
device.initialize("description", "unknown");

ElectrodeGroup elecGroup = ElectrodeGroup(electrodePath, io);
ElectrodeGroup elecGroup = ElectrodeGroup(electrodePath, m_io);
elecGroup.initialize("description", "unknown", device);
}

@@ -154,14 +148,13 @@ Status NWBFile::createElectricalSeries(
Device device = Device(devicePath, m_io);
device.initialize("description", "unknown");

ElectrodeGroup elecGroup =
ElectrodeGroup(electrodePath, m_io);
ElectrodeGroup elecGroup = ElectrodeGroup(electrodePath, m_io);
elecGroup.initialize("description", "unknown", device);
}

// Setup electrical series datasets
auto electricalSeries =
std::make_unique<ElectricalSeries>(electricalSeriesPath, io);
auto electricalSeries =
std::make_unique<ElectricalSeries>(electricalSeriesPath, m_io);
electricalSeries->initialize(
dataType,
channelVector,
@@ -227,8 +220,7 @@ Status NWBFile::createSpikeEventSeries(
Device device = Device(devicePath, m_io);
device.initialize("description", "unknown");

ElectrodeGroup elecGroup =
ElectrodeGroup(electrodePath, m_io);
ElectrodeGroup elecGroup = ElectrodeGroup(electrodePath, m_io);
elecGroup.initialize("description", "unknown", device);
}

@@ -288,6 +280,6 @@ std::unique_ptr<AQNWB::IO::BaseRecordingData> NWBFile::createRecordingData(
const SizeArray& chunking,
const std::string& path)
{
return std::unique_ptr<BaseRecordingData>(
return std::unique_ptr<IO::BaseRecordingData>(
m_io->createArrayDataSet(type, size, chunking, path));
}
3 changes: 0 additions & 3 deletions src/nwb/NWBFile.hpp
Original file line number Diff line number Diff line change
@@ -158,8 +158,6 @@ class NWBFile : public Container
const std::array<std::pair<std::string_view, std::string_view>, N>&
specVariables);

std::unique_ptr<ElectrodeTable> elecTable;
const std::string identifierText;
inline const static std::string acquisitionPath = "/acquisition";
static std::vector<SizeType> emptyContainerIndexes;

@@ -168,7 +166,6 @@ class NWBFile : public Container
* @brief The ElectrodeTable for the file
*/
std::unique_ptr<ElectrodeTable> m_electrodeTable;
const std::string m_identifierText;
};

} // namespace AQNWB::NWB
4 changes: 2 additions & 2 deletions src/nwb/base/TimeSeries.cpp
Original file line number Diff line number Diff line change
@@ -32,14 +32,14 @@ void TimeSeries::initialize(const IO::BaseDataType& dataType,
m_io->createAttribute(comments, m_path, "comments");

// setup datasets
this->data = std::unique_ptr<BaseRecordingData>(m_io->createArrayDataSet(
this->data = std::unique_ptr<IO::BaseRecordingData>(m_io->createArrayDataSet(
dataType, dsetSize, chunkSize, m_path + "/data"));
m_io->createDataAttributes(m_path, conversion, resolution, unit);

SizeArray tsDsetSize = {
dsetSize[0]}; // timestamps match data along first dimension
this->timestamps =
std::unique_ptr<BaseRecordingData>(m_io->createArrayDataSet(
std::unique_ptr<IO::BaseRecordingData>(m_io->createArrayDataSet(
this->timestampsType, tsDsetSize, chunkSize, m_path + "/timestamps"));
m_io->createTimestampsAttributes(m_path);
}
6 changes: 3 additions & 3 deletions src/nwb/base/TimeSeries.hpp
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ class TimeSeries : public Container

inline std::string dataPath() const
{
return (this->path + std::string("/data"));
return (m_path + std::string("/data"));
}

template<typename VTYPE = std::any>
@@ -100,7 +100,7 @@ class TimeSeries : public Container
{
return std::make_unique<
IO::ReadDataWrapper<AQNWB::Types::StorageObjectType::Dataset, VTYPE>>(
this->io, this->dataPath());
m_io, this->dataPath());
}

inline std::string resolutionPath() const
@@ -115,7 +115,7 @@ class TimeSeries : public Container
{
return std::make_unique<
IO::ReadDataWrapper<AQNWB::Types::StorageObjectType::Attribute, VTYPE>>(
this->io, this->resolutionPath());
m_io, this->resolutionPath());
}

private:
10 changes: 5 additions & 5 deletions src/nwb/ecephys/ElectricalSeries.cpp
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ void ElectricalSeries::initialize(const IO::BaseDataType& dataType,
TimeSeries::initialize(dataType,
"volts",
description,
channelVector[0].comments,
channelVector[0].getComments(),
dsetSize,
chunkSize,
channelVector[0].getConversion(),
@@ -47,8 +47,8 @@ void ElectricalSeries::initialize(const IO::BaseDataType& dataType,
samplesRecorded = SizeArray(channelVector.size(), 0);

// make channel conversion dataset
channelConversion = std::unique_ptr<BaseRecordingData>(
m_io->createArrayDataSet(BaseDataType::F32,
channelConversion = std::unique_ptr<IO::BaseRecordingData>(
m_io->createArrayDataSet(IO::BaseDataType::F32,
SizeArray {1},
chunkSize,
getPath() + "/channel_conversion"));
@@ -62,8 +62,8 @@ void ElectricalSeries::initialize(const IO::BaseDataType& dataType,
"Bit volts values for all channels");

// make electrodes dataset
electrodesDataset = std::unique_ptr<BaseRecordingData>(
m_io->createArrayDataSet(BaseDataType::I32,
electrodesDataset = std::unique_ptr<IO::BaseRecordingData>(
m_io->createArrayDataSet(IO::BaseDataType::I32,
SizeArray {1},
chunkSize,
getPath() + "/electrodes"));
14 changes: 7 additions & 7 deletions src/nwb/file/ElectrodeTable.cpp
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ using namespace AQNWB::NWB;
/** Constructor */
ElectrodeTable::ElectrodeTable(std::shared_ptr<IO::BaseIO> io)
: DynamicTable(electrodeTablePath, // use the electrodeTablePath
io)
io,
{"group", "group_name", "location"})
{
}
@@ -32,15 +32,15 @@ void ElectrodeTable::initialize(const std::string& description)
DynamicTable::initialize(description);

electrodeDataset->setDataset(
std::unique_ptr<BaseRecordingData>(m_io->createArrayDataSet(
BaseDataType::I32, SizeArray {1}, SizeArray {1}, m_path + "id")));
groupNamesDataset->setDataset(std::unique_ptr<BaseRecordingData>(
m_io->createArrayDataSet(BaseDataType::STR(250),
std::unique_ptr<IO::BaseRecordingData>(m_io->createArrayDataSet(
IO::BaseDataType::I32, SizeArray {1}, SizeArray {1}, m_path + "id")));
groupNamesDataset->setDataset(std::unique_ptr<IO::BaseRecordingData>(
m_io->createArrayDataSet(IO::BaseDataType::STR(250),
SizeArray {0},
SizeArray {1},
m_path + "group_name")));
locationsDataset->setDataset(std::unique_ptr<BaseRecordingData>(
m_io->createArrayDataSet(BaseDataType::STR(250),
locationsDataset->setDataset(std::unique_ptr<IO::BaseRecordingData>(
m_io->createArrayDataSet(IO::BaseDataType::STR(250),
SizeArray {0},
SizeArray {1},
m_path + "location")));
1 change: 0 additions & 1 deletion src/nwb/hdmf/base/Container.hpp
Original file line number Diff line number Diff line change
@@ -56,6 +56,5 @@ class Container
* @brief A shared pointer to the IO object.
*/
std::shared_ptr<IO::BaseIO> m_io;

};
} // namespace AQNWB::NWB
5 changes: 3 additions & 2 deletions src/nwb/hdmf/base/Data.hpp
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ class Data
*
* @param dataset The rvalue unique pointer to the BaseRecordingData object
*/
inline void setDataset(std::unique_ptr<BaseRecordingData>&& dataset)
inline void setDataset(std::unique_ptr<IO::BaseRecordingData>&& dataset)
{
m_dataset = std::move(dataset);
}
@@ -40,6 +40,7 @@ class Data
*/
inline bool isInitialized() { return m_dataset != nullptr; }

std::unique_ptr<BaseRecordingData> m_dataset; // TODO We may not want this here if we need Data for read
std::unique_ptr<IO::BaseRecordingData>
m_dataset; // TODO We may not want this here if we need Data for read
};
} // namespace AQNWB::NWB
9 changes: 5 additions & 4 deletions src/nwb/hdmf/table/DynamicTable.cpp
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ DynamicTable::~DynamicTable() {}
void DynamicTable::initialize(const std::string& description)
{
Container::initialize();
this->description = description;
this->m_description = description;

m_io->createCommonNWBAttributes(
m_path, "hdmf-common", "DynamicTable", getDescription());
@@ -53,9 +53,10 @@ void DynamicTable::setRowIDs(std::unique_ptr<ElementIdentifiers>& elementIDs,
if (!elementIDs->isInitialized()) {
std::cerr << "ElementIdentifiers dataset is not initialized" << std::endl;
} else {
elementIDs->m_dataset->writeDataBlock(std::vector<SizeType>(1, values.size()),
BaseDataType::I32,
&values[0]);
elementIDs->m_dataset->writeDataBlock(
std::vector<SizeType>(1, values.size()),
IO::BaseDataType::I32,
&values[0]);
m_io->createCommonNWBAttributes(
m_path + "id", "hdmf-common", "ElementIdentifiers");
}
9 changes: 5 additions & 4 deletions src/nwb/hdmf/table/DynamicTable.hpp
Original file line number Diff line number Diff line change
@@ -25,10 +25,11 @@ class DynamicTable : public Container
* @param io A shared pointer to the IO object.
* @param colNames Set the names of the columns for the table
*/
DynamicTable(const std::string& path,
std::shared_ptr<BaseIO> io,
const std::vector<std::string>& colNames = {}); // TODO Need to remove colNames here and move it to initialize

DynamicTable(
const std::string& path,
std::shared_ptr<IO::BaseIO> io,
const std::vector<std::string>& colNames =
{}); // TODO Need to remove colNames here and move it to initialize

/**
* @brief Destructor

0 comments on commit 968fcf0

Please sign in to comment.