From 2071445ae9ea5a545def51a7e9723dc5a93c3ef4 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 10:59:49 -0700 Subject: [PATCH 01/26] Update Channel.hpp/cpp to avoid shadowing --- src/Channel.cpp | 35 ++--- src/Channel.hpp | 178 ++++++++++++++++++++---- src/nwb/NWBFile.cpp | 4 +- src/nwb/RecordingContainers.cpp | 4 +- src/nwb/ecephys/ElectricalSeries.cpp | 4 +- src/nwb/file/ElectrodeTable.cpp | 6 +- tests/examples/testWorkflowExamples.cpp | 6 +- tests/testRecordingWorkflow.cpp | 6 +- 8 files changed, 175 insertions(+), 68 deletions(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index d8f9357d..54598b9d 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -14,32 +14,17 @@ Channel::Channel(const std::string name, const float bitVolts, const std::array position, const std::string comments) - : name(name) - , groupName(groupName) - , groupIndex(groupIndex) - , localIndex(localIndex) - , globalIndex(globalIndex) - , position(position) - , conversion(conversion) - , samplingRate(samplingRate) - , bitVolts(bitVolts) - , comments(comments) + : m_name(name) + , m_groupName(groupName) + , m_groupIndex(groupIndex) + , m_localIndex(localIndex) + , m_globalIndex(globalIndex) + , m_position(position) + , m_conversion(conversion) + , m_samplingRate(samplingRate) + , m_bitVolts(bitVolts) + , m_comments(comments) { } Channel::~Channel() {} - -float Channel::getConversion() const -{ - return bitVolts / conversion; -} - -float Channel::getSamplingRate() const -{ - return samplingRate; -} - -float Channel::getBitVolts() const -{ - return bitVolts; -} diff --git a/src/Channel.hpp b/src/Channel.hpp index 4166aa8b..b8b61f5d 100644 --- a/src/Channel.hpp +++ b/src/Channel.hpp @@ -37,72 +37,194 @@ class Channel ~Channel(); /** + * @brief Copy constructor + */ + Channel(const Channel& other) = default; + + /** + * @brief Move constructor + */ + Channel(Channel&& other) = default; + + /** + * @brief Assignment operator + */ + Channel& operator=(const Channel& other) = default; + + /** + * @brief Move assignment operator + */ + Channel& operator=(Channel&& other) = default; + + /** * @brief Getter for conversion factor * @return The conversion value. */ - float getConversion() const; + inline float getConversion() const { return m_bitVolts / m_conversion; } - /** - * @brief Getter for samplingRate - * @return The samplingRate value. + /** + * @brief Getter for sampling rate of the channel. + * @return The sampling rate value. */ - float getSamplingRate() const; + inline float getSamplingRate() const { return m_samplingRate; } - /** - * @brief Getter for bitVolts + /** + * @brief Getter for bitVolts floating point value of microvolts per bit * @return The bitVolts value. */ - float getBitVolts() const; + inline float getBitVolts() const { return m_bitVolts; } - /** - * @brief Name of the channel. + /** + * @brief Get the name of the array group the channel belongs to. + * @return The groupName value. */ - std::string name; + inline std::string getGroupName() const { return m_groupName; } - /** - * @brief Name of the array group the channel belongs to. + /** + * @brief Get the name of the channel + * @return The name value. + */ + inline std::string getName() const { return m_name; } + + /** + * @brief Get the array group index the channel belongs to + * @return The groupIndex value. + */ + inline SizeType getGroupIndex() const { return m_groupIndex; } + + /** + * @brief Get the index of the channel within the recording array. + * @return The localIndex value. + */ + inline SizeType getLocalIndex() const { return m_localIndex; } + + /** + * @brief Get the index of the channel across the recording system. + * @return The globalIndex value. + */ + inline SizeType getGlobalIndex() const { return m_globalIndex; } + + /** + * @brief Get the coordinates of channel (x, y, z) within the recording array. + * @return The position value. + */ + inline const std::array& getPosition() const { return m_position; } + + /** + * @brief Get comments about the channel + * @return The comments value. + */ + inline std::string getComments() const { return m_comments; } + + /** + * @brief Set comments about the channel. + * @param comments The comments to set. + */ + inline void setComments(const std::string& comments) { m_comments = comments; } + + /** + * @brief Set coordinates of channel (x, y, z) within the recording array. + * @param position The position to set. + */ + inline void setPosition(const std::array& position) { m_position = position; } + + /** + * @brief Set index of channel across the recording system. + * @param globalIndex The globalIndex to set. + */ + inline void setGlobalIndex(const SizeType globalIndex) { m_globalIndex = globalIndex; } + + /** + * @brief Set index of channel within the recording array. + * @param localIndex The localIndex to set. */ - std::string groupName; + inline void setLocalIndex(const SizeType localIndex) { m_localIndex = localIndex; } + /** + * @brief Set index of array group the channel belongs to. + * @param groupIndex The groupIndex to set. + */ + inline void setGroupIndex(const SizeType groupIndex) { m_groupIndex = groupIndex; } + + /** + * @brief Set name of the channel. + * @param name The name to set. + */ + inline void setName(const std::string& name) { m_name = name; } + + /** + * @brief Set name of the array group the channel belongs to. + * @param groupName The groupName to set. + */ + inline void setGroupName(const std::string& groupName) { m_groupName = groupName; } + + /** + * @brief Set conversion factor. + * @param conversion The conversion to set. + */ + inline void setConversion(const float conversion) { m_conversion = conversion; } + + /** + * @brief Set sampling rate of the channel. + * @param samplingRate The samplingRate to set. + */ + inline void setSamplingRate(const float samplingRate) { m_samplingRate = samplingRate; } + + /** + * @brief Set floating point value of microvolts per bit + * @param bitVolts The bitVolts to set. + */ + inline void setBitVolts(const float bitVolts) { m_bitVolts = bitVolts; } + +private: /** - * @brief Index of array group the channel belongs to. + * @brief Comments about the channel. + */ + std::string m_comments; + + /** + * @brief Coordinates of channel (x, y, z) within the recording array. + */ + std::array m_position; + + /** + * @brief Index of channel across the recording system. */ - SizeType groupIndex; + SizeType m_globalIndex; /** * @brief Index of channel within the recording array. */ - SizeType localIndex; + SizeType m_localIndex; /** - * @brief Index of channel across the recording system. + * @brief Index of array group the channel belongs to. */ - SizeType globalIndex; + SizeType m_groupIndex; /** - * @brief Coordinates of channel (x, y, z) within the recording array. + * @brief Name of the channel. */ - std::array position; + std::string m_name; /** - * @brief Comments about the channel. + * @brief Name of the array group the channel belongs to. */ - std::string comments; + std::string m_groupName; -private: /** * @brief Conversion factor. */ - float conversion; + float m_conversion; /** * @brief Sampling rate of the channel. */ - float samplingRate; + float m_samplingRate; /** * @brief floating point value of microvolts per bit */ - float bitVolts; + float m_bitVolts; }; -} // namespace AQNWB +} // namespace AQNWB \ No newline at end of file diff --git a/src/nwb/NWBFile.cpp b/src/nwb/NWBFile.cpp index 0142634e..8bc4591d 100644 --- a/src/nwb/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -134,7 +134,7 @@ Status NWBFile::createElectricalSeries( const std::string& recordingName = recordingNames[i]; // Setup electrodes and devices - std::string groupName = channelVector[0].groupName; + std::string groupName = channelVector[0].getGroupName(); std::string devicePath = "/general/devices/" + groupName; std::string electrodePath = "/general/extracellular_ephys/" + groupName; std::string electricalSeriesPath = acquisitionPath + "/" + recordingName; @@ -208,7 +208,7 @@ Status NWBFile::createSpikeEventSeries( const std::string& recordingName = recordingNames[i]; // Setup electrodes and devices - std::string groupName = channelVector[0].groupName; + std::string groupName = channelVector[0].getGroupName(); std::string devicePath = "/general/devices/" + groupName; std::string electrodePath = "/general/extracellular_ephys/" + groupName; std::string spikeEventSeriesPath = acquisitionPath + "/" + recordingName; diff --git a/src/nwb/RecordingContainers.cpp b/src/nwb/RecordingContainers.cpp index 4658d551..d80bea8a 100644 --- a/src/nwb/RecordingContainers.cpp +++ b/src/nwb/RecordingContainers.cpp @@ -40,7 +40,7 @@ Status RecordingContainers::writeTimeseriesData( return Status::Failure; // write data and timestamps to datasets - if (channel.localIndex == 0) { + if (channel.getLocalIndex() == 0) { // write with timestamps if it's the first channel return ts->writeData(dataShape, positionOffset, data, timestamps); } else { @@ -62,7 +62,7 @@ Status RecordingContainers::writeElectricalSeriesData( if (es == nullptr) return Status::Failure; - es->writeChannel(channel.localIndex, numSamples, data, timestamps); + es->writeChannel(channel.getLocalIndex(), numSamples, data, timestamps); } Status RecordingContainers::writeSpikeEventData(const SizeType& containerInd, diff --git a/src/nwb/ecephys/ElectricalSeries.cpp b/src/nwb/ecephys/ElectricalSeries.cpp index bf186d27..7f0a9f23 100644 --- a/src/nwb/ecephys/ElectricalSeries.cpp +++ b/src/nwb/ecephys/ElectricalSeries.cpp @@ -23,7 +23,7 @@ ElectricalSeries::ElectricalSeries(const std::string& path, dataType, "volts", // default unit for Electrical Series description, - channelVector[0].comments, + channelVector[0].getComments(), dsetSize, chunkSize, channelVector[0].getConversion(), @@ -45,7 +45,7 @@ void ElectricalSeries::initialize() std::vector electrodeInds(channelVector.size()); std::vector channelConversions(channelVector.size()); for (size_t i = 0; i < channelVector.size(); ++i) { - electrodeInds[i] = channelVector[i].globalIndex; + electrodeInds[i] = channelVector[i].getGlobalIndex(); channelConversions[i] = channelVector[i].getConversion(); } samplesRecorded = SizeArray(channelVector.size(), 0); diff --git a/src/nwb/file/ElectrodeTable.cpp b/src/nwb/file/ElectrodeTable.cpp index 027c9f6a..ea42e21d 100644 --- a/src/nwb/file/ElectrodeTable.cpp +++ b/src/nwb/file/ElectrodeTable.cpp @@ -41,9 +41,9 @@ void ElectrodeTable::addElectrodes(std::vector channels) { // create datasets for (const auto& ch : channels) { - groupReferences.push_back(groupPathBase + ch.groupName); - groupNames.push_back(ch.groupName); - electrodeNumbers.push_back(ch.globalIndex); + groupReferences.push_back(groupPathBase + ch.getGroupName()); + groupNames.push_back(ch.getGroupName()); + electrodeNumbers.push_back(ch.getGlobalIndex()); locationNames.push_back("unknown"); } } diff --git a/tests/examples/testWorkflowExamples.cpp b/tests/examples/testWorkflowExamples.cpp index 64c7d309..18821cb0 100644 --- a/tests/examples/testWorkflowExamples.cpp +++ b/tests/examples/testWorkflowExamples.cpp @@ -70,8 +70,8 @@ TEST_CASE("workflowExamples") const auto& channelVector = mockRecordingArrays[i]; for (const auto& channel : channelVector) { // copy data into buffer - std::copy(mockData[channel.globalIndex].begin() + samplesRecorded, - mockData[channel.globalIndex].begin() + samplesRecorded + std::copy(mockData[channel.getGlobalIndex()].begin() + samplesRecorded, + mockData[channel.getGlobalIndex()].begin() + samplesRecorded + bufferSize, dataBuffer.begin()); std::copy(mockTimestamps.begin() + samplesRecorded, @@ -80,7 +80,7 @@ TEST_CASE("workflowExamples") // write timeseries data std::vector positionOffset = {samplesRecorded, - channel.localIndex}; + channel.getLocalIndex()}; std::vector dataShape = {dataBuffer.size(), 1}; std::unique_ptr intBuffer = transformToInt16( dataBuffer.size(), channel.getBitVolts(), dataBuffer.data()); diff --git a/tests/testRecordingWorkflow.cpp b/tests/testRecordingWorkflow.cpp index d5c8d05a..0a9bafdc 100644 --- a/tests/testRecordingWorkflow.cpp +++ b/tests/testRecordingWorkflow.cpp @@ -65,8 +65,8 @@ TEST_CASE("writeContinuousData", "[recording]") const auto& channelVector = mockRecordingArrays[i]; for (const auto& channel : channelVector) { // copy data into buffer - std::copy(mockData[channel.globalIndex].begin() + samplesRecorded, - mockData[channel.globalIndex].begin() + samplesRecorded + std::copy(mockData[channel.getGlobalIndex()].begin() + samplesRecorded, + mockData[channel.getGlobalIndex()].begin() + samplesRecorded + bufferSize, dataBuffer.begin()); std::copy(mockTimestamps.begin() + samplesRecorded, @@ -75,7 +75,7 @@ TEST_CASE("writeContinuousData", "[recording]") // write timeseries data std::vector positionOffset = {samplesRecorded, - channel.localIndex}; + channel.getLocalIndex()}; std::vector dataShape = {dataBuffer.size(), 1}; recordingContainers->writeTimeseriesData(i, From 43313cb28359e98acb151f2a994a5d417ac436a1 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 11:04:35 -0700 Subject: [PATCH 02/26] Fix formatting --- src/Channel.hpp | 132 ++++++++++++++---------- tests/examples/testWorkflowExamples.cpp | 9 +- tests/testRecordingWorkflow.cpp | 9 +- 3 files changed, 88 insertions(+), 62 deletions(-) diff --git a/src/Channel.hpp b/src/Channel.hpp index b8b61f5d..39cfc4af 100644 --- a/src/Channel.hpp +++ b/src/Channel.hpp @@ -39,142 +39,166 @@ class Channel /** * @brief Copy constructor */ - Channel(const Channel& other) = default; + Channel(const Channel& other) = default; - /** - * @brief Move constructor - */ - Channel(Channel&& other) = default; + /** + * @brief Move constructor + */ + Channel(Channel&& other) = default; - /** - * @brief Assignment operator - */ - Channel& operator=(const Channel& other) = default; + /** + * @brief Assignment operator + */ + Channel& operator=(const Channel& other) = default; - /** - * @brief Move assignment operator - */ - Channel& operator=(Channel&& other) = default; + /** + * @brief Move assignment operator + */ + Channel& operator=(Channel&& other) = default; - /** + /** * @brief Getter for conversion factor * @return The conversion value. */ inline float getConversion() const { return m_bitVolts / m_conversion; } - /** + /** * @brief Getter for sampling rate of the channel. * @return The sampling rate value. */ - inline float getSamplingRate() const { return m_samplingRate; } + inline float getSamplingRate() const { return m_samplingRate; } - /** + /** * @brief Getter for bitVolts floating point value of microvolts per bit * @return The bitVolts value. */ - inline float getBitVolts() const { return m_bitVolts; } + inline float getBitVolts() const { return m_bitVolts; } - /** + /** * @brief Get the name of the array group the channel belongs to. * @return The groupName value. */ - inline std::string getGroupName() const { return m_groupName; } + inline std::string getGroupName() const { return m_groupName; } - /** + /** * @brief Get the name of the channel * @return The name value. */ - inline std::string getName() const { return m_name; } + inline std::string getName() const { return m_name; } - /** + /** * @brief Get the array group index the channel belongs to * @return The groupIndex value. */ - inline SizeType getGroupIndex() const { return m_groupIndex; } + inline SizeType getGroupIndex() const { return m_groupIndex; } - /** + /** * @brief Get the index of the channel within the recording array. * @return The localIndex value. */ - inline SizeType getLocalIndex() const { return m_localIndex; } + inline SizeType getLocalIndex() const { return m_localIndex; } - /** + /** * @brief Get the index of the channel across the recording system. * @return The globalIndex value. */ - inline SizeType getGlobalIndex() const { return m_globalIndex; } + inline SizeType getGlobalIndex() const { return m_globalIndex; } - /** + /** * @brief Get the coordinates of channel (x, y, z) within the recording array. * @return The position value. */ - inline const std::array& getPosition() const { return m_position; } + inline const std::array& getPosition() const { return m_position; } - /** + /** * @brief Get comments about the channel * @return The comments value. */ - inline std::string getComments() const { return m_comments; } + inline std::string getComments() const { return m_comments; } - /** + /** * @brief Set comments about the channel. * @param comments The comments to set. */ - inline void setComments(const std::string& comments) { m_comments = comments; } + inline void setComments(const std::string& comments) + { + m_comments = comments; + } - /** + /** * @brief Set coordinates of channel (x, y, z) within the recording array. * @param position The position to set. */ - inline void setPosition(const std::array& position) { m_position = position; } + inline void setPosition(const std::array& position) + { + m_position = position; + } - /** + /** * @brief Set index of channel across the recording system. * @param globalIndex The globalIndex to set. */ - inline void setGlobalIndex(const SizeType globalIndex) { m_globalIndex = globalIndex; } + inline void setGlobalIndex(const SizeType globalIndex) + { + m_globalIndex = globalIndex; + } - /** + /** * @brief Set index of channel within the recording array. * @param localIndex The localIndex to set. */ - inline void setLocalIndex(const SizeType localIndex) { m_localIndex = localIndex; } + inline void setLocalIndex(const SizeType localIndex) + { + m_localIndex = localIndex; + } - /** + /** * @brief Set index of array group the channel belongs to. * @param groupIndex The groupIndex to set. */ - inline void setGroupIndex(const SizeType groupIndex) { m_groupIndex = groupIndex; } + inline void setGroupIndex(const SizeType groupIndex) + { + m_groupIndex = groupIndex; + } - /** + /** * @brief Set name of the channel. * @param name The name to set. */ - inline void setName(const std::string& name) { m_name = name; } + inline void setName(const std::string& name) { m_name = name; } - /** + /** * @brief Set name of the array group the channel belongs to. * @param groupName The groupName to set. */ - inline void setGroupName(const std::string& groupName) { m_groupName = groupName; } + inline void setGroupName(const std::string& groupName) + { + m_groupName = groupName; + } - /** + /** * @brief Set conversion factor. * @param conversion The conversion to set. */ - inline void setConversion(const float conversion) { m_conversion = conversion; } + inline void setConversion(const float conversion) + { + m_conversion = conversion; + } - /** + /** * @brief Set sampling rate of the channel. * @param samplingRate The samplingRate to set. */ - inline void setSamplingRate(const float samplingRate) { m_samplingRate = samplingRate; } + inline void setSamplingRate(const float samplingRate) + { + m_samplingRate = samplingRate; + } - /** + /** * @brief Set floating point value of microvolts per bit * @param bitVolts The bitVolts to set. */ - inline void setBitVolts(const float bitVolts) { m_bitVolts = bitVolts; } + inline void setBitVolts(const float bitVolts) { m_bitVolts = bitVolts; } private: /** @@ -182,12 +206,12 @@ class Channel */ std::string m_comments; - /** + /** * @brief Coordinates of channel (x, y, z) within the recording array. */ std::array m_position; - /** + /** * @brief Index of channel across the recording system. */ SizeType m_globalIndex; diff --git a/tests/examples/testWorkflowExamples.cpp b/tests/examples/testWorkflowExamples.cpp index 18821cb0..9edde1cb 100644 --- a/tests/examples/testWorkflowExamples.cpp +++ b/tests/examples/testWorkflowExamples.cpp @@ -70,10 +70,11 @@ TEST_CASE("workflowExamples") const auto& channelVector = mockRecordingArrays[i]; for (const auto& channel : channelVector) { // copy data into buffer - std::copy(mockData[channel.getGlobalIndex()].begin() + samplesRecorded, - mockData[channel.getGlobalIndex()].begin() + samplesRecorded - + bufferSize, - dataBuffer.begin()); + std::copy( + mockData[channel.getGlobalIndex()].begin() + samplesRecorded, + mockData[channel.getGlobalIndex()].begin() + samplesRecorded + + bufferSize, + dataBuffer.begin()); std::copy(mockTimestamps.begin() + samplesRecorded, mockTimestamps.begin() + samplesRecorded + bufferSize, timestampsBuffer.begin()); diff --git a/tests/testRecordingWorkflow.cpp b/tests/testRecordingWorkflow.cpp index 0a9bafdc..69b2326f 100644 --- a/tests/testRecordingWorkflow.cpp +++ b/tests/testRecordingWorkflow.cpp @@ -65,10 +65,11 @@ TEST_CASE("writeContinuousData", "[recording]") const auto& channelVector = mockRecordingArrays[i]; for (const auto& channel : channelVector) { // copy data into buffer - std::copy(mockData[channel.getGlobalIndex()].begin() + samplesRecorded, - mockData[channel.getGlobalIndex()].begin() + samplesRecorded - + bufferSize, - dataBuffer.begin()); + std::copy( + mockData[channel.getGlobalIndex()].begin() + samplesRecorded, + mockData[channel.getGlobalIndex()].begin() + samplesRecorded + + bufferSize, + dataBuffer.begin()); std::copy(mockTimestamps.begin() + samplesRecorded, mockTimestamps.begin() + samplesRecorded + bufferSize, timestampsBuffer.begin()); From 5c69181326ad3654098dd115680b693209a1b179 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 11:16:17 -0700 Subject: [PATCH 03/26] Update names in RecordingContainers --- src/nwb/NWBFile.cpp | 4 ++-- src/nwb/RecordingContainers.cpp | 11 ++++++++--- src/nwb/RecordingContainers.hpp | 17 +++++++++++++++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/nwb/NWBFile.cpp b/src/nwb/NWBFile.cpp index 8bc4591d..64804ff6 100644 --- a/src/nwb/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -162,7 +162,7 @@ Status NWBFile::createElectricalSeries( SizeArray {CHUNK_XSIZE, 0}); electricalSeries->initialize(); recordingContainers->addContainer(std::move(electricalSeries)); - containerIndexes.push_back(recordingContainers->containers.size() - 1); + containerIndexes.push_back(recordingContainers->size() - 1); } // write electrode information to datasets @@ -245,7 +245,7 @@ Status NWBFile::createSpikeEventSeries( chunkSize); spikeEventSeries->initialize(); recordingContainers->addContainer(std::move(spikeEventSeries)); - containerIndexes.push_back(recordingContainers->containers.size() - 1); + containerIndexes.push_back(recordingContainers->size() - 1); } // write electrode information to datasets diff --git a/src/nwb/RecordingContainers.cpp b/src/nwb/RecordingContainers.cpp index d80bea8a..4786b5c7 100644 --- a/src/nwb/RecordingContainers.cpp +++ b/src/nwb/RecordingContainers.cpp @@ -14,15 +14,15 @@ RecordingContainers::~RecordingContainers() {} void RecordingContainers::addContainer(std::unique_ptr container) { - this->containers.push_back(std::move(container)); + this->m_containers.push_back(std::move(container)); } Container* RecordingContainers::getContainer(const SizeType& containerInd) { - if (containerInd >= this->containers.size()) { + if (containerInd >= this->m_containers.size()) { return nullptr; } else { - return this->containers[containerInd].get(); + return this->m_containers[containerInd].get(); } } @@ -79,3 +79,8 @@ Status RecordingContainers::writeSpikeEventData(const SizeType& containerInd, ses->writeSpike(numSamples, numChannels, data, timestamps); } + +SizeType RecordingContainers::size() +{ + return this->m_containers.size(); +} \ No newline at end of file diff --git a/src/nwb/RecordingContainers.hpp b/src/nwb/RecordingContainers.hpp index f38d84c7..c1dfd5b1 100644 --- a/src/nwb/RecordingContainers.hpp +++ b/src/nwb/RecordingContainers.hpp @@ -105,8 +105,21 @@ class RecordingContainers const void* data, const void* timestamps); - std::vector> containers; - std::string name; + /** + * @brief Get the number of recording containers + */ + SizeType size(); + +private: + /** + * @brief The Containers used for recording + */ + std::vector> m_containers; + + /** + * @brief The name of the collection of recording containers + */ + std::string m_name; }; } // namespace AQNWB::NWB From 0685e574d84805f716a2e10f6f86c06836942b76 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 11:26:29 -0700 Subject: [PATCH 04/26] Update members in NWBFile --- src/nwb/NWBFile.cpp | 23 ++++++++++++----------- src/nwb/NWBFile.hpp | 16 +++++++++++----- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/nwb/NWBFile.cpp b/src/nwb/NWBFile.cpp index 64804ff6..bcb2b2ee 100644 --- a/src/nwb/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -31,8 +31,9 @@ std::vector NWBFile::emptyContainerIndexes = {}; // NWBFile NWBFile::NWBFile(const std::string& idText, std::shared_ptr io) - : identifierText(idText) - , io(io) + : Container("/", io), + m_identifierText(idText) + { } @@ -95,7 +96,7 @@ Status NWBFile::createFileStructure(std::string description, io->createStringDataSet("/session_description", description); io->createStringDataSet("/session_start_time", time); io->createStringDataSet("/timestamps_reference_time", time); - io->createStringDataSet("/identifier", identifierText); + io->createStringDataSet("/identifier", this->m_identifierText); return Status::Success; } @@ -119,12 +120,12 @@ Status NWBFile::createElectricalSeries( bool electrodeTableCreated = io->objectExists(ElectrodeTable::electrodeTablePath); if (!electrodeTableCreated) { - elecTable = std::make_unique(io); - elecTable->initialize(); + this->m_electrodeTable = std::make_unique(io); + this->m_electrodeTable->initialize(); // Add electrode information to table (does not write to datasets yet) for (const auto& channelVector : recordingArrays) { - elecTable->addElectrodes(channelVector); + this->m_electrodeTable->addElectrodes(channelVector); } } @@ -168,7 +169,7 @@ Status NWBFile::createElectricalSeries( // write electrode information to datasets // (requires that the ElectrodeGroup has been written) if (!electrodeTableCreated) { - elecTable->finalize(); + this->m_electrodeTable->finalize(); } return Status::Success; @@ -193,12 +194,12 @@ Status NWBFile::createSpikeEventSeries( bool electrodeTableCreated = io->objectExists(ElectrodeTable::electrodeTablePath); if (!electrodeTableCreated) { - elecTable = std::make_unique(io); - elecTable->initialize(); + this->m_electrodeTable = std::make_unique(io); + this->m_electrodeTable->initialize(); // Add electrode information to table (does not write to datasets yet) for (const auto& channelVector : recordingArrays) { - elecTable->addElectrodes(channelVector); + this->m_electrodeTable->addElectrodes(channelVector); } } @@ -251,7 +252,7 @@ Status NWBFile::createSpikeEventSeries( // write electrode information to datasets // (requires that the ElectrodeGroup has been written) if (!electrodeTableCreated) { - elecTable->finalize(); + this->m_electrodeTable->finalize(); } return Status::Success; diff --git a/src/nwb/NWBFile.hpp b/src/nwb/NWBFile.hpp index a5a5c212..c20ccb64 100644 --- a/src/nwb/NWBFile.hpp +++ b/src/nwb/NWBFile.hpp @@ -7,6 +7,7 @@ #include #include +#include "nwb/hdmf/base/Container.hpp" #include "BaseIO.hpp" #include "Types.hpp" #include "nwb/RecordingContainers.hpp" @@ -24,7 +25,7 @@ namespace AQNWB::NWB * @brief The NWBFile class provides an interface for setting up and managing * the NWB file. */ -class NWBFile +class NWBFile : public Container { public: /** @@ -152,11 +153,16 @@ class NWBFile const std::array, N>& specVariables); - std::unique_ptr elecTable; - const std::string identifierText; - std::shared_ptr io; - static std::vector emptyContainerIndexes; inline const static std::string acquisitionPath = "/acquisition"; + static std::vector emptyContainerIndexes; + +private: + /** + * @brief The ElectrodeTable for the file + */ + std::unique_ptr m_electrodeTable; + const std::string m_identifierText; + }; } // namespace AQNWB::NWB \ No newline at end of file From f4583b34799077bf20f9842ec5d14030fc5d042f Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 12:03:11 -0700 Subject: [PATCH 05/26] Update members in Container --- src/nwb/NWBFile.cpp | 86 ++++++++++++++-------------- src/nwb/base/TimeSeries.cpp | 16 +++--- src/nwb/device/Device.cpp | 4 +- src/nwb/ecephys/ElectricalSeries.cpp | 10 ++-- src/nwb/file/ElectrodeGroup.cpp | 6 +- src/nwb/file/ElectrodeTable.cpp | 12 ++-- src/nwb/hdmf/base/Container.cpp | 12 +--- src/nwb/hdmf/base/Container.hpp | 6 +- src/nwb/hdmf/table/DynamicTable.cpp | 20 +++---- 9 files changed, 83 insertions(+), 89 deletions(-) diff --git a/src/nwb/NWBFile.cpp b/src/nwb/NWBFile.cpp index bcb2b2ee..7c9a5d33 100644 --- a/src/nwb/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -42,44 +42,44 @@ NWBFile::~NWBFile() {} Status NWBFile::initialize(const std::string description, const std::string dataCollection) { - if (std::filesystem::exists(io->getFileName())) { - return io->open(false); + if (std::filesystem::exists(this->m_io->getFileName())) { + return this->m_io->open(false); } else { - io->open(true); + this->m_io->open(true); return createFileStructure(description, dataCollection); } } Status NWBFile::finalize() { - return io->close(); + return this->m_io->close(); } Status NWBFile::createFileStructure(std::string description, std::string dataCollection) { - if (!io->canModifyObjects()) { + if (!this->m_io->canModifyObjects()) { return Status::Failure; } - io->createCommonNWBAttributes("/", "core", "NWBFile", ""); - io->createAttribute(AQNWB::SPEC::CORE::version, "/", "nwb_version"); - - io->createGroup("/acquisition"); - io->createGroup("/analysis"); - io->createGroup("/processing"); - io->createGroup("/stimulus"); - io->createGroup("/stimulus/presentation"); - io->createGroup("/stimulus/templates"); - io->createGroup("/general"); - io->createGroup("/general/devices"); - io->createGroup("/general/extracellular_ephys"); + this->m_io->createCommonNWBAttributes("/", "core", "NWBFile", ""); + this->m_io->createAttribute(AQNWB::SPEC::CORE::version, "/", "nwb_version"); + + this->m_io->createGroup("/acquisition"); + this->m_io->createGroup("/analysis"); + this->m_io->createGroup("/processing"); + this->m_io->createGroup("/stimulus"); + this->m_io->createGroup("/stimulus/presentation"); + this->m_io->createGroup("/stimulus/templates"); + this->m_io->createGroup("/general"); + this->m_io->createGroup("/general/devices"); + this->m_io->createGroup("/general/extracellular_ephys"); if (dataCollection != "") { - io->createStringDataSet("/general/data_collection", dataCollection); + this->m_io->createStringDataSet("/general/data_collection", dataCollection); } - io->createGroup("/specifications"); - io->createReferenceAttribute("/specifications", "/", ".specloc"); + this->m_io->createGroup("/specifications"); + this->m_io->createReferenceAttribute("/specifications", "/", ".specloc"); cacheSpecifications( "core", AQNWB::SPEC::CORE::version, AQNWB::SPEC::CORE::specVariables); @@ -92,11 +92,11 @@ Status NWBFile::createFileStructure(std::string description, std::string time = getCurrentTime(); std::vector timeVec = {time}; - io->createStringDataSet("/file_create_date", timeVec); - io->createStringDataSet("/session_description", description); - io->createStringDataSet("/session_start_time", time); - io->createStringDataSet("/timestamps_reference_time", time); - io->createStringDataSet("/identifier", this->m_identifierText); + this->m_io->createStringDataSet("/file_create_date", timeVec); + this->m_io->createStringDataSet("/session_description", description); + this->m_io->createStringDataSet("/session_start_time", time); + this->m_io->createStringDataSet("/timestamps_reference_time", time); + this->m_io->createStringDataSet("/identifier", this->m_identifierText); return Status::Success; } @@ -108,7 +108,7 @@ Status NWBFile::createElectricalSeries( RecordingContainers* recordingContainers, std::vector& containerIndexes) { - if (!io->canModifyObjects()) { + if (!this->m_io->canModifyObjects()) { return Status::Failure; } @@ -118,9 +118,9 @@ Status NWBFile::createElectricalSeries( // Setup electrode table if it was not yet created bool electrodeTableCreated = - io->objectExists(ElectrodeTable::electrodeTablePath); + this->m_io->objectExists(ElectrodeTable::electrodeTablePath); if (!electrodeTableCreated) { - this->m_electrodeTable = std::make_unique(io); + this->m_electrodeTable = std::make_unique(this->m_io); this->m_electrodeTable->initialize(); // Add electrode information to table (does not write to datasets yet) @@ -142,19 +142,19 @@ 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, "description", "unknown"); + if (!this->m_io->objectExists(devicePath)) { + Device device = Device(devicePath, this->m_io, "description", "unknown"); device.initialize(); ElectrodeGroup elecGroup = - ElectrodeGroup(electrodePath, io, "description", "unknown", device); + ElectrodeGroup(electrodePath, this->m_io, "description", "unknown", device); elecGroup.initialize(); } // Setup electrical series datasets auto electricalSeries = std::make_unique( electricalSeriesPath, - io, + this->m_io, dataType, channelVector, "Stores continuously sampled voltage data from an " @@ -182,7 +182,7 @@ Status NWBFile::createSpikeEventSeries( RecordingContainers* recordingContainers, std::vector& containerIndexes) { - if (!io->canModifyObjects()) { + if (!this->m_io->canModifyObjects()) { return Status::Failure; } @@ -192,9 +192,9 @@ Status NWBFile::createSpikeEventSeries( // Setup electrode table if it was not yet created bool electrodeTableCreated = - io->objectExists(ElectrodeTable::electrodeTablePath); + this->m_io->objectExists(ElectrodeTable::electrodeTablePath); if (!electrodeTableCreated) { - this->m_electrodeTable = std::make_unique(io); + this->m_electrodeTable = std::make_unique(this->m_io); this->m_electrodeTable->initialize(); // Add electrode information to table (does not write to datasets yet) @@ -216,12 +216,12 @@ Status NWBFile::createSpikeEventSeries( // Check if device exists for groupName, create device and electrode group // if not - if (!io->objectExists(devicePath)) { - Device device = Device(devicePath, io, "description", "unknown"); + if (!this->m_io->objectExists(devicePath)) { + Device device = Device(devicePath, this->m_io, "description", "unknown"); device.initialize(); ElectrodeGroup elecGroup = - ElectrodeGroup(electrodePath, io, "description", "unknown", device); + ElectrodeGroup(electrodePath, this->m_io, "description", "unknown", device); elecGroup.initialize(); } @@ -238,7 +238,7 @@ Status NWBFile::createSpikeEventSeries( auto spikeEventSeries = std::make_unique( spikeEventSeriesPath, - io, + this->m_io, dataType, channelVector, "Stores spike waveforms from an extracellular ephys recording", @@ -265,11 +265,11 @@ void NWBFile::cacheSpecifications( const std::array, N>& specVariables) { - io->createGroup("/specifications/" + specPath); - io->createGroup("/specifications/" + specPath + "/" + versionNumber); + this->m_io->createGroup("/specifications/" + specPath); + this->m_io->createGroup("/specifications/" + specPath + "/" + versionNumber); for (const auto& [name, content] : specVariables) { - io->createStringDataSet("/specifications/" + specPath + "/" + versionNumber + this->m_io->createStringDataSet("/specifications/" + specPath + "/" + versionNumber + "/" + std::string(name), std::string(content)); } @@ -283,5 +283,5 @@ std::unique_ptr NWBFile::createRecordingData( const std::string& path) { return std::unique_ptr( - io->createArrayDataSet(type, size, chunking, path)); + this->m_io->createArrayDataSet(type, size, chunking, path)); } diff --git a/src/nwb/base/TimeSeries.cpp b/src/nwb/base/TimeSeries.cpp index a9c008b3..306bbbcb 100644 --- a/src/nwb/base/TimeSeries.cpp +++ b/src/nwb/base/TimeSeries.cpp @@ -37,19 +37,19 @@ void TimeSeries::initialize() Container::initialize(); // setup attributes - io->createCommonNWBAttributes(path, "core", neurodataType, description); - io->createAttribute(comments, path, "comments"); + this->m_io->createCommonNWBAttributes(this->m_path, "core", neurodataType, description); + this->m_io->createAttribute(comments, this->m_path, "comments"); // setup datasets - this->data = std::unique_ptr(io->createArrayDataSet( - dataType, dsetSize, chunkSize, getPath() + "/data")); - io->createDataAttributes(getPath(), conversion, resolution, unit); + this->data = std::unique_ptr(this->m_io->createArrayDataSet( + dataType, dsetSize, chunkSize, this->m_path + "/data")); + this->m_io->createDataAttributes(this->m_path, conversion, resolution, unit); SizeArray tsDsetSize = { dsetSize[0]}; // timestamps match data along first dimension - this->timestamps = std::unique_ptr(io->createArrayDataSet( - this->timestampsType, tsDsetSize, chunkSize, getPath() + "/timestamps")); - io->createTimestampsAttributes(getPath()); + this->timestamps = std::unique_ptr(this->m_io->createArrayDataSet( + this->timestampsType, tsDsetSize, chunkSize, this->m_path + "/timestamps")); + this->m_io->createTimestampsAttributes(this->m_path); } Status TimeSeries::writeData(const std::vector& dataShape, diff --git a/src/nwb/device/Device.cpp b/src/nwb/device/Device.cpp index 262d9207..b44a0749 100644 --- a/src/nwb/device/Device.cpp +++ b/src/nwb/device/Device.cpp @@ -21,8 +21,8 @@ void Device::initialize() { Container::initialize(); - io->createCommonNWBAttributes(path, "core", "Device", description); - io->createAttribute(manufacturer, path, "manufacturer"); + this->m_io->createCommonNWBAttributes(this->m_path, "core", "Device", description); + this->m_io->createAttribute(manufacturer, this->m_path, "manufacturer"); } // Getter for manufacturer diff --git a/src/nwb/ecephys/ElectricalSeries.cpp b/src/nwb/ecephys/ElectricalSeries.cpp index 7f0a9f23..2331ccc6 100644 --- a/src/nwb/ecephys/ElectricalSeries.cpp +++ b/src/nwb/ecephys/ElectricalSeries.cpp @@ -52,7 +52,7 @@ void ElectricalSeries::initialize() // make channel conversion dataset channelConversion = std::unique_ptr( - io->createArrayDataSet(BaseDataType::F32, + this->m_io->createArrayDataSet(BaseDataType::F32, SizeArray {1}, chunkSize, getPath() + "/channel_conversion")); @@ -60,21 +60,21 @@ void ElectricalSeries::initialize() std::vector(1, channelVector.size()), BaseDataType::F32, &channelConversions[0]); - io->createCommonNWBAttributes(getPath() + "/channel_conversion", + this->m_io->createCommonNWBAttributes(getPath() + "/channel_conversion", "hdmf-common", "", "Bit volts values for all channels"); // make electrodes dataset - electrodesDataset = std::unique_ptr(io->createArrayDataSet( + electrodesDataset = std::unique_ptr(this->m_io->createArrayDataSet( BaseDataType::I32, SizeArray {1}, chunkSize, getPath() + "/electrodes")); electrodesDataset->writeDataBlock( std::vector(1, channelVector.size()), BaseDataType::I32, &electrodeInds[0]); - io->createCommonNWBAttributes( + this->m_io->createCommonNWBAttributes( getPath() + "/electrodes", "hdmf-common", "DynamicTableRegion", ""); - io->createReferenceAttribute( + this->m_io->createReferenceAttribute( ElectrodeTable::electrodeTablePath, getPath() + "/electrodes", "table"); } diff --git a/src/nwb/file/ElectrodeGroup.cpp b/src/nwb/file/ElectrodeGroup.cpp index b5beaa03..77ac2743 100644 --- a/src/nwb/file/ElectrodeGroup.cpp +++ b/src/nwb/file/ElectrodeGroup.cpp @@ -24,9 +24,9 @@ void ElectrodeGroup::initialize() { Container::initialize(); - io->createCommonNWBAttributes(path, "core", "ElectrodeGroup", description); - io->createAttribute(location, path, "location"); - io->createLink("/" + path + "/device", "/" + device.getPath()); + this->m_io->createCommonNWBAttributes(this->m_path, "core", "ElectrodeGroup", description); + this->m_io->createAttribute(location, this->m_path, "location"); + this->m_io->createLink("/" + this->m_path + "/device", "/" + device.getPath()); } // Getter for description diff --git a/src/nwb/file/ElectrodeTable.cpp b/src/nwb/file/ElectrodeTable.cpp index ea42e21d..b0b2a5d4 100644 --- a/src/nwb/file/ElectrodeTable.cpp +++ b/src/nwb/file/ElectrodeTable.cpp @@ -25,16 +25,16 @@ void ElectrodeTable::initialize() DynamicTable::initialize(); electrodeDataset->dataset = - std::unique_ptr(io->createArrayDataSet( - BaseDataType::I32, SizeArray {1}, SizeArray {1}, path + "id")); + std::unique_ptr(this->m_io->createArrayDataSet( + BaseDataType::I32, SizeArray {1}, SizeArray {1}, this->m_path + "id")); groupNamesDataset->dataset = std::unique_ptr( - io->createArrayDataSet(BaseDataType::STR(250), + this->m_io->createArrayDataSet(BaseDataType::STR(250), SizeArray {0}, SizeArray {1}, - path + "group_name")); + this->m_path + "group_name")); locationsDataset - ->dataset = std::unique_ptr(io->createArrayDataSet( - BaseDataType::STR(250), SizeArray {0}, SizeArray {1}, path + "location")); + ->dataset = std::unique_ptr(this->m_io->createArrayDataSet( + BaseDataType::STR(250), SizeArray {0}, SizeArray {1}, this->m_path + "location")); } void ElectrodeTable::addElectrodes(std::vector channels) diff --git a/src/nwb/hdmf/base/Container.cpp b/src/nwb/hdmf/base/Container.cpp index 525d82ed..f2221cb8 100644 --- a/src/nwb/hdmf/base/Container.cpp +++ b/src/nwb/hdmf/base/Container.cpp @@ -6,8 +6,8 @@ using namespace AQNWB::NWB; /** Constructor */ Container::Container(const std::string& path, std::shared_ptr io) - : path(path) - , io(io) + : m_path(path) + , m_io(io) { } @@ -17,11 +17,5 @@ Container::~Container() {} /** Initialize */ void Container::initialize() { - io->createGroup(path); -} - -/** Getter for path */ -std::string Container::getPath() const -{ - return path; + m_io->createGroup(m_path); } diff --git a/src/nwb/hdmf/base/Container.hpp b/src/nwb/hdmf/base/Container.hpp index 1d89c875..b1ecdc6e 100644 --- a/src/nwb/hdmf/base/Container.hpp +++ b/src/nwb/hdmf/base/Container.hpp @@ -35,17 +35,17 @@ class Container * @brief Gets the path of the container. * @return The path of the container. */ - std::string getPath() const; + inline std::string getPath() const { return m_path; } protected: /** * @brief The path of the container. */ - std::string path; + std::string m_path; /** * @brief A shared pointer to the IO object. */ - std::shared_ptr io; + std::shared_ptr m_io; }; } // namespace AQNWB::NWB diff --git a/src/nwb/hdmf/table/DynamicTable.cpp b/src/nwb/hdmf/table/DynamicTable.cpp index d8b8c989..c54d94ab 100644 --- a/src/nwb/hdmf/table/DynamicTable.cpp +++ b/src/nwb/hdmf/table/DynamicTable.cpp @@ -21,9 +21,9 @@ void DynamicTable::initialize() { Container::initialize(); - io->createCommonNWBAttributes( - path, "hdmf-common", "DynamicTable", getDescription()); - io->createAttribute(getColNames(), path, "colnames"); + this->m_io->createCommonNWBAttributes( + this->m_path, "hdmf-common", "DynamicTable", getDescription()); + this->m_io->createAttribute(getColNames(), this->m_path, "colnames"); } /** Add column to table */ @@ -41,8 +41,8 @@ void DynamicTable::addColumn(const std::string& name, std::vector(1, 1), BaseDataType::STR(values[i].size() + 1), values[i].c_str()); // TODO - add tests for this - io->createCommonNWBAttributes( - path + name, "hdmf-common", "VectorData", colDescription); + this->m_io->createCommonNWBAttributes( + this->m_path + name, "hdmf-common", "VectorData", colDescription); } } @@ -54,8 +54,8 @@ void DynamicTable::setRowIDs(std::unique_ptr& elementIDs, } else { elementIDs->dataset->writeDataBlock( std::vector(1, values.size()), BaseDataType::I32, &values[0]); - io->createCommonNWBAttributes( - path + "id", "hdmf-common", "ElementIdentifiers"); + this->m_io->createCommonNWBAttributes( + this->m_path + "id", "hdmf-common", "ElementIdentifiers"); } } @@ -66,9 +66,9 @@ void DynamicTable::addColumn(const std::string& name, if (values.empty()) { std::cerr << "Data to add to column is empty" << std::endl; } else { - io->createReferenceDataSet(path + name, values); - io->createCommonNWBAttributes( - path + name, "hdmf-common", "VectorData", colDescription); + this->m_io->createReferenceDataSet(this->m_path + name, values); + this->m_io->createCommonNWBAttributes( + this->m_path + name, "hdmf-common", "VectorData", colDescription); } } From 615b03ccd618a75cebc4c18c2520fbacf7415bd1 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 12:03:34 -0700 Subject: [PATCH 06/26] Fix formatting --- src/nwb/NWBFile.cpp | 19 ++++++++++--------- src/nwb/NWBFile.hpp | 3 +-- src/nwb/RecordingContainers.cpp | 4 ++-- src/nwb/RecordingContainers.hpp | 12 ++++++------ src/nwb/base/TimeSeries.cpp | 15 ++++++++++----- src/nwb/device/Device.cpp | 3 ++- src/nwb/ecephys/ElectricalSeries.cpp | 19 +++++++++++-------- src/nwb/file/ElectrodeGroup.cpp | 6 ++++-- src/nwb/file/ElectrodeTable.cpp | 22 +++++++++++++--------- 9 files changed, 59 insertions(+), 44 deletions(-) diff --git a/src/nwb/NWBFile.cpp b/src/nwb/NWBFile.cpp index 7c9a5d33..c8738dd3 100644 --- a/src/nwb/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -31,8 +31,8 @@ std::vector NWBFile::emptyContainerIndexes = {}; // NWBFile NWBFile::NWBFile(const std::string& idText, std::shared_ptr io) - : Container("/", io), - m_identifierText(idText) + : Container("/", io) + , m_identifierText(idText) { } @@ -146,8 +146,8 @@ Status NWBFile::createElectricalSeries( Device device = Device(devicePath, this->m_io, "description", "unknown"); device.initialize(); - ElectrodeGroup elecGroup = - ElectrodeGroup(electrodePath, this->m_io, "description", "unknown", device); + ElectrodeGroup elecGroup = ElectrodeGroup( + electrodePath, this->m_io, "description", "unknown", device); elecGroup.initialize(); } @@ -220,8 +220,8 @@ Status NWBFile::createSpikeEventSeries( Device device = Device(devicePath, this->m_io, "description", "unknown"); device.initialize(); - ElectrodeGroup elecGroup = - ElectrodeGroup(electrodePath, this->m_io, "description", "unknown", device); + ElectrodeGroup elecGroup = ElectrodeGroup( + electrodePath, this->m_io, "description", "unknown", device); elecGroup.initialize(); } @@ -269,9 +269,10 @@ void NWBFile::cacheSpecifications( this->m_io->createGroup("/specifications/" + specPath + "/" + versionNumber); for (const auto& [name, content] : specVariables) { - this->m_io->createStringDataSet("/specifications/" + specPath + "/" + versionNumber - + "/" + std::string(name), - std::string(content)); + this->m_io->createStringDataSet("/specifications/" + specPath + "/" + + versionNumber + "/" + + std::string(name), + std::string(content)); } } diff --git a/src/nwb/NWBFile.hpp b/src/nwb/NWBFile.hpp index c20ccb64..ece6a64e 100644 --- a/src/nwb/NWBFile.hpp +++ b/src/nwb/NWBFile.hpp @@ -7,12 +7,12 @@ #include #include -#include "nwb/hdmf/base/Container.hpp" #include "BaseIO.hpp" #include "Types.hpp" #include "nwb/RecordingContainers.hpp" #include "nwb/base/TimeSeries.hpp" #include "nwb/file/ElectrodeTable.hpp" +#include "nwb/hdmf/base/Container.hpp" /*! * \namespace AQNWB::NWB @@ -162,7 +162,6 @@ class NWBFile : public Container */ std::unique_ptr m_electrodeTable; const std::string m_identifierText; - }; } // namespace AQNWB::NWB \ No newline at end of file diff --git a/src/nwb/RecordingContainers.cpp b/src/nwb/RecordingContainers.cpp index 4786b5c7..4aafd36e 100644 --- a/src/nwb/RecordingContainers.cpp +++ b/src/nwb/RecordingContainers.cpp @@ -80,7 +80,7 @@ Status RecordingContainers::writeSpikeEventData(const SizeType& containerInd, ses->writeSpike(numSamples, numChannels, data, timestamps); } -SizeType RecordingContainers::size() +SizeType RecordingContainers::size() { - return this->m_containers.size(); + return this->m_containers.size(); } \ No newline at end of file diff --git a/src/nwb/RecordingContainers.hpp b/src/nwb/RecordingContainers.hpp index c1dfd5b1..6b47056f 100644 --- a/src/nwb/RecordingContainers.hpp +++ b/src/nwb/RecordingContainers.hpp @@ -106,19 +106,19 @@ class RecordingContainers const void* timestamps); /** - * @brief Get the number of recording containers - */ + * @brief Get the number of recording containers + */ SizeType size(); private: /** - * @brief The Containers used for recording - */ + * @brief The Containers used for recording + */ std::vector> m_containers; /** - * @brief The name of the collection of recording containers - */ + * @brief The name of the collection of recording containers + */ std::string m_name; }; diff --git a/src/nwb/base/TimeSeries.cpp b/src/nwb/base/TimeSeries.cpp index 306bbbcb..b520a08a 100644 --- a/src/nwb/base/TimeSeries.cpp +++ b/src/nwb/base/TimeSeries.cpp @@ -37,18 +37,23 @@ void TimeSeries::initialize() Container::initialize(); // setup attributes - this->m_io->createCommonNWBAttributes(this->m_path, "core", neurodataType, description); + this->m_io->createCommonNWBAttributes( + this->m_path, "core", neurodataType, description); this->m_io->createAttribute(comments, this->m_path, "comments"); // setup datasets - this->data = std::unique_ptr(this->m_io->createArrayDataSet( - dataType, dsetSize, chunkSize, this->m_path + "/data")); + this->data = + std::unique_ptr(this->m_io->createArrayDataSet( + dataType, dsetSize, chunkSize, this->m_path + "/data")); this->m_io->createDataAttributes(this->m_path, conversion, resolution, unit); SizeArray tsDsetSize = { dsetSize[0]}; // timestamps match data along first dimension - this->timestamps = std::unique_ptr(this->m_io->createArrayDataSet( - this->timestampsType, tsDsetSize, chunkSize, this->m_path + "/timestamps")); + this->timestamps = std::unique_ptr( + this->m_io->createArrayDataSet(this->timestampsType, + tsDsetSize, + chunkSize, + this->m_path + "/timestamps")); this->m_io->createTimestampsAttributes(this->m_path); } diff --git a/src/nwb/device/Device.cpp b/src/nwb/device/Device.cpp index b44a0749..905dfd5a 100644 --- a/src/nwb/device/Device.cpp +++ b/src/nwb/device/Device.cpp @@ -21,7 +21,8 @@ void Device::initialize() { Container::initialize(); - this->m_io->createCommonNWBAttributes(this->m_path, "core", "Device", description); + this->m_io->createCommonNWBAttributes( + this->m_path, "core", "Device", description); this->m_io->createAttribute(manufacturer, this->m_path, "manufacturer"); } diff --git a/src/nwb/ecephys/ElectricalSeries.cpp b/src/nwb/ecephys/ElectricalSeries.cpp index 2331ccc6..ff5bbc90 100644 --- a/src/nwb/ecephys/ElectricalSeries.cpp +++ b/src/nwb/ecephys/ElectricalSeries.cpp @@ -53,21 +53,24 @@ void ElectricalSeries::initialize() // make channel conversion dataset channelConversion = std::unique_ptr( this->m_io->createArrayDataSet(BaseDataType::F32, - SizeArray {1}, - chunkSize, - getPath() + "/channel_conversion")); + SizeArray {1}, + chunkSize, + getPath() + "/channel_conversion")); channelConversion->writeDataBlock( std::vector(1, channelVector.size()), BaseDataType::F32, &channelConversions[0]); this->m_io->createCommonNWBAttributes(getPath() + "/channel_conversion", - "hdmf-common", - "", - "Bit volts values for all channels"); + "hdmf-common", + "", + "Bit volts values for all channels"); // make electrodes dataset - electrodesDataset = std::unique_ptr(this->m_io->createArrayDataSet( - BaseDataType::I32, SizeArray {1}, chunkSize, getPath() + "/electrodes")); + electrodesDataset = std::unique_ptr( + this->m_io->createArrayDataSet(BaseDataType::I32, + SizeArray {1}, + chunkSize, + getPath() + "/electrodes")); electrodesDataset->writeDataBlock( std::vector(1, channelVector.size()), BaseDataType::I32, diff --git a/src/nwb/file/ElectrodeGroup.cpp b/src/nwb/file/ElectrodeGroup.cpp index 77ac2743..c065cb7c 100644 --- a/src/nwb/file/ElectrodeGroup.cpp +++ b/src/nwb/file/ElectrodeGroup.cpp @@ -24,9 +24,11 @@ void ElectrodeGroup::initialize() { Container::initialize(); - this->m_io->createCommonNWBAttributes(this->m_path, "core", "ElectrodeGroup", description); + this->m_io->createCommonNWBAttributes( + this->m_path, "core", "ElectrodeGroup", description); this->m_io->createAttribute(location, this->m_path, "location"); - this->m_io->createLink("/" + this->m_path + "/device", "/" + device.getPath()); + this->m_io->createLink("/" + this->m_path + "/device", + "/" + device.getPath()); } // Getter for description diff --git a/src/nwb/file/ElectrodeTable.cpp b/src/nwb/file/ElectrodeTable.cpp index b0b2a5d4..55142514 100644 --- a/src/nwb/file/ElectrodeTable.cpp +++ b/src/nwb/file/ElectrodeTable.cpp @@ -24,17 +24,21 @@ void ElectrodeTable::initialize() // create group DynamicTable::initialize(); - electrodeDataset->dataset = - std::unique_ptr(this->m_io->createArrayDataSet( - BaseDataType::I32, SizeArray {1}, SizeArray {1}, this->m_path + "id")); + electrodeDataset->dataset = std::unique_ptr( + this->m_io->createArrayDataSet(BaseDataType::I32, + SizeArray {1}, + SizeArray {1}, + this->m_path + "id")); groupNamesDataset->dataset = std::unique_ptr( this->m_io->createArrayDataSet(BaseDataType::STR(250), - SizeArray {0}, - SizeArray {1}, - this->m_path + "group_name")); - locationsDataset - ->dataset = std::unique_ptr(this->m_io->createArrayDataSet( - BaseDataType::STR(250), SizeArray {0}, SizeArray {1}, this->m_path + "location")); + SizeArray {0}, + SizeArray {1}, + this->m_path + "group_name")); + locationsDataset->dataset = std::unique_ptr( + this->m_io->createArrayDataSet(BaseDataType::STR(250), + SizeArray {0}, + SizeArray {1}, + this->m_path + "location")); } void ElectrodeTable::addElectrodes(std::vector channels) From 476d7c78021c7e2a3be347704e64de4e9dc9c7aa Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 12:29:45 -0700 Subject: [PATCH 07/26] Update members in Data.hpp --- src/nwb/file/ElectrodeTable.cpp | 12 ++++++------ src/nwb/hdmf/base/Data.hpp | 19 +++++++++++++++++-- src/nwb/hdmf/table/DynamicTable.cpp | 8 ++++---- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/nwb/file/ElectrodeTable.cpp b/src/nwb/file/ElectrodeTable.cpp index 55142514..9e128000 100644 --- a/src/nwb/file/ElectrodeTable.cpp +++ b/src/nwb/file/ElectrodeTable.cpp @@ -24,21 +24,21 @@ void ElectrodeTable::initialize() // create group DynamicTable::initialize(); - electrodeDataset->dataset = std::unique_ptr( + electrodeDataset->setDataset(std::unique_ptr( this->m_io->createArrayDataSet(BaseDataType::I32, SizeArray {1}, SizeArray {1}, - this->m_path + "id")); - groupNamesDataset->dataset = std::unique_ptr( + this->m_path + "id"))); + groupNamesDataset->setDataset(std::unique_ptr( this->m_io->createArrayDataSet(BaseDataType::STR(250), SizeArray {0}, SizeArray {1}, - this->m_path + "group_name")); - locationsDataset->dataset = std::unique_ptr( + this->m_path + "group_name"))); + locationsDataset->setDataset(std::unique_ptr( this->m_io->createArrayDataSet(BaseDataType::STR(250), SizeArray {0}, SizeArray {1}, - this->m_path + "location")); + this->m_path + "location"))); } void ElectrodeTable::addElectrodes(std::vector channels) diff --git a/src/nwb/hdmf/base/Data.hpp b/src/nwb/hdmf/base/Data.hpp index ef146485..52818259 100644 --- a/src/nwb/hdmf/base/Data.hpp +++ b/src/nwb/hdmf/base/Data.hpp @@ -23,8 +23,23 @@ class Data ~Data() {} /** - * @brief Pointer to dataset. + * @brief Initialize the dataset for the Data object + * + * This functions takes ownership of the passed rvalue unique_ptr and moves + * ownership to its internal m_dataset variable + * + * @param The rvalue unique pointer to the BaseRecordingData object */ - std::unique_ptr dataset; + inline void setDataset(std::unique_ptr&& dataset) + { + m_dataset = std::move(dataset); + } + + /** + * @brief Check whether the m_dataset has been initialized + */ + inline bool isInitialized() { return this->m_dataset != nullptr; } + + std::unique_ptr m_dataset; }; } // namespace AQNWB::NWB diff --git a/src/nwb/hdmf/table/DynamicTable.cpp b/src/nwb/hdmf/table/DynamicTable.cpp index c54d94ab..d50a272f 100644 --- a/src/nwb/hdmf/table/DynamicTable.cpp +++ b/src/nwb/hdmf/table/DynamicTable.cpp @@ -32,12 +32,12 @@ void DynamicTable::addColumn(const std::string& name, std::unique_ptr& vectorData, const std::vector& values) { - if (vectorData->dataset == nullptr) { + if (!vectorData->isInitialized()) { std::cerr << "VectorData dataset is not initialized" << std::endl; } else { // write in loop because variable length string for (SizeType i = 0; i < values.size(); i++) - vectorData->dataset->writeDataBlock( + vectorData->m_dataset->writeDataBlock( std::vector(1, 1), BaseDataType::STR(values[i].size() + 1), values[i].c_str()); // TODO - add tests for this @@ -49,10 +49,10 @@ void DynamicTable::addColumn(const std::string& name, void DynamicTable::setRowIDs(std::unique_ptr& elementIDs, const std::vector& values) { - if (elementIDs->dataset == nullptr) { + if (!elementIDs->isInitialized()) { std::cerr << "ElementIdentifiers dataset is not initialized" << std::endl; } else { - elementIDs->dataset->writeDataBlock( + elementIDs->m_dataset->writeDataBlock( std::vector(1, values.size()), BaseDataType::I32, &values[0]); this->m_io->createCommonNWBAttributes( this->m_path + "id", "hdmf-common", "ElementIdentifiers"); From 131a9143ad5682405ab41eb2e90872d1ddc95e9d Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 12:48:23 -0700 Subject: [PATCH 08/26] Update member in HDF5RecordingData --- src/hdf5/HDF5IO.cpp | 12 ++++++------ src/hdf5/HDF5IO.hpp | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hdf5/HDF5IO.cpp b/src/hdf5/HDF5IO.cpp index 58fe39e0..0a518820 100644 --- a/src/hdf5/HDF5IO.cpp +++ b/src/hdf5/HDF5IO.cpp @@ -653,7 +653,7 @@ HDF5RecordingData::HDF5RecordingData(std::unique_ptr data) this->nDimensions = nDimensions; this->position = std::vector( nDimensions, 0); // Initialize position with 0 for each dimension - this->dSet = std::make_unique(*data); + this->m_dataset = std::make_unique(*data); } // HDF5RecordingData @@ -661,7 +661,7 @@ HDF5RecordingData::HDF5RecordingData(std::unique_ptr data) HDF5RecordingData::~HDF5RecordingData() { // Safety - dSet->flush(H5F_SCOPE_GLOBAL); + this->m_dataset->flush(H5F_SCOPE_GLOBAL); } Status HDF5RecordingData::writeDataBlock( @@ -690,10 +690,10 @@ Status HDF5RecordingData::writeDataBlock( } // Adjust dataset dimensions if necessary - dSet->extend(dSetDims.data()); + this->m_dataset->extend(dSetDims.data()); // Set size to new size based on updated dimensionality - DataSpace fSpace = dSet->getSpace(); + DataSpace fSpace = this->m_dataset->getSpace(); fSpace.getSimpleExtentDims(dSetDims.data()); for (int i = 0; i < nDimensions; ++i) { size[i] = dSetDims[i]; @@ -716,7 +716,7 @@ Status HDF5RecordingData::writeDataBlock( // Write the data DataType nativeType = HDF5IO::getNativeType(type); - dSet->write(data, nativeType, mSpace, fSpace); + this->m_dataset->write(data, nativeType, mSpace, fSpace); // Update position for simple extension for (int i = 0; i < dataShape.size(); ++i) { @@ -734,5 +734,5 @@ Status HDF5RecordingData::writeDataBlock( const H5::DataSet* HDF5RecordingData::getDataSet() { - return dSet.get(); + return this->m_dataset.get(); }; diff --git a/src/hdf5/HDF5IO.hpp b/src/hdf5/HDF5IO.hpp index 8d2480dc..26ffc799 100644 --- a/src/hdf5/HDF5IO.hpp +++ b/src/hdf5/HDF5IO.hpp @@ -331,13 +331,13 @@ class HDF5RecordingData : public BaseRecordingData private: /** - * @brief Pointer to an extendable HDF5 dataset + * @brief Return status of HDF5 operations. */ - std::unique_ptr 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 m_dataset; }; } // namespace AQNWB::HDF5 From e10535f53c342a8f9bdc9ff49d125cf48540832d Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 13:17:22 -0700 Subject: [PATCH 09/26] Update members in BaseIO and HDF5IO --- src/BaseIO.cpp | 16 +++++--- src/BaseIO.hpp | 12 +++--- src/hdf5/HDF5IO.cpp | 97 ++++++++++++++++++++++----------------------- src/hdf5/HDF5IO.hpp | 18 ++++----- 4 files changed, 72 insertions(+), 71 deletions(-) diff --git a/src/BaseIO.cpp b/src/BaseIO.cpp index 353f709d..26b39049 100644 --- a/src/BaseIO.cpp +++ b/src/BaseIO.cpp @@ -31,9 +31,10 @@ const BaseDataType BaseDataType::DSTR = BaseDataType(T_STR, DEFAULT_STR_SIZE); // BaseIO -BaseIO::BaseIO() - : readyToOpen(true) - , opened(false) +BaseIO::BaseIO(const std::string& filename) + : m_filename(filename) + , m_readyToOpen(true) + , m_opened(false) { } @@ -41,12 +42,17 @@ BaseIO::~BaseIO() {} bool BaseIO::isOpen() const { - return opened; + return m_opened; +} + +std::string BaseIO::getFileName() +{ + return this->m_filename; } bool BaseIO::isReadyToOpen() const { - return readyToOpen; + return m_readyToOpen; } bool BaseIO::canModifyObjects() diff --git a/src/BaseIO.hpp b/src/BaseIO.hpp index 19d47cb1..268695e3 100644 --- a/src/BaseIO.hpp +++ b/src/BaseIO.hpp @@ -94,7 +94,7 @@ class BaseIO /** * @brief Constructor for the BaseIO class. */ - BaseIO(); + BaseIO(const std::string& filename); /** * @brief Copy constructor is deleted to prevent construction-copying. @@ -115,7 +115,7 @@ class BaseIO * @brief Returns the full path to the file. * @return The full path to the file. */ - virtual std::string getFileName() = 0; + virtual std::string getFileName(); /** * @brief Opens the file for writing. @@ -346,12 +346,12 @@ class BaseIO */ bool isReadyToOpen() const; +protected: /** * @brief The name of the file. */ - const std::string filename; + const std::string m_filename; -protected: /** * @brief Creates a new group if it does not already exist. * @param path The location of the group in the file. @@ -362,12 +362,12 @@ class BaseIO /** * @brief Whether the file is ready to be opened. */ - bool readyToOpen; + bool m_readyToOpen; /** * @brief Whether the file is currently open. */ - bool opened; + bool m_opened; }; /** diff --git a/src/hdf5/HDF5IO.cpp b/src/hdf5/HDF5IO.cpp index 0a518820..36eee1a5 100644 --- a/src/hdf5/HDF5IO.cpp +++ b/src/hdf5/HDF5IO.cpp @@ -15,12 +15,9 @@ using namespace H5; using namespace AQNWB::HDF5; // HDF5IO - -HDF5IO::HDF5IO() {} - -HDF5IO::HDF5IO(const std::string& fileName, const bool disableSWMRMode) - : filename(fileName) - , disableSWMRMode(disableSWMRMode) +HDF5IO::HDF5IO(const std::string& filename, const bool disableSWMRMode) + : BaseIO(filename) + , m_disableSWMRMode(disableSWMRMode) { } @@ -31,7 +28,7 @@ HDF5IO::~HDF5IO() std::string HDF5IO::getFileName() { - return filename; + return this->m_filename; } Status HDF5IO::open() @@ -47,7 +44,7 @@ Status HDF5IO::open(bool newfile) { int accFlags = 0; - if (opened) + if (this->m_opened) return Status::Failure; FileAccPropList fapl = FileAccPropList::DEFAULT; @@ -58,19 +55,19 @@ Status HDF5IO::open(bool newfile) else accFlags = H5F_ACC_RDWR; - file = std::make_unique( + this->m_file = std::make_unique( getFileName(), accFlags, FileCreatPropList::DEFAULT, fapl); - opened = true; + this->m_opened = true; return Status::Success; } Status HDF5IO::close() { - if (this->file != nullptr && opened) { - this->file->close(); - this->file = nullptr; - this->opened = false; + if (this->m_file != nullptr && this->m_opened) { + this->m_file->close(); + this->m_file = nullptr; + this->m_opened = false; } return Status::Success; @@ -86,7 +83,7 @@ Status checkStatus(int status) Status HDF5IO::flush() { - int status = H5Fflush(this->file->getId(), H5F_SCOPE_GLOBAL); + int status = H5Fflush(this->m_file->getId(), H5F_SCOPE_GLOBAL); return checkStatus(status); } @@ -103,18 +100,18 @@ Status HDF5IO::createAttribute(const BaseDataType& type, DataType H5type; DataType origType; - if (!opened) + if (!this->m_opened) return Status::Failure; // open the group or dataset H5O_type_t objectType = getObjectType(path); switch (objectType) { case H5O_TYPE_GROUP: - gloc = file->openGroup(path); + gloc = this->m_file->openGroup(path); loc = &gloc; break; case H5O_TYPE_DATASET: - dloc = file->openDataSet(path); + dloc = this->m_file->openDataSet(path); loc = &dloc; break; default: @@ -178,7 +175,7 @@ Status HDF5IO::createAttribute(const std::vector& data, Attribute attr; hsize_t dims[1]; - if (!opened) + if (!this->m_opened) return Status::Failure; StrType H5type(PredType::C_S1, maxSize); @@ -188,11 +185,11 @@ Status HDF5IO::createAttribute(const std::vector& data, H5O_type_t objectType = getObjectType(path); switch (objectType) { case H5O_TYPE_GROUP: - gloc = file->openGroup(path); + gloc = this->m_file->openGroup(path); loc = &gloc; break; case H5O_TYPE_DATASET: - dloc = file->openDataSet(path); + dloc = this->m_file->openDataSet(path); loc = &dloc; break; default: @@ -235,18 +232,18 @@ Status HDF5IO::createReferenceAttribute(const std::string& referencePath, DataSet dloc; Attribute attr; - if (!opened) + if (!this->m_opened) return Status::Failure; // open the group or dataset H5O_type_t objectType = getObjectType(path); switch (objectType) { case H5O_TYPE_GROUP: - gloc = file->openGroup(path); + gloc = this->m_file->openGroup(path); loc = &gloc; break; case H5O_TYPE_DATASET: - dloc = file->openDataSet(path); + dloc = this->m_file->openDataSet(path); loc = &dloc; break; default: @@ -263,7 +260,7 @@ Status HDF5IO::createReferenceAttribute(const std::string& referencePath, hobj_ref_t* rdata = new hobj_ref_t[sizeof(hobj_ref_t)]; - file->reference(rdata, referencePath.c_str()); + this->m_file->reference(rdata, referencePath.c_str()); attr.write(H5::PredType::STD_REF_OBJ, rdata); delete[] rdata; @@ -283,10 +280,10 @@ Status HDF5IO::createReferenceAttribute(const std::string& referencePath, Status HDF5IO::createGroup(const std::string& path) { - if (!opened) + if (!this->m_opened) return Status::Failure; try { - file->createGroup(path); + this->m_file->createGroup(path); } catch (FileIException error) { error.printErrorStack(); } catch (GroupIException error) { @@ -297,10 +294,10 @@ Status HDF5IO::createGroup(const std::string& path) Status HDF5IO::createGroupIfDoesNotExist(const std::string& path) { - if (!opened) + if (!this->m_opened) return Status::Failure; try { - file->childObjType(path); + this->m_file->childObjType(path); } catch (FileIException) { return createGroup(path); } @@ -310,11 +307,11 @@ Status HDF5IO::createGroupIfDoesNotExist(const std::string& path) /** Creates a link to another location in the file */ Status HDF5IO::createLink(const std::string& path, const std::string& reference) { - if (!opened) + if (!this->m_opened) return Status::Failure; herr_t error = H5Lcreate_soft(reference.c_str(), - file->getLocId(), + this->m_file->getLocId(), path.c_str(), H5P_DEFAULT, H5P_DEFAULT); @@ -325,7 +322,7 @@ Status HDF5IO::createLink(const std::string& path, const std::string& reference) Status HDF5IO::createReferenceDataSet( const std::string& path, const std::vector& references) { - if (!opened) + if (!this->m_opened) return Status::Failure; const hsize_t size = references.size(); @@ -333,12 +330,12 @@ Status HDF5IO::createReferenceDataSet( hobj_ref_t* rdata = new hobj_ref_t[size * sizeof(hobj_ref_t)]; for (SizeType i = 0; i < size; i++) { - file->reference(&rdata[i], references[i].c_str()); + this->m_file->reference(&rdata[i], references[i].c_str()); } hid_t space = H5Screate_simple(1, &size, NULL); - hid_t dset = H5Dcreate(file->getLocId(), + hid_t dset = H5Dcreate(this->m_file->getLocId(), path.c_str(), H5T_STD_REF_OBJ, space, @@ -360,7 +357,7 @@ Status HDF5IO::createReferenceDataSet( Status HDF5IO::createStringDataSet(const std::string& path, const std::string& value) { - if (!opened) + if (!this->m_opened) return Status::Failure; std::unique_ptr dataset; @@ -368,7 +365,7 @@ Status HDF5IO::createStringDataSet(const std::string& path, DataSpace dSpace(H5S_SCALAR); dataset = - std::make_unique(file->createDataSet(path, H5type, dSpace)); + std::make_unique(this->m_file->createDataSet(path, H5type, dSpace)); dataset->write(value.c_str(), H5type); return Status::Success; @@ -377,7 +374,7 @@ Status HDF5IO::createStringDataSet(const std::string& path, Status HDF5IO::createStringDataSet(const std::string& path, const std::vector& values) { - if (!opened) + if (!this->m_opened) return Status::Failure; std::vector cStrs; @@ -397,11 +394,11 @@ Status HDF5IO::createStringDataSet(const std::string& path, Status HDF5IO::startRecording() { - if (!opened) + if (!this->m_opened) return Status::Failure; - if (!disableSWMRMode) { - herr_t status = H5Fstart_swmr_write(this->file->getId()); + if (!this->m_disableSWMRMode) { + herr_t status = H5Fstart_swmr_write(this->m_file->getId()); return checkStatus(status); } return Status::Success; @@ -410,7 +407,7 @@ Status HDF5IO::startRecording() Status HDF5IO::stopRecording() { // if SWMR mode is disabled, stopping the recording will leave the file open - if (!disableSWMRMode) { + if (!this->m_disableSWMRMode) { close(); // SWMR mode cannot be disabled so close the file } else { this->flush(); @@ -420,13 +417,13 @@ Status HDF5IO::stopRecording() bool HDF5IO::canModifyObjects() { - if (!opened) + if (!this->m_opened) return false; // Check if we are in SWMR mode bool inSWMRMode = false; unsigned int intent; - herr_t status = H5Fget_intent(this->file->getId(), &intent); + herr_t status = H5Fget_intent(this->m_file->getId(), &intent); bool statusOK = (status >= 0); if (statusOK) { inSWMRMode = (intent & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE)); @@ -439,7 +436,7 @@ bool HDF5IO::canModifyObjects() bool HDF5IO::objectExists(const std::string& path) { - htri_t exists = H5Lexists(file->getId(), path.c_str(), H5P_DEFAULT); + htri_t exists = H5Lexists(this->m_file->getId(), path.c_str(), H5P_DEFAULT); if (exists > 0) { return true; } else { @@ -452,11 +449,11 @@ std::unique_ptr HDF5IO::getDataSet( { std::unique_ptr data; - if (!opened) + if (!this->m_opened) return nullptr; try { - data = std::make_unique(file->openDataSet(path)); + data = std::make_unique(this->m_file->openDataSet(path)); return std::make_unique(std::move(data)); } catch (DataSetIException error) { error.printErrorStack(); @@ -480,7 +477,7 @@ std::unique_ptr HDF5IO::createArrayDataSet( DSetCreatPropList prop; DataType H5type = getH5Type(type); - if (!opened) + if (!this->m_opened) return nullptr; SizeType dimension = size.size(); @@ -509,7 +506,7 @@ std::unique_ptr HDF5IO::createArrayDataSet( prop.setChunk(static_cast(dimension), chunk_dims.data()); data = std::make_unique( - file->createDataSet(path, H5type, dSpace, prop)); + this->m_file->createDataSet(path, H5type, dSpace, prop)); return std::make_unique(std::move(data)); } @@ -520,11 +517,11 @@ H5O_type_t HDF5IO::getObjectType(const std::string& path) // get whether path is a dataset or group H5O_info_t objInfo; // Structure to hold information about the object H5Oget_info_by_name( - this->file->getId(), path.c_str(), &objInfo, H5O_INFO_BASIC, H5P_DEFAULT); + this->m_file->getId(), path.c_str(), &objInfo, H5O_INFO_BASIC, H5P_DEFAULT); #else // get whether path is a dataset or group H5O_info_t objInfo; // Structure to hold information about the object - H5Oget_info_by_name(this->file->getId(), path.c_str(), &objInfo, H5P_DEFAULT); + H5Oget_info_by_name(this-m_>file->getId(), path.c_str(), &objInfo, H5P_DEFAULT); #endif H5O_type_t objectType = objInfo.type; diff --git a/src/hdf5/HDF5IO.hpp b/src/hdf5/HDF5IO.hpp index 26ffc799..528ef43c 100644 --- a/src/hdf5/HDF5IO.hpp +++ b/src/hdf5/HDF5IO.hpp @@ -32,11 +32,6 @@ class HDF5RecordingData; // declare here because gets used in HDF5IO class class HDF5IO : public BaseIO { public: - /** - * @brief Default constructor for the HDF5IO class. - */ - HDF5IO(); - /** * @brief Constructor for the HDF5IO class that takes a file name as input. * @param fileName The name of the HDF5 file. @@ -264,8 +259,6 @@ class HDF5IO : public BaseIO static H5::DataType getH5Type(BaseDataType type); protected: - std::string filename; - /** * @brief Creates a new group if it does not exist. * @param path The location in the file of the group. @@ -274,9 +267,14 @@ class HDF5IO : public BaseIO Status createGroupIfDoesNotExist(const std::string& path) override; private: - std::unique_ptr file; - bool disableSWMRMode; // when set do not use SWMR mode when opening the HDF5 - // file + /** + * @brief the HDF5 file + */ + std::unique_ptr m_file; + /** + * @brief When set do not use SWMR mode when opening the HDF5 file + */ + bool m_disableSWMRMode; }; /** From 42a43a8f4e620d1054f5541140fd592bc7d3be2a Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 13:22:23 -0700 Subject: [PATCH 10/26] Update members in VectorData --- src/nwb/hdmf/table/VectorData.cpp | 2 +- src/nwb/hdmf/table/VectorData.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nwb/hdmf/table/VectorData.cpp b/src/nwb/hdmf/table/VectorData.cpp index 1438387e..c46c0f87 100644 --- a/src/nwb/hdmf/table/VectorData.cpp +++ b/src/nwb/hdmf/table/VectorData.cpp @@ -5,5 +5,5 @@ using namespace AQNWB::NWB; // VectorData std::string VectorData::getDescription() const { - return description; + return m_description; } diff --git a/src/nwb/hdmf/table/VectorData.hpp b/src/nwb/hdmf/table/VectorData.hpp index 7ee93f09..e4cd5fcd 100644 --- a/src/nwb/hdmf/table/VectorData.hpp +++ b/src/nwb/hdmf/table/VectorData.hpp @@ -22,6 +22,6 @@ class VectorData : public Data /** * @brief Description of VectorData. */ - std::string description; + std::string m_description; }; } // namespace AQNWB::NWB From fcea05976754b1ed64c38641b602714a822466d1 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 13:26:07 -0700 Subject: [PATCH 11/26] Fix formatting --- src/hdf5/HDF5IO.cpp | 14 +++++++++----- src/hdf5/HDF5IO.hpp | 8 ++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/hdf5/HDF5IO.cpp b/src/hdf5/HDF5IO.cpp index 36eee1a5..aba82316 100644 --- a/src/hdf5/HDF5IO.cpp +++ b/src/hdf5/HDF5IO.cpp @@ -364,8 +364,8 @@ Status HDF5IO::createStringDataSet(const std::string& path, DataType H5type = getH5Type(BaseDataType::STR(value.length())); DataSpace dSpace(H5S_SCALAR); - dataset = - std::make_unique(this->m_file->createDataSet(path, H5type, dSpace)); + dataset = std::make_unique( + this->m_file->createDataSet(path, H5type, dSpace)); dataset->write(value.c_str(), H5type); return Status::Success; @@ -516,12 +516,16 @@ H5O_type_t HDF5IO::getObjectType(const std::string& path) #if H5_VERSION_GE(1, 12, 0) // get whether path is a dataset or group H5O_info_t objInfo; // Structure to hold information about the object - H5Oget_info_by_name( - this->m_file->getId(), path.c_str(), &objInfo, H5O_INFO_BASIC, H5P_DEFAULT); + H5Oget_info_by_name(this->m_file->getId(), + path.c_str(), + &objInfo, + H5O_INFO_BASIC, + H5P_DEFAULT); #else // get whether path is a dataset or group H5O_info_t objInfo; // Structure to hold information about the object - H5Oget_info_by_name(this-m_>file->getId(), path.c_str(), &objInfo, H5P_DEFAULT); + H5Oget_info_by_name( + this - m_ > file->getId(), path.c_str(), &objInfo, H5P_DEFAULT); #endif H5O_type_t objectType = objInfo.type; diff --git a/src/hdf5/HDF5IO.hpp b/src/hdf5/HDF5IO.hpp index 528ef43c..00278d49 100644 --- a/src/hdf5/HDF5IO.hpp +++ b/src/hdf5/HDF5IO.hpp @@ -268,12 +268,12 @@ class HDF5IO : public BaseIO private: /** - * @brief the HDF5 file - */ + * @brief the HDF5 file + */ std::unique_ptr m_file; /** - * @brief When set do not use SWMR mode when opening the HDF5 file - */ + * @brief When set do not use SWMR mode when opening the HDF5 file + */ bool m_disableSWMRMode; }; From 341739ebea260062dcd3c337d89f4d0f608cc5e6 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 13:29:47 -0700 Subject: [PATCH 12/26] Fix ubuntu build error --- src/hdf5/HDF5IO.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hdf5/HDF5IO.cpp b/src/hdf5/HDF5IO.cpp index aba82316..8ed70e86 100644 --- a/src/hdf5/HDF5IO.cpp +++ b/src/hdf5/HDF5IO.cpp @@ -525,7 +525,7 @@ H5O_type_t HDF5IO::getObjectType(const std::string& path) // get whether path is a dataset or group H5O_info_t objInfo; // Structure to hold information about the object H5Oget_info_by_name( - this - m_ > file->getId(), path.c_str(), &objInfo, H5P_DEFAULT); + this->m_file->getId(), path.c_str(), &objInfo, H5P_DEFAULT); #endif H5O_type_t objectType = objInfo.type; From 669fa954dbb260e7794e7ae975643d548f523690 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 13:47:01 -0700 Subject: [PATCH 13/26] Fix Doxygen built errors --- docs/pages/userdocs/workflow.dox | 82 ++++++++++++++-------------- src/nwb/ecephys/SpikeEventSeries.hpp | 21 +++++-- src/nwb/hdmf/base/Data.hpp | 2 +- 3 files changed, 59 insertions(+), 46 deletions(-) diff --git a/docs/pages/userdocs/workflow.dox b/docs/pages/userdocs/workflow.dox index 106f46ff..4f90846c 100644 --- a/docs/pages/userdocs/workflow.dox +++ b/docs/pages/userdocs/workflow.dox @@ -8,94 +8,94 @@ * 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. * - * 1. Create the I/O object (e.g,. \ref AQNWB::HDF5::HDF5IO "HDF5IO") used for + * 1. Create the I/O object (e.g,. \ref AQNWB::HDF5::HDF5IO "HDF5IO") used for * writing data to the file on disk. - * 2. Create the \ref AQNWB::NWB::RecordingContainers "RecordingContainers" object + * 2. Create the \ref AQNWB::NWB::RecordingContainers "RecordingContainers" object * used for managing \ref AQNWB::NWB::Container "Container" objects for storing recordings. - * 3. Create the \ref AQNWB::NWB::NWBFile "NWBFile" object used for managing and creating NWB + * 3. Create the \ref AQNWB::NWB::NWBFile "NWBFile" object used for managing and creating NWB * file contents. - * 4. Create the \ref AQNWB::NWB::Container "Container" objects (e.g., - * \ref AQNWB::NWB::ElectricalSeries "ElectricalSeries") used for recording and add them + * 4. Create the \ref AQNWB::NWB::Container "Container" objects (e.g., + * \ref AQNWB::NWB::ElectricalSeries "ElectricalSeries") used for recording and add them * to the \ref AQNWB::NWB::RecordingContainers "RecordingContainers". * 5. Start the recording. * 6. Write data. * 7. Stop the recording and close the \ref AQNWB::NWB::NWBFile "NWBFile". - * + * * Below, we walk through these steps in more detail. - * - * + * + * * \subsection create_io 1. Create the I/O object. - * - * First, create an I/O object (e.g., \ref AQNWB::HDF5::HDF5IO "HDF5IO") used for writing + * + * First, create an I/O object (e.g., \ref AQNWB::HDF5::HDF5IO "HDF5IO") used for writing * data to the file. AqNWB provides the convenience method, \ref AQNWB::createIO "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` + * control of different backend parameters, you can create your own `std::shared_ptr` * using any of the derived \ref AQNWB::BaseIO "BaseIO" classes. - * + * * \snippet tests/examples/testWorkflowExamples.cpp example_workflow_io_snippet * * * \subsection create_recording_container 2. Create the RecordingContainer object. - * - * Next, create a \ref AQNWB::NWB::RecordingContainers "RecordingContainers" object to manage the - * different \ref AQNWB::NWB::Container "Container" objects with the datasets that you would + * + * Next, create a \ref AQNWB::NWB::RecordingContainers "RecordingContainers" object to manage the + * different \ref AQNWB::NWB::Container "Container" objects with the datasets that you would * like to write data to. - * + * * \snippet tests/examples/testWorkflowExamples.cpp example_workflow_recording_containers_snippet - * + * * * \subsection create_nwbfile 3. Create the NWBFile - * - * Next, constructs the \ref AQNWB::NWB::NWBFile "NWBFile" object, using the I/O object as an input. + * + * Next, constructs the \ref AQNWB::NWB::NWBFile "NWBFile" object, using the I/O object as an input. * Then, initialize the object to create the basic file structure of the NWBFile. * * \snippet tests/examples/testWorkflowExamples.cpp example_workflow_nwbfile_snippet * - * + * * \subsection create_datasets 4. Create datasets and add to RecordingContainers. * - * Next, create the different data types (e.g. \ref AQNWB::NWB::ElectricalSeries "ElectricalSeries" - * or other AQNWB::NWB::TimeSeries "TimeSeries") that you would like to write data into. After - * creation, these objects are added to the \ref AQNWB::NWB::RecordingContainers "RecordingContainers" - * 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`. - * + * Next, create the different data types (e.g. \ref AQNWB::NWB::ElectricalSeries "ElectricalSeries" + * or other AQNWB::NWB::TimeSeries "TimeSeries") that you would like to write data into. After + * creation, these objects are added to the \ref AQNWB::NWB::RecordingContainers "RecordingContainers" + * 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 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 * * * \subsection start_recording 5. Start the recording. * - * Then, start the recording process with a call to the ``startRecording`` function of the I/O object. + * Then, start the recording process with a call to the ``startRecording`` function of the I/O object. * - * \note - * When using \ref AQNWB::HDF5::HDF5IO "HDF5IO" for writing to HDF5, calling + * \note + * When using \ref AQNWB::HDF5::HDF5IO "HDF5IO" for writing to HDF5, calling * \ref AQNWB::HDF5::HDF5IO::startRecording "startRecording" will by default enable - * \ref hdf5io_swmr "SWMR mode" to ensure file integrity and support concurrent read. + * \ref hdf5io_swmr "SWMR mode" to ensure file integrity and support concurrent read. * As a result, no additional datasets or groups can be added to the file once a recording * has been started unless the file is is closed and reopened. * * \snippet tests/examples/testWorkflowExamples.cpp example_workflow_start_snippet * - * + * * \subsection write_data 6. Write data. * - * During the recording process, use the \ref AQNWB::NWB::RecordingContainers "RecordingContainers" - * as an interface to access the various \ref AQNWB::NWB::Container "Container" object and corresponding - * datasets and write blocks of data to the file. Calling `flush()` on the I/O object at any time will + * During the recording process, use the \ref AQNWB::NWB::RecordingContainers "RecordingContainers" + * as an interface to access the various \ref AQNWB::NWB::Container "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. - * + * * \snippet tests/examples/testWorkflowExamples.cpp example_workflow_write_snippet * - * + * * \subsection stop_recording 7. Stop the recording and finalize the file. * * When the recording process is finished, call `stopRecording` from the I/O object * to flush any data and close the file. - * + * * \snippet tests/examples/testWorkflowExamples.cpp example_workflow_stop_snippet * * diff --git a/src/nwb/ecephys/SpikeEventSeries.hpp b/src/nwb/ecephys/SpikeEventSeries.hpp index ad2dd2ae..401500dd 100644 --- a/src/nwb/ecephys/SpikeEventSeries.hpp +++ b/src/nwb/ecephys/SpikeEventSeries.hpp @@ -17,10 +17,24 @@ class SpikeEventSeries : public ElectricalSeries public: /** * @brief Constructor. - * @param path The location of the SpikeEventSeries in the file. + * @param path The location of the ElectricalSeries in the file. * @param io A shared pointer to the IO object. - * @param description The description of the SpikeEventSeries, should describe - * how events were detected. + * @param dataType The data type to use for storing the recorded voltage + * @param channelVector The electrodes to use for recording + * @param description The description of the TimeSeries. + * @param dsetSize Initial size of the main dataset. This must be a vector + * with two elements. The first element specifies the length + * in time and the second element must be equal to the + * length of channelVector + * @param chunkSize Chunk size to use. The number of elements must be two to + * specify the size of a chunk in the time and electrode + * dimension + * @param conversion Scalar to multiply each element in data to convert it to + * the specified ‘unit’ + * @param resolution Smallest meaningful difference between values in data, + * stored in the specified by unit + * @param offset Scalar to add to the data after scaling by ‘conversion’ to + * finalize its coercion to the specified ‘unit' */ SpikeEventSeries(const std::string& path, std::shared_ptr io, @@ -49,7 +63,6 @@ class SpikeEventSeries : public ElectricalSeries * @param numChannels The number of channels in the event * @param data The data of the event * @param timestamps The timestamps of the event - * @param */ Status writeSpike(const SizeType& numSamples, const SizeType& numChannels, diff --git a/src/nwb/hdmf/base/Data.hpp b/src/nwb/hdmf/base/Data.hpp index 52818259..7fdef6db 100644 --- a/src/nwb/hdmf/base/Data.hpp +++ b/src/nwb/hdmf/base/Data.hpp @@ -28,7 +28,7 @@ class Data * This functions takes ownership of the passed rvalue unique_ptr and moves * ownership to its internal m_dataset variable * - * @param The rvalue unique pointer to the BaseRecordingData object + * @param dataset The rvalue unique pointer to the BaseRecordingData object */ inline void setDataset(std::unique_ptr&& dataset) { From ad7aea441e224fe8b418ad2d2bb5f4d482b586dc Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 17:10:41 -0700 Subject: [PATCH 14/26] Replace this->m_ with just m_ --- src/BaseIO.cpp | 2 +- src/hdf5/HDF5IO.cpp | 40 ++++++++++---------- src/nwb/NWBFile.cpp | 56 ++++++++++++++-------------- src/nwb/RecordingContainers.cpp | 8 ++-- src/nwb/base/TimeSeries.cpp | 22 +++++------ src/nwb/device/Device.cpp | 5 +-- src/nwb/ecephys/ElectricalSeries.cpp | 28 +++++++------- src/nwb/file/ElectrodeGroup.cpp | 9 ++--- src/nwb/file/ElectrodeTable.cpp | 24 ++++++------ src/nwb/hdmf/base/Data.hpp | 2 +- src/nwb/hdmf/table/DynamicTable.cpp | 20 +++++----- 11 files changed, 104 insertions(+), 112 deletions(-) diff --git a/src/BaseIO.cpp b/src/BaseIO.cpp index 26b39049..e5031d3e 100644 --- a/src/BaseIO.cpp +++ b/src/BaseIO.cpp @@ -47,7 +47,7 @@ bool BaseIO::isOpen() const std::string BaseIO::getFileName() { - return this->m_filename; + return m_filename; } bool BaseIO::isReadyToOpen() const diff --git a/src/hdf5/HDF5IO.cpp b/src/hdf5/HDF5IO.cpp index 8ed70e86..844fb2b8 100644 --- a/src/hdf5/HDF5IO.cpp +++ b/src/hdf5/HDF5IO.cpp @@ -28,7 +28,7 @@ HDF5IO::~HDF5IO() std::string HDF5IO::getFileName() { - return this->m_filename; + return m_filename; } Status HDF5IO::open() @@ -44,7 +44,7 @@ Status HDF5IO::open(bool newfile) { int accFlags = 0; - if (this->m_opened) + if (m_opened) return Status::Failure; FileAccPropList fapl = FileAccPropList::DEFAULT; @@ -55,19 +55,19 @@ Status HDF5IO::open(bool newfile) else accFlags = H5F_ACC_RDWR; - this->m_file = std::make_unique( + m_file = std::make_unique( getFileName(), accFlags, FileCreatPropList::DEFAULT, fapl); - this->m_opened = true; + m_opened = true; return Status::Success; } Status HDF5IO::close() { - if (this->m_file != nullptr && this->m_opened) { - this->m_file->close(); - this->m_file = nullptr; - this->m_opened = false; + if (m_file != nullptr && m_opened) { + m_file->close(); + m_file = nullptr; + m_opened = false; } return Status::Success; @@ -83,7 +83,7 @@ Status checkStatus(int status) Status HDF5IO::flush() { - int status = H5Fflush(this->m_file->getId(), H5F_SCOPE_GLOBAL); + int status = H5Fflush(m_file->getId(), H5F_SCOPE_GLOBAL); return checkStatus(status); } @@ -100,18 +100,18 @@ Status HDF5IO::createAttribute(const BaseDataType& type, DataType H5type; DataType origType; - if (!this->m_opened) + if (!m_opened) return Status::Failure; // open the group or dataset H5O_type_t objectType = getObjectType(path); switch (objectType) { case H5O_TYPE_GROUP: - gloc = this->m_file->openGroup(path); + gloc = m_file->openGroup(path); loc = &gloc; break; case H5O_TYPE_DATASET: - dloc = this->m_file->openDataSet(path); + dloc = m_file->openDataSet(path); loc = &dloc; break; default: @@ -175,7 +175,7 @@ Status HDF5IO::createAttribute(const std::vector& data, Attribute attr; hsize_t dims[1]; - if (!this->m_opened) + if (!m_opened) return Status::Failure; StrType H5type(PredType::C_S1, maxSize); @@ -185,11 +185,11 @@ Status HDF5IO::createAttribute(const std::vector& data, H5O_type_t objectType = getObjectType(path); switch (objectType) { case H5O_TYPE_GROUP: - gloc = this->m_file->openGroup(path); + gloc = m_file->openGroup(path); loc = &gloc; break; case H5O_TYPE_DATASET: - dloc = this->m_file->openDataSet(path); + dloc = m_file->openDataSet(path); loc = &dloc; break; default: @@ -232,18 +232,18 @@ Status HDF5IO::createReferenceAttribute(const std::string& referencePath, DataSet dloc; Attribute attr; - if (!this->m_opened) + if (!m_opened) return Status::Failure; // open the group or dataset H5O_type_t objectType = getObjectType(path); switch (objectType) { case H5O_TYPE_GROUP: - gloc = this->m_file->openGroup(path); + gloc = m_file->openGroup(path); loc = &gloc; break; case H5O_TYPE_DATASET: - dloc = this->m_file->openDataSet(path); + dloc = m_file->openDataSet(path); loc = &dloc; break; default: @@ -260,7 +260,7 @@ Status HDF5IO::createReferenceAttribute(const std::string& referencePath, hobj_ref_t* rdata = new hobj_ref_t[sizeof(hobj_ref_t)]; - this->m_file->reference(rdata, referencePath.c_str()); + m_file->reference(rdata, referencePath.c_str()); attr.write(H5::PredType::STD_REF_OBJ, rdata); delete[] rdata; @@ -280,7 +280,7 @@ Status HDF5IO::createReferenceAttribute(const std::string& referencePath, Status HDF5IO::createGroup(const std::string& path) { - if (!this->m_opened) + if (!m_opened) return Status::Failure; try { this->m_file->createGroup(path); diff --git a/src/nwb/NWBFile.cpp b/src/nwb/NWBFile.cpp index c8738dd3..08034b1a 100644 --- a/src/nwb/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -42,44 +42,44 @@ NWBFile::~NWBFile() {} Status NWBFile::initialize(const std::string description, const std::string dataCollection) { - if (std::filesystem::exists(this->m_io->getFileName())) { - return this->m_io->open(false); + if (std::filesystem::exists(m_io->getFileName())) { + return m_io->open(false); } else { - this->m_io->open(true); + m_io->open(true); return createFileStructure(description, dataCollection); } } Status NWBFile::finalize() { - return this->m_io->close(); + return m_io->close(); } Status NWBFile::createFileStructure(std::string description, std::string dataCollection) { - if (!this->m_io->canModifyObjects()) { + if (!m_io->canModifyObjects()) { return Status::Failure; } - this->m_io->createCommonNWBAttributes("/", "core", "NWBFile", ""); - this->m_io->createAttribute(AQNWB::SPEC::CORE::version, "/", "nwb_version"); - - this->m_io->createGroup("/acquisition"); - this->m_io->createGroup("/analysis"); - this->m_io->createGroup("/processing"); - this->m_io->createGroup("/stimulus"); - this->m_io->createGroup("/stimulus/presentation"); - this->m_io->createGroup("/stimulus/templates"); - this->m_io->createGroup("/general"); - this->m_io->createGroup("/general/devices"); - this->m_io->createGroup("/general/extracellular_ephys"); + m_io->createCommonNWBAttributes("/", "core", "NWBFile", ""); + m_io->createAttribute(AQNWB::SPEC::CORE::version, "/", "nwb_version"); + + m_io->createGroup("/acquisition"); + m_io->createGroup("/analysis"); + m_io->createGroup("/processing"); + m_io->createGroup("/stimulus"); + m_io->createGroup("/stimulus/presentation"); + m_io->createGroup("/stimulus/templates"); + m_io->createGroup("/general"); + m_io->createGroup("/general/devices"); + m_io->createGroup("/general/extracellular_ephys"); if (dataCollection != "") { - this->m_io->createStringDataSet("/general/data_collection", dataCollection); + m_io->createStringDataSet("/general/data_collection", dataCollection); } - this->m_io->createGroup("/specifications"); - this->m_io->createReferenceAttribute("/specifications", "/", ".specloc"); + m_io->createGroup("/specifications"); + m_io->createReferenceAttribute("/specifications", "/", ".specloc"); cacheSpecifications( "core", AQNWB::SPEC::CORE::version, AQNWB::SPEC::CORE::specVariables); @@ -92,11 +92,11 @@ Status NWBFile::createFileStructure(std::string description, std::string time = getCurrentTime(); std::vector timeVec = {time}; - this->m_io->createStringDataSet("/file_create_date", timeVec); - this->m_io->createStringDataSet("/session_description", description); - this->m_io->createStringDataSet("/session_start_time", time); - this->m_io->createStringDataSet("/timestamps_reference_time", time); - this->m_io->createStringDataSet("/identifier", this->m_identifierText); + 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); return Status::Success; } @@ -108,7 +108,7 @@ Status NWBFile::createElectricalSeries( RecordingContainers* recordingContainers, std::vector& containerIndexes) { - if (!this->m_io->canModifyObjects()) { + if (!m_io->canModifyObjects()) { return Status::Failure; } @@ -118,9 +118,9 @@ Status NWBFile::createElectricalSeries( // Setup electrode table if it was not yet created bool electrodeTableCreated = - this->m_io->objectExists(ElectrodeTable::electrodeTablePath); + m_io->objectExists(ElectrodeTable::electrodeTablePath); if (!electrodeTableCreated) { - this->m_electrodeTable = std::make_unique(this->m_io); + m_electrodeTable = std::make_unique(this->m_io); this->m_electrodeTable->initialize(); // Add electrode information to table (does not write to datasets yet) diff --git a/src/nwb/RecordingContainers.cpp b/src/nwb/RecordingContainers.cpp index 4aafd36e..cd2b96c5 100644 --- a/src/nwb/RecordingContainers.cpp +++ b/src/nwb/RecordingContainers.cpp @@ -14,15 +14,15 @@ RecordingContainers::~RecordingContainers() {} void RecordingContainers::addContainer(std::unique_ptr container) { - this->m_containers.push_back(std::move(container)); + m_containers.push_back(std::move(container)); } Container* RecordingContainers::getContainer(const SizeType& containerInd) { - if (containerInd >= this->m_containers.size()) { + if (containerInd >= m_containers.size()) { return nullptr; } else { - return this->m_containers[containerInd].get(); + return m_containers[containerInd].get(); } } @@ -82,5 +82,5 @@ Status RecordingContainers::writeSpikeEventData(const SizeType& containerInd, SizeType RecordingContainers::size() { - return this->m_containers.size(); + return m_containers.size(); } \ No newline at end of file diff --git a/src/nwb/base/TimeSeries.cpp b/src/nwb/base/TimeSeries.cpp index b520a08a..a5158077 100644 --- a/src/nwb/base/TimeSeries.cpp +++ b/src/nwb/base/TimeSeries.cpp @@ -37,24 +37,20 @@ void TimeSeries::initialize() Container::initialize(); // setup attributes - this->m_io->createCommonNWBAttributes( - this->m_path, "core", neurodataType, description); - this->m_io->createAttribute(comments, this->m_path, "comments"); + m_io->createCommonNWBAttributes(m_path, "core", neurodataType, description); + m_io->createAttribute(comments, m_path, "comments"); // setup datasets - this->data = - std::unique_ptr(this->m_io->createArrayDataSet( - dataType, dsetSize, chunkSize, this->m_path + "/data")); - this->m_io->createDataAttributes(this->m_path, conversion, resolution, unit); + this->data = std::unique_ptr(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( - this->m_io->createArrayDataSet(this->timestampsType, - tsDsetSize, - chunkSize, - this->m_path + "/timestamps")); - this->m_io->createTimestampsAttributes(this->m_path); + this->timestamps = + std::unique_ptr(m_io->createArrayDataSet( + this->timestampsType, tsDsetSize, chunkSize, m_path + "/timestamps")); + m_io->createTimestampsAttributes(m_path); } Status TimeSeries::writeData(const std::vector& dataShape, diff --git a/src/nwb/device/Device.cpp b/src/nwb/device/Device.cpp index 905dfd5a..01036ad2 100644 --- a/src/nwb/device/Device.cpp +++ b/src/nwb/device/Device.cpp @@ -21,9 +21,8 @@ void Device::initialize() { Container::initialize(); - this->m_io->createCommonNWBAttributes( - this->m_path, "core", "Device", description); - this->m_io->createAttribute(manufacturer, this->m_path, "manufacturer"); + m_io->createCommonNWBAttributes(m_path, "core", "Device", description); + m_io->createAttribute(manufacturer, m_path, "manufacturer"); } // Getter for manufacturer diff --git a/src/nwb/ecephys/ElectricalSeries.cpp b/src/nwb/ecephys/ElectricalSeries.cpp index ff5bbc90..7be87dae 100644 --- a/src/nwb/ecephys/ElectricalSeries.cpp +++ b/src/nwb/ecephys/ElectricalSeries.cpp @@ -52,32 +52,32 @@ void ElectricalSeries::initialize() // make channel conversion dataset channelConversion = std::unique_ptr( - this->m_io->createArrayDataSet(BaseDataType::F32, - SizeArray {1}, - chunkSize, - getPath() + "/channel_conversion")); + m_io->createArrayDataSet(BaseDataType::F32, + SizeArray {1}, + chunkSize, + getPath() + "/channel_conversion")); channelConversion->writeDataBlock( std::vector(1, channelVector.size()), BaseDataType::F32, &channelConversions[0]); - this->m_io->createCommonNWBAttributes(getPath() + "/channel_conversion", - "hdmf-common", - "", - "Bit volts values for all channels"); + m_io->createCommonNWBAttributes(getPath() + "/channel_conversion", + "hdmf-common", + "", + "Bit volts values for all channels"); // make electrodes dataset electrodesDataset = std::unique_ptr( - this->m_io->createArrayDataSet(BaseDataType::I32, - SizeArray {1}, - chunkSize, - getPath() + "/electrodes")); + m_io->createArrayDataSet(BaseDataType::I32, + SizeArray {1}, + chunkSize, + getPath() + "/electrodes")); electrodesDataset->writeDataBlock( std::vector(1, channelVector.size()), BaseDataType::I32, &electrodeInds[0]); - this->m_io->createCommonNWBAttributes( + m_io->createCommonNWBAttributes( getPath() + "/electrodes", "hdmf-common", "DynamicTableRegion", ""); - this->m_io->createReferenceAttribute( + m_io->createReferenceAttribute( ElectrodeTable::electrodeTablePath, getPath() + "/electrodes", "table"); } diff --git a/src/nwb/file/ElectrodeGroup.cpp b/src/nwb/file/ElectrodeGroup.cpp index c065cb7c..0d283654 100644 --- a/src/nwb/file/ElectrodeGroup.cpp +++ b/src/nwb/file/ElectrodeGroup.cpp @@ -24,11 +24,10 @@ void ElectrodeGroup::initialize() { Container::initialize(); - this->m_io->createCommonNWBAttributes( - this->m_path, "core", "ElectrodeGroup", description); - this->m_io->createAttribute(location, this->m_path, "location"); - this->m_io->createLink("/" + this->m_path + "/device", - "/" + device.getPath()); + m_io->createCommonNWBAttributes( + m_path, "core", "ElectrodeGroup", description); + m_io->createAttribute(location, m_path, "location"); + m_io->createLink("/" + m_path + "/device", "/" + device.getPath()); } // Getter for description diff --git a/src/nwb/file/ElectrodeTable.cpp b/src/nwb/file/ElectrodeTable.cpp index 9e128000..31b60704 100644 --- a/src/nwb/file/ElectrodeTable.cpp +++ b/src/nwb/file/ElectrodeTable.cpp @@ -24,21 +24,19 @@ void ElectrodeTable::initialize() // create group DynamicTable::initialize(); - electrodeDataset->setDataset(std::unique_ptr( - this->m_io->createArrayDataSet(BaseDataType::I32, - SizeArray {1}, - SizeArray {1}, - this->m_path + "id"))); + electrodeDataset->setDataset( + std::unique_ptr(m_io->createArrayDataSet( + BaseDataType::I32, SizeArray {1}, SizeArray {1}, m_path + "id"))); groupNamesDataset->setDataset(std::unique_ptr( - this->m_io->createArrayDataSet(BaseDataType::STR(250), - SizeArray {0}, - SizeArray {1}, - this->m_path + "group_name"))); + m_io->createArrayDataSet(BaseDataType::STR(250), + SizeArray {0}, + SizeArray {1}, + m_path + "group_name"))); locationsDataset->setDataset(std::unique_ptr( - this->m_io->createArrayDataSet(BaseDataType::STR(250), - SizeArray {0}, - SizeArray {1}, - this->m_path + "location"))); + m_io->createArrayDataSet(BaseDataType::STR(250), + SizeArray {0}, + SizeArray {1}, + m_path + "location"))); } void ElectrodeTable::addElectrodes(std::vector channels) diff --git a/src/nwb/hdmf/base/Data.hpp b/src/nwb/hdmf/base/Data.hpp index 7fdef6db..833b5f87 100644 --- a/src/nwb/hdmf/base/Data.hpp +++ b/src/nwb/hdmf/base/Data.hpp @@ -38,7 +38,7 @@ class Data /** * @brief Check whether the m_dataset has been initialized */ - inline bool isInitialized() { return this->m_dataset != nullptr; } + inline bool isInitialized() { return m_dataset != nullptr; } std::unique_ptr m_dataset; }; diff --git a/src/nwb/hdmf/table/DynamicTable.cpp b/src/nwb/hdmf/table/DynamicTable.cpp index d50a272f..37eff45a 100644 --- a/src/nwb/hdmf/table/DynamicTable.cpp +++ b/src/nwb/hdmf/table/DynamicTable.cpp @@ -21,9 +21,9 @@ void DynamicTable::initialize() { Container::initialize(); - this->m_io->createCommonNWBAttributes( - this->m_path, "hdmf-common", "DynamicTable", getDescription()); - this->m_io->createAttribute(getColNames(), this->m_path, "colnames"); + m_io->createCommonNWBAttributes( + m_path, "hdmf-common", "DynamicTable", getDescription()); + m_io->createAttribute(getColNames(), m_path, "colnames"); } /** Add column to table */ @@ -41,8 +41,8 @@ void DynamicTable::addColumn(const std::string& name, std::vector(1, 1), BaseDataType::STR(values[i].size() + 1), values[i].c_str()); // TODO - add tests for this - this->m_io->createCommonNWBAttributes( - this->m_path + name, "hdmf-common", "VectorData", colDescription); + m_io->createCommonNWBAttributes( + m_path + name, "hdmf-common", "VectorData", colDescription); } } @@ -54,8 +54,8 @@ void DynamicTable::setRowIDs(std::unique_ptr& elementIDs, } else { elementIDs->m_dataset->writeDataBlock( std::vector(1, values.size()), BaseDataType::I32, &values[0]); - this->m_io->createCommonNWBAttributes( - this->m_path + "id", "hdmf-common", "ElementIdentifiers"); + m_io->createCommonNWBAttributes( + m_path + "id", "hdmf-common", "ElementIdentifiers"); } } @@ -66,9 +66,9 @@ void DynamicTable::addColumn(const std::string& name, if (values.empty()) { std::cerr << "Data to add to column is empty" << std::endl; } else { - this->m_io->createReferenceDataSet(this->m_path + name, values); - this->m_io->createCommonNWBAttributes( - this->m_path + name, "hdmf-common", "VectorData", colDescription); + m_io->createReferenceDataSet(m_path + name, values); + m_io->createCommonNWBAttributes( + m_path + name, "hdmf-common", "VectorData", colDescription); } } From be496199f34b2e0e806a9bcf8047315f94d18cfd Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 17:12:14 -0700 Subject: [PATCH 15/26] Update src/nwb/ecephys/SpikeEventSeries.hpp Co-authored-by: Steph Prince <40640337+stephprince@users.noreply.github.com> --- src/nwb/ecephys/SpikeEventSeries.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nwb/ecephys/SpikeEventSeries.hpp b/src/nwb/ecephys/SpikeEventSeries.hpp index 401500dd..cbd541da 100644 --- a/src/nwb/ecephys/SpikeEventSeries.hpp +++ b/src/nwb/ecephys/SpikeEventSeries.hpp @@ -17,7 +17,7 @@ class SpikeEventSeries : public ElectricalSeries public: /** * @brief Constructor. - * @param path The location of the ElectricalSeries in the file. + * @param path The location of the SpikeEventSeries in the file. * @param io A shared pointer to the IO object. * @param dataType The data type to use for storing the recorded voltage * @param channelVector The electrodes to use for recording From 430600a09c542df94fb17d06df708cc7fb459259 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:24:38 -0700 Subject: [PATCH 16/26] Remove setters from channel --- src/Channel.hpp | 59 ------------------------------------------------- 1 file changed, 59 deletions(-) diff --git a/src/Channel.hpp b/src/Channel.hpp index 39cfc4af..70ad4edf 100644 --- a/src/Channel.hpp +++ b/src/Channel.hpp @@ -134,32 +134,6 @@ class Channel m_position = position; } - /** - * @brief Set index of channel across the recording system. - * @param globalIndex The globalIndex to set. - */ - inline void setGlobalIndex(const SizeType globalIndex) - { - m_globalIndex = globalIndex; - } - - /** - * @brief Set index of channel within the recording array. - * @param localIndex The localIndex to set. - */ - inline void setLocalIndex(const SizeType localIndex) - { - m_localIndex = localIndex; - } - - /** - * @brief Set index of array group the channel belongs to. - * @param groupIndex The groupIndex to set. - */ - inline void setGroupIndex(const SizeType groupIndex) - { - m_groupIndex = groupIndex; - } /** * @brief Set name of the channel. @@ -167,39 +141,6 @@ class Channel */ inline void setName(const std::string& name) { m_name = name; } - /** - * @brief Set name of the array group the channel belongs to. - * @param groupName The groupName to set. - */ - inline void setGroupName(const std::string& groupName) - { - m_groupName = groupName; - } - - /** - * @brief Set conversion factor. - * @param conversion The conversion to set. - */ - inline void setConversion(const float conversion) - { - m_conversion = conversion; - } - - /** - * @brief Set sampling rate of the channel. - * @param samplingRate The samplingRate to set. - */ - inline void setSamplingRate(const float samplingRate) - { - m_samplingRate = samplingRate; - } - - /** - * @brief Set floating point value of microvolts per bit - * @param bitVolts The bitVolts to set. - */ - inline void setBitVolts(const float bitVolts) { m_bitVolts = bitVolts; } - private: /** * @brief Comments about the channel. From 3a685f644c2b466d7b105b96969b42ba074e0eec Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 17:25:44 -0700 Subject: [PATCH 17/26] Make simple getters in BaseIO in the header and remove redundant override of getFilename in HDF5IO --- src/BaseIO.cpp | 20 -------------------- src/BaseIO.hpp | 8 ++++---- src/hdf5/HDF5IO.cpp | 5 ----- src/hdf5/HDF5IO.hpp | 6 ------ 4 files changed, 4 insertions(+), 35 deletions(-) diff --git a/src/BaseIO.cpp b/src/BaseIO.cpp index e5031d3e..027d81c6 100644 --- a/src/BaseIO.cpp +++ b/src/BaseIO.cpp @@ -40,26 +40,6 @@ BaseIO::BaseIO(const std::string& filename) BaseIO::~BaseIO() {} -bool BaseIO::isOpen() const -{ - return m_opened; -} - -std::string BaseIO::getFileName() -{ - return m_filename; -} - -bool BaseIO::isReadyToOpen() const -{ - return m_readyToOpen; -} - -bool BaseIO::canModifyObjects() -{ - return true; -} - Status BaseIO::createCommonNWBAttributes(const std::string& path, const std::string& objectNamespace, const std::string& neurodataType, diff --git a/src/BaseIO.hpp b/src/BaseIO.hpp index 268695e3..480d96e1 100644 --- a/src/BaseIO.hpp +++ b/src/BaseIO.hpp @@ -115,7 +115,7 @@ class BaseIO * @brief Returns the full path to the file. * @return The full path to the file. */ - virtual std::string getFileName(); + virtual std::string getFileName() const { return m_filename; } /** * @brief Opens the file for writing. @@ -267,7 +267,7 @@ class BaseIO * override this function to check if objects can be modified. * @return True if the file is in a modification mode, false otherwise. */ - virtual bool canModifyObjects(); + virtual bool canModifyObjects() { return true; } /** * @brief Creates an extendable dataset with a given base data type, size, @@ -338,13 +338,13 @@ class BaseIO * @brief Returns true if the file is open. * @return True if the file is open, false otherwise. */ - bool isOpen() const; + inline bool isOpen() const { return m_opened; } /** * @brief Returns true if the file is able to be opened. * @return True if the file is able to be opened, false otherwise. */ - bool isReadyToOpen() const; + inline bool isReadyToOpen() const { return m_readyToOpen; } protected: /** diff --git a/src/hdf5/HDF5IO.cpp b/src/hdf5/HDF5IO.cpp index 844fb2b8..2efdf689 100644 --- a/src/hdf5/HDF5IO.cpp +++ b/src/hdf5/HDF5IO.cpp @@ -26,11 +26,6 @@ HDF5IO::~HDF5IO() close(); } -std::string HDF5IO::getFileName() -{ - return m_filename; -} - Status HDF5IO::open() { if (std::filesystem::exists(getFileName())) { diff --git a/src/hdf5/HDF5IO.hpp b/src/hdf5/HDF5IO.hpp index 00278d49..21fde096 100644 --- a/src/hdf5/HDF5IO.hpp +++ b/src/hdf5/HDF5IO.hpp @@ -48,12 +48,6 @@ class HDF5IO : public BaseIO */ ~HDF5IO(); - /** - * @brief Returns the full path to the HDF5 file. - * @return The full path to the HDF5 file. - */ - std::string getFileName() override; - /** * @brief Opens an existing file or creates a new file for writing. * @return The status of the file opening operation. From 57c85207e7a29648984bdd994768a4d72450cfc9 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 17:27:24 -0700 Subject: [PATCH 18/26] Fix formatting --- src/Channel.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Channel.hpp b/src/Channel.hpp index 70ad4edf..3d157f5d 100644 --- a/src/Channel.hpp +++ b/src/Channel.hpp @@ -134,7 +134,6 @@ class Channel m_position = position; } - /** * @brief Set name of the channel. * @param name The name to set. From b7a8792195d21539f2b4b4cae35ff84a9e33349b Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 17:30:58 -0700 Subject: [PATCH 19/26] Make simple getter for HDF5RecordingData inline --- src/hdf5/HDF5IO.cpp | 5 ----- src/hdf5/HDF5IO.hpp | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/hdf5/HDF5IO.cpp b/src/hdf5/HDF5IO.cpp index 2efdf689..4f087a4a 100644 --- a/src/hdf5/HDF5IO.cpp +++ b/src/hdf5/HDF5IO.cpp @@ -727,8 +727,3 @@ Status HDF5RecordingData::writeDataBlock( } return Status::Success; } - -const H5::DataSet* HDF5RecordingData::getDataSet() -{ - return this->m_dataset.get(); -}; diff --git a/src/hdf5/HDF5IO.hpp b/src/hdf5/HDF5IO.hpp index 21fde096..7cab75cc 100644 --- a/src/hdf5/HDF5IO.hpp +++ b/src/hdf5/HDF5IO.hpp @@ -319,7 +319,7 @@ class HDF5RecordingData : public 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 this->m_dataset.get(); } private: /** From f1122d03cfbe831b8b72e5f9d99fcaf13709157c Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 17:32:36 -0700 Subject: [PATCH 20/26] Make simple getter for RecordingContainers inline --- src/nwb/RecordingContainers.cpp | 5 ----- src/nwb/RecordingContainers.hpp | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/nwb/RecordingContainers.cpp b/src/nwb/RecordingContainers.cpp index cd2b96c5..59b01bfb 100644 --- a/src/nwb/RecordingContainers.cpp +++ b/src/nwb/RecordingContainers.cpp @@ -79,8 +79,3 @@ Status RecordingContainers::writeSpikeEventData(const SizeType& containerInd, ses->writeSpike(numSamples, numChannels, data, timestamps); } - -SizeType RecordingContainers::size() -{ - return m_containers.size(); -} \ No newline at end of file diff --git a/src/nwb/RecordingContainers.hpp b/src/nwb/RecordingContainers.hpp index 6b47056f..0ffd938d 100644 --- a/src/nwb/RecordingContainers.hpp +++ b/src/nwb/RecordingContainers.hpp @@ -108,7 +108,7 @@ class RecordingContainers /** * @brief Get the number of recording containers */ - SizeType size(); + inline SizeType size() const { return m_containers.size(); } private: /** From 940bf0621d40d9075ec2c1cfff38e0dbee89d3d3 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:43:18 -0700 Subject: [PATCH 21/26] replace this->m_ with just m_ --- src/hdf5/HDF5IO.cpp | 58 ++++++++++++++++++++++----------------------- src/hdf5/HDF5IO.hpp | 2 +- src/nwb/NWBFile.cpp | 44 +++++++++++++++++----------------- 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/hdf5/HDF5IO.cpp b/src/hdf5/HDF5IO.cpp index 4f087a4a..4bf287d2 100644 --- a/src/hdf5/HDF5IO.cpp +++ b/src/hdf5/HDF5IO.cpp @@ -278,7 +278,7 @@ Status HDF5IO::createGroup(const std::string& path) if (!m_opened) return Status::Failure; try { - this->m_file->createGroup(path); + m_file->createGroup(path); } catch (FileIException error) { error.printErrorStack(); } catch (GroupIException error) { @@ -289,10 +289,10 @@ Status HDF5IO::createGroup(const std::string& path) Status HDF5IO::createGroupIfDoesNotExist(const std::string& path) { - if (!this->m_opened) + if (!m_opened) return Status::Failure; try { - this->m_file->childObjType(path); + m_file->childObjType(path); } catch (FileIException) { return createGroup(path); } @@ -302,11 +302,11 @@ Status HDF5IO::createGroupIfDoesNotExist(const std::string& path) /** Creates a link to another location in the file */ Status HDF5IO::createLink(const std::string& path, const std::string& reference) { - if (!this->m_opened) + if (!m_opened) return Status::Failure; herr_t error = H5Lcreate_soft(reference.c_str(), - this->m_file->getLocId(), + m_file->getLocId(), path.c_str(), H5P_DEFAULT, H5P_DEFAULT); @@ -317,7 +317,7 @@ Status HDF5IO::createLink(const std::string& path, const std::string& reference) Status HDF5IO::createReferenceDataSet( const std::string& path, const std::vector& references) { - if (!this->m_opened) + if (!m_opened) return Status::Failure; const hsize_t size = references.size(); @@ -325,12 +325,12 @@ Status HDF5IO::createReferenceDataSet( hobj_ref_t* rdata = new hobj_ref_t[size * sizeof(hobj_ref_t)]; for (SizeType i = 0; i < size; i++) { - this->m_file->reference(&rdata[i], references[i].c_str()); + m_file->reference(&rdata[i], references[i].c_str()); } hid_t space = H5Screate_simple(1, &size, NULL); - hid_t dset = H5Dcreate(this->m_file->getLocId(), + hid_t dset = H5Dcreate(m_file->getLocId(), path.c_str(), H5T_STD_REF_OBJ, space, @@ -352,7 +352,7 @@ Status HDF5IO::createReferenceDataSet( Status HDF5IO::createStringDataSet(const std::string& path, const std::string& value) { - if (!this->m_opened) + if (!m_opened) return Status::Failure; std::unique_ptr dataset; @@ -360,7 +360,7 @@ Status HDF5IO::createStringDataSet(const std::string& path, DataSpace dSpace(H5S_SCALAR); dataset = std::make_unique( - this->m_file->createDataSet(path, H5type, dSpace)); + m_file->createDataSet(path, H5type, dSpace)); dataset->write(value.c_str(), H5type); return Status::Success; @@ -369,7 +369,7 @@ Status HDF5IO::createStringDataSet(const std::string& path, Status HDF5IO::createStringDataSet(const std::string& path, const std::vector& values) { - if (!this->m_opened) + if (!m_opened) return Status::Failure; std::vector cStrs; @@ -389,11 +389,11 @@ Status HDF5IO::createStringDataSet(const std::string& path, Status HDF5IO::startRecording() { - if (!this->m_opened) + if (!m_opened) return Status::Failure; - if (!this->m_disableSWMRMode) { - herr_t status = H5Fstart_swmr_write(this->m_file->getId()); + if (!m_disableSWMRMode) { + herr_t status = H5Fstart_swmr_write(m_file->getId()); return checkStatus(status); } return Status::Success; @@ -402,7 +402,7 @@ Status HDF5IO::startRecording() Status HDF5IO::stopRecording() { // if SWMR mode is disabled, stopping the recording will leave the file open - if (!this->m_disableSWMRMode) { + if (!m_disableSWMRMode) { close(); // SWMR mode cannot be disabled so close the file } else { this->flush(); @@ -412,13 +412,13 @@ Status HDF5IO::stopRecording() bool HDF5IO::canModifyObjects() { - if (!this->m_opened) + if (!m_opened) return false; // Check if we are in SWMR mode bool inSWMRMode = false; unsigned int intent; - herr_t status = H5Fget_intent(this->m_file->getId(), &intent); + herr_t status = H5Fget_intent(m_file->getId(), &intent); bool statusOK = (status >= 0); if (statusOK) { inSWMRMode = (intent & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE)); @@ -431,7 +431,7 @@ bool HDF5IO::canModifyObjects() bool HDF5IO::objectExists(const std::string& path) { - htri_t exists = H5Lexists(this->m_file->getId(), path.c_str(), H5P_DEFAULT); + htri_t exists = H5Lexists(m_file->getId(), path.c_str(), H5P_DEFAULT); if (exists > 0) { return true; } else { @@ -444,11 +444,11 @@ std::unique_ptr HDF5IO::getDataSet( { std::unique_ptr data; - if (!this->m_opened) + if (!m_opened) return nullptr; try { - data = std::make_unique(this->m_file->openDataSet(path)); + data = std::make_unique(m_file->openDataSet(path)); return std::make_unique(std::move(data)); } catch (DataSetIException error) { error.printErrorStack(); @@ -472,7 +472,7 @@ std::unique_ptr HDF5IO::createArrayDataSet( DSetCreatPropList prop; DataType H5type = getH5Type(type); - if (!this->m_opened) + if (!m_opened) return nullptr; SizeType dimension = size.size(); @@ -501,7 +501,7 @@ std::unique_ptr HDF5IO::createArrayDataSet( prop.setChunk(static_cast(dimension), chunk_dims.data()); data = std::make_unique( - this->m_file->createDataSet(path, H5type, dSpace, prop)); + m_file->createDataSet(path, H5type, dSpace, prop)); return std::make_unique(std::move(data)); } @@ -511,7 +511,7 @@ H5O_type_t HDF5IO::getObjectType(const std::string& path) #if H5_VERSION_GE(1, 12, 0) // get whether path is a dataset or group H5O_info_t objInfo; // Structure to hold information about the object - H5Oget_info_by_name(this->m_file->getId(), + H5Oget_info_by_name(m_file->getId(), path.c_str(), &objInfo, H5O_INFO_BASIC, @@ -520,7 +520,7 @@ H5O_type_t HDF5IO::getObjectType(const std::string& path) // get whether path is a dataset or group H5O_info_t objInfo; // Structure to hold information about the object H5Oget_info_by_name( - this->m_file->getId(), path.c_str(), &objInfo, H5P_DEFAULT); + m_file->getId(), path.c_str(), &objInfo, H5P_DEFAULT); #endif H5O_type_t objectType = objInfo.type; @@ -649,7 +649,7 @@ HDF5RecordingData::HDF5RecordingData(std::unique_ptr data) this->nDimensions = nDimensions; this->position = std::vector( nDimensions, 0); // Initialize position with 0 for each dimension - this->m_dataset = std::make_unique(*data); + m_dataset = std::make_unique(*data); } // HDF5RecordingData @@ -657,7 +657,7 @@ HDF5RecordingData::HDF5RecordingData(std::unique_ptr data) HDF5RecordingData::~HDF5RecordingData() { // Safety - this->m_dataset->flush(H5F_SCOPE_GLOBAL); + m_dataset->flush(H5F_SCOPE_GLOBAL); } Status HDF5RecordingData::writeDataBlock( @@ -686,10 +686,10 @@ Status HDF5RecordingData::writeDataBlock( } // Adjust dataset dimensions if necessary - this->m_dataset->extend(dSetDims.data()); + m_dataset->extend(dSetDims.data()); // Set size to new size based on updated dimensionality - DataSpace fSpace = this->m_dataset->getSpace(); + DataSpace fSpace = m_dataset->getSpace(); fSpace.getSimpleExtentDims(dSetDims.data()); for (int i = 0; i < nDimensions; ++i) { size[i] = dSetDims[i]; @@ -712,7 +712,7 @@ Status HDF5RecordingData::writeDataBlock( // Write the data DataType nativeType = HDF5IO::getNativeType(type); - this->m_dataset->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) { diff --git a/src/hdf5/HDF5IO.hpp b/src/hdf5/HDF5IO.hpp index 7cab75cc..d9f3c851 100644 --- a/src/hdf5/HDF5IO.hpp +++ b/src/hdf5/HDF5IO.hpp @@ -319,7 +319,7 @@ class HDF5RecordingData : public BaseRecordingData * @brief Gets a const pointer to the HDF5 dataset. * @return A const pointer to the HDF5 dataset. */ - inline const H5::DataSet* getDataSet() const { return this->m_dataset.get(); } + inline const H5::DataSet* getDataSet() const { return m_dataset.get(); } private: /** diff --git a/src/nwb/NWBFile.cpp b/src/nwb/NWBFile.cpp index 08034b1a..d07af5b8 100644 --- a/src/nwb/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -120,12 +120,12 @@ Status NWBFile::createElectricalSeries( bool electrodeTableCreated = m_io->objectExists(ElectrodeTable::electrodeTablePath); if (!electrodeTableCreated) { - m_electrodeTable = std::make_unique(this->m_io); - this->m_electrodeTable->initialize(); + m_electrodeTable = std::make_unique(m_io); + m_electrodeTable->initialize(); // Add electrode information to table (does not write to datasets yet) for (const auto& channelVector : recordingArrays) { - this->m_electrodeTable->addElectrodes(channelVector); + m_electrodeTable->addElectrodes(channelVector); } } @@ -142,19 +142,19 @@ Status NWBFile::createElectricalSeries( // Check if device exists for groupName, create device and electrode group // if not - if (!this->m_io->objectExists(devicePath)) { - Device device = Device(devicePath, this->m_io, "description", "unknown"); + if (!m_io->objectExists(devicePath)) { + Device device = Device(devicePath, m_io, "description", "unknown"); device.initialize(); ElectrodeGroup elecGroup = ElectrodeGroup( - electrodePath, this->m_io, "description", "unknown", device); + electrodePath, m_io, "description", "unknown", device); elecGroup.initialize(); } // Setup electrical series datasets auto electricalSeries = std::make_unique( electricalSeriesPath, - this->m_io, + m_io, dataType, channelVector, "Stores continuously sampled voltage data from an " @@ -169,7 +169,7 @@ Status NWBFile::createElectricalSeries( // write electrode information to datasets // (requires that the ElectrodeGroup has been written) if (!electrodeTableCreated) { - this->m_electrodeTable->finalize(); + m_electrodeTable->finalize(); } return Status::Success; @@ -182,7 +182,7 @@ Status NWBFile::createSpikeEventSeries( RecordingContainers* recordingContainers, std::vector& containerIndexes) { - if (!this->m_io->canModifyObjects()) { + if (!m_io->canModifyObjects()) { return Status::Failure; } @@ -192,14 +192,14 @@ Status NWBFile::createSpikeEventSeries( // Setup electrode table if it was not yet created bool electrodeTableCreated = - this->m_io->objectExists(ElectrodeTable::electrodeTablePath); + m_io->objectExists(ElectrodeTable::electrodeTablePath); if (!electrodeTableCreated) { - this->m_electrodeTable = std::make_unique(this->m_io); - this->m_electrodeTable->initialize(); + m_electrodeTable = std::make_unique(m_io); + m_electrodeTable->initialize(); // Add electrode information to table (does not write to datasets yet) for (const auto& channelVector : recordingArrays) { - this->m_electrodeTable->addElectrodes(channelVector); + m_electrodeTable->addElectrodes(channelVector); } } @@ -216,12 +216,12 @@ Status NWBFile::createSpikeEventSeries( // Check if device exists for groupName, create device and electrode group // if not - if (!this->m_io->objectExists(devicePath)) { - Device device = Device(devicePath, this->m_io, "description", "unknown"); + if (!m_io->objectExists(devicePath)) { + Device device = Device(devicePath, m_io, "description", "unknown"); device.initialize(); ElectrodeGroup elecGroup = ElectrodeGroup( - electrodePath, this->m_io, "description", "unknown", device); + electrodePath, m_io, "description", "unknown", device); elecGroup.initialize(); } @@ -238,7 +238,7 @@ Status NWBFile::createSpikeEventSeries( auto spikeEventSeries = std::make_unique( spikeEventSeriesPath, - this->m_io, + m_io, dataType, channelVector, "Stores spike waveforms from an extracellular ephys recording", @@ -252,7 +252,7 @@ Status NWBFile::createSpikeEventSeries( // write electrode information to datasets // (requires that the ElectrodeGroup has been written) if (!electrodeTableCreated) { - this->m_electrodeTable->finalize(); + m_electrodeTable->finalize(); } return Status::Success; @@ -265,11 +265,11 @@ void NWBFile::cacheSpecifications( const std::array, N>& specVariables) { - this->m_io->createGroup("/specifications/" + specPath); - this->m_io->createGroup("/specifications/" + specPath + "/" + versionNumber); + m_io->createGroup("/specifications/" + specPath); + m_io->createGroup("/specifications/" + specPath + "/" + versionNumber); for (const auto& [name, content] : specVariables) { - this->m_io->createStringDataSet("/specifications/" + specPath + "/" + m_io->createStringDataSet("/specifications/" + specPath + "/" + versionNumber + "/" + std::string(name), std::string(content)); @@ -284,5 +284,5 @@ std::unique_ptr NWBFile::createRecordingData( const std::string& path) { return std::unique_ptr( - this->m_io->createArrayDataSet(type, size, chunking, path)); + m_io->createArrayDataSet(type, size, chunking, path)); } From d73d7a2bfa916883146c0db5fa54775dc102ca49 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 17:44:19 -0700 Subject: [PATCH 22/26] Move simple setters for DynamicTable and remove redundant definitions with ElectrodeTable --- src/nwb/file/ElectrodeTable.cpp | 19 ------------------- src/nwb/file/ElectrodeTable.hpp | 18 +++++------------- src/nwb/hdmf/table/DynamicTable.cpp | 14 +------------- src/nwb/hdmf/table/DynamicTable.hpp | 20 ++++++++++++++++---- 4 files changed, 22 insertions(+), 49 deletions(-) diff --git a/src/nwb/file/ElectrodeTable.cpp b/src/nwb/file/ElectrodeTable.cpp index 31b60704..f78d7160 100644 --- a/src/nwb/file/ElectrodeTable.cpp +++ b/src/nwb/file/ElectrodeTable.cpp @@ -65,22 +65,3 @@ void ElectrodeTable::finalize() "a reference to the ElectrodeGroup this electrode is a part of", groupReferences); } - -// Getter for colNames -const std::vector& ElectrodeTable::getColNames() -{ - return colNames; -} - -// Setter for colNames -void ElectrodeTable::setColNames(const std::vector& newColNames) -{ - colNames = newColNames; -} - -// Getter for groupPath -std::string ElectrodeTable::getGroupPath() const -{ - return groupReferences[0]; // all channels in ChannelVector should have the - // same groupName -} diff --git a/src/nwb/file/ElectrodeTable.hpp b/src/nwb/file/ElectrodeTable.hpp index b8611a32..409ae17d 100644 --- a/src/nwb/file/ElectrodeTable.hpp +++ b/src/nwb/file/ElectrodeTable.hpp @@ -52,23 +52,15 @@ class ElectrodeTable : public DynamicTable */ void addElectrodes(std::vector channels); - /** - * @brief Gets the column names of the ElectrodeTable. - * @return The vector of column names. - */ - const std::vector& getColNames() override; - - /** - * @brief Sets the column names of the ElectrodeTable. - * @param newColNames The vector of new column names. - */ - void setColNames(const std::vector& newColNames); - /** * @brief Gets the group path of the ElectrodeTable. * @return The group path. */ - std::string getGroupPath() const; + inline std::string getGroupPath() const + { + // all channels in ChannelVector should have the same groupName + return groupReferences[0]; + } /** * @brief Sets the group path of the ElectrodeTable. diff --git a/src/nwb/hdmf/table/DynamicTable.cpp b/src/nwb/hdmf/table/DynamicTable.cpp index 37eff45a..8154b496 100644 --- a/src/nwb/hdmf/table/DynamicTable.cpp +++ b/src/nwb/hdmf/table/DynamicTable.cpp @@ -9,7 +9,7 @@ DynamicTable::DynamicTable(const std::string& path, std::shared_ptr io, const std::string& description) : Container(path, io) - , description(description) + , m_description(description) { } @@ -71,15 +71,3 @@ void DynamicTable::addColumn(const std::string& name, m_path + name, "hdmf-common", "VectorData", colDescription); } } - -// Getter for description -std::string DynamicTable::getDescription() const -{ - return description; -} - -// Getter for colNames -const std::vector& DynamicTable::getColNames() -{ - return colNames; -} diff --git a/src/nwb/hdmf/table/DynamicTable.hpp b/src/nwb/hdmf/table/DynamicTable.hpp index 6cd8c2a5..b92eab73 100644 --- a/src/nwb/hdmf/table/DynamicTable.hpp +++ b/src/nwb/hdmf/table/DynamicTable.hpp @@ -74,23 +74,35 @@ class DynamicTable : public Container * @brief Gets the description of the table. * @return The description of the table. */ - std::string getDescription() const; + inline std::string getDescription() const { return m_description; } /** * @brief Gets the column names of the table. * @return A vector of column names. */ - virtual const std::vector& getColNames() = 0; + virtual const std::vector& getColNames() const + { + return m_colNames; + } + + /** + * @brief Sets the column names of the ElectrodeTable. + * @param newColNames The vector of new column names. + */ + virtual void setColNames(const std::vector& newColNames) + { + m_colNames = newColNames; + } private: /** * @brief Description of the DynamicTable. */ - std::string description; + std::string m_description; /** * @brief Names of the columns in the table. */ - std::vector colNames; + std::vector m_colNames; }; } // namespace AQNWB::NWB From f2816c29ce757a38d8fa9b527cc23646e72a3f01 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:45:47 -0700 Subject: [PATCH 23/26] fix formatting --- src/hdf5/HDF5IO.cpp | 10 +++------- src/nwb/NWBFile.cpp | 13 ++++++------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/hdf5/HDF5IO.cpp b/src/hdf5/HDF5IO.cpp index 4bf287d2..9529f246 100644 --- a/src/hdf5/HDF5IO.cpp +++ b/src/hdf5/HDF5IO.cpp @@ -511,16 +511,12 @@ H5O_type_t HDF5IO::getObjectType(const std::string& path) #if H5_VERSION_GE(1, 12, 0) // get whether path is a dataset or group H5O_info_t objInfo; // Structure to hold information about the object - H5Oget_info_by_name(m_file->getId(), - path.c_str(), - &objInfo, - H5O_INFO_BASIC, - H5P_DEFAULT); + H5Oget_info_by_name( + m_file->getId(), path.c_str(), &objInfo, H5O_INFO_BASIC, H5P_DEFAULT); #else // get whether path is a dataset or group H5O_info_t objInfo; // Structure to hold information about the object - H5Oget_info_by_name( - m_file->getId(), path.c_str(), &objInfo, H5P_DEFAULT); + H5Oget_info_by_name(m_file->getId(), path.c_str(), &objInfo, H5P_DEFAULT); #endif H5O_type_t objectType = objInfo.type; diff --git a/src/nwb/NWBFile.cpp b/src/nwb/NWBFile.cpp index d07af5b8..9e2ed943 100644 --- a/src/nwb/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -146,8 +146,8 @@ Status NWBFile::createElectricalSeries( Device device = Device(devicePath, m_io, "description", "unknown"); device.initialize(); - ElectrodeGroup elecGroup = ElectrodeGroup( - electrodePath, m_io, "description", "unknown", device); + ElectrodeGroup elecGroup = + ElectrodeGroup(electrodePath, m_io, "description", "unknown", device); elecGroup.initialize(); } @@ -220,8 +220,8 @@ Status NWBFile::createSpikeEventSeries( Device device = Device(devicePath, m_io, "description", "unknown"); device.initialize(); - ElectrodeGroup elecGroup = ElectrodeGroup( - electrodePath, m_io, "description", "unknown", device); + ElectrodeGroup elecGroup = + ElectrodeGroup(electrodePath, m_io, "description", "unknown", device); elecGroup.initialize(); } @@ -270,9 +270,8 @@ void NWBFile::cacheSpecifications( for (const auto& [name, content] : specVariables) { m_io->createStringDataSet("/specifications/" + specPath + "/" - + versionNumber + "/" - + std::string(name), - std::string(content)); + + versionNumber + "/" + std::string(name), + std::string(content)); } } From 7bc8d3cec76b1ae81f8d25e30aeb21a6efb77b83 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 17:46:41 -0700 Subject: [PATCH 24/26] Fix formatting --- src/hdf5/HDF5IO.cpp | 10 +++------- src/nwb/NWBFile.cpp | 13 ++++++------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/hdf5/HDF5IO.cpp b/src/hdf5/HDF5IO.cpp index 4bf287d2..9529f246 100644 --- a/src/hdf5/HDF5IO.cpp +++ b/src/hdf5/HDF5IO.cpp @@ -511,16 +511,12 @@ H5O_type_t HDF5IO::getObjectType(const std::string& path) #if H5_VERSION_GE(1, 12, 0) // get whether path is a dataset or group H5O_info_t objInfo; // Structure to hold information about the object - H5Oget_info_by_name(m_file->getId(), - path.c_str(), - &objInfo, - H5O_INFO_BASIC, - H5P_DEFAULT); + H5Oget_info_by_name( + m_file->getId(), path.c_str(), &objInfo, H5O_INFO_BASIC, H5P_DEFAULT); #else // get whether path is a dataset or group H5O_info_t objInfo; // Structure to hold information about the object - H5Oget_info_by_name( - m_file->getId(), path.c_str(), &objInfo, H5P_DEFAULT); + H5Oget_info_by_name(m_file->getId(), path.c_str(), &objInfo, H5P_DEFAULT); #endif H5O_type_t objectType = objInfo.type; diff --git a/src/nwb/NWBFile.cpp b/src/nwb/NWBFile.cpp index d07af5b8..9e2ed943 100644 --- a/src/nwb/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -146,8 +146,8 @@ Status NWBFile::createElectricalSeries( Device device = Device(devicePath, m_io, "description", "unknown"); device.initialize(); - ElectrodeGroup elecGroup = ElectrodeGroup( - electrodePath, m_io, "description", "unknown", device); + ElectrodeGroup elecGroup = + ElectrodeGroup(electrodePath, m_io, "description", "unknown", device); elecGroup.initialize(); } @@ -220,8 +220,8 @@ Status NWBFile::createSpikeEventSeries( Device device = Device(devicePath, m_io, "description", "unknown"); device.initialize(); - ElectrodeGroup elecGroup = ElectrodeGroup( - electrodePath, m_io, "description", "unknown", device); + ElectrodeGroup elecGroup = + ElectrodeGroup(electrodePath, m_io, "description", "unknown", device); elecGroup.initialize(); } @@ -270,9 +270,8 @@ void NWBFile::cacheSpecifications( for (const auto& [name, content] : specVariables) { m_io->createStringDataSet("/specifications/" + specPath + "/" - + versionNumber + "/" - + std::string(name), - std::string(content)); + + versionNumber + "/" + std::string(name), + std::string(content)); } } From 45a1238ae33ae91bbf1921a55cfa840b5cb7316e Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Thu, 19 Sep 2024 17:51:44 -0700 Subject: [PATCH 25/26] Move VectorData getters --- src/nwb/hdmf/table/VectorData.cpp | 6 ------ src/nwb/hdmf/table/VectorData.hpp | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/nwb/hdmf/table/VectorData.cpp b/src/nwb/hdmf/table/VectorData.cpp index c46c0f87..e96945a5 100644 --- a/src/nwb/hdmf/table/VectorData.cpp +++ b/src/nwb/hdmf/table/VectorData.cpp @@ -1,9 +1,3 @@ #include "nwb/hdmf/table/VectorData.hpp" using namespace AQNWB::NWB; - -// VectorData -std::string VectorData::getDescription() const -{ - return m_description; -} diff --git a/src/nwb/hdmf/table/VectorData.hpp b/src/nwb/hdmf/table/VectorData.hpp index e4cd5fcd..45ee737f 100644 --- a/src/nwb/hdmf/table/VectorData.hpp +++ b/src/nwb/hdmf/table/VectorData.hpp @@ -16,7 +16,7 @@ class VectorData : public Data * @brief Gets the description of the table. * @return The description of the table. */ - std::string getDescription() const; + inline std::string getDescription() const { return m_description; } private: /** From f00b03c61d0a30bee034b437b61a9ed62d08c266 Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Fri, 20 Sep 2024 00:06:52 -0700 Subject: [PATCH 26/26] Fix hidden ElectrodeTable.colNames member and bad init --- src/nwb/file/ElectrodeTable.cpp | 3 ++- src/nwb/file/ElectrodeTable.hpp | 5 ----- src/nwb/hdmf/table/DynamicTable.cpp | 4 +++- src/nwb/hdmf/table/DynamicTable.hpp | 5 +++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/nwb/file/ElectrodeTable.cpp b/src/nwb/file/ElectrodeTable.cpp index f78d7160..0f162bce 100644 --- a/src/nwb/file/ElectrodeTable.cpp +++ b/src/nwb/file/ElectrodeTable.cpp @@ -11,7 +11,8 @@ ElectrodeTable::ElectrodeTable(std::shared_ptr io, const std::string& description) : DynamicTable(electrodeTablePath, // use the electrodeTablePath io, - description) + description, + {"group", "group_name", "location"}) { } diff --git a/src/nwb/file/ElectrodeTable.hpp b/src/nwb/file/ElectrodeTable.hpp index 409ae17d..6c3775fa 100644 --- a/src/nwb/file/ElectrodeTable.hpp +++ b/src/nwb/file/ElectrodeTable.hpp @@ -107,11 +107,6 @@ class ElectrodeTable : public DynamicTable */ std::vector groupReferences; - /** - * @brief The vector of column names for the table. - */ - std::vector colNames = {"group", "group_name", "location"}; - /** * @brief The references path to the ElectrodeGroup */ diff --git a/src/nwb/hdmf/table/DynamicTable.cpp b/src/nwb/hdmf/table/DynamicTable.cpp index 8154b496..8fa217d4 100644 --- a/src/nwb/hdmf/table/DynamicTable.cpp +++ b/src/nwb/hdmf/table/DynamicTable.cpp @@ -7,9 +7,11 @@ using namespace AQNWB::NWB; /** Constructor */ DynamicTable::DynamicTable(const std::string& path, std::shared_ptr io, - const std::string& description) + const std::string& description, + const std::vector& colNames) : Container(path, io) , m_description(description) + , m_colNames(colNames) { } diff --git a/src/nwb/hdmf/table/DynamicTable.hpp b/src/nwb/hdmf/table/DynamicTable.hpp index b92eab73..0148c756 100644 --- a/src/nwb/hdmf/table/DynamicTable.hpp +++ b/src/nwb/hdmf/table/DynamicTable.hpp @@ -27,7 +27,8 @@ class DynamicTable : public Container */ DynamicTable(const std::string& path, std::shared_ptr io, - const std::string& description); + const std::string& description, + const std::vector& colNames); /** * @brief Destructor @@ -94,7 +95,7 @@ class DynamicTable : public Container m_colNames = newColNames; } -private: +protected: /** * @brief Description of the DynamicTable. */