From f5db6a42f928d7873496c288c1dec26c04338c85 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Mon, 1 Apr 2024 16:25:27 -0700 Subject: [PATCH 1/7] add types to AQNWBIO namespace --- src/Types.hpp | 3 +++ src/io/BaseIO.hpp | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Types.hpp b/src/Types.hpp index 5012f294..17e699cc 100644 --- a/src/Types.hpp +++ b/src/Types.hpp @@ -2,6 +2,8 @@ #include +namespace AQNWBIO +{ /** * @brief Provides definitions for various types used in the project. */ @@ -27,3 +29,4 @@ class Types */ using SizeArray = std::vector; }; +} // namespace AQNWBIO diff --git a/src/io/BaseIO.hpp b/src/io/BaseIO.hpp index 1d95924d..c85c3673 100644 --- a/src/io/BaseIO.hpp +++ b/src/io/BaseIO.hpp @@ -10,9 +10,9 @@ #define DEFAULT_STR_SIZE 256 #define DEFAULT_ARRAY_SIZE 1 -using Status = Types::Status; -using SizeArray = Types::SizeArray; -using SizeType = Types::SizeType; +using Status = AQNWBIO::Types::Status; +using SizeArray = AQNWBIO::Types::SizeArray; +using SizeType = AQNWBIO::Types::SizeType; namespace AQNWBIO { From 28d2c7f60d9e65a3b7455f631d47534514053c58 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Tue, 2 Apr 2024 13:24:10 -0700 Subject: [PATCH 2/7] add nested hdf5 and schema namespaces --- CMakeLists.txt | 16 +++++----- src/NWBFile.cpp | 29 ++++++++++--------- src/NWBFile.hpp | 4 +-- src/Types.hpp | 4 +-- src/Utils.hpp | 4 +-- src/io/BaseIO.cpp | 2 +- src/io/BaseIO.hpp | 10 +++---- src/io/HDF5IO.cpp | 12 ++++---- src/io/HDF5IO.hpp | 4 +-- src/{ => schema}/hdmf/base/Container.cpp | 4 +-- src/{ => schema}/hdmf/base/Container.hpp | 4 +-- src/{ => schema}/hdmf/base/Data.hpp | 4 +-- src/{ => schema}/hdmf/table/DynamicTable.cpp | 4 +-- src/{ => schema}/hdmf/table/DynamicTable.hpp | 10 +++---- .../hdmf/table/ElementIdentifiers.hpp | 6 ++-- src/{ => schema}/hdmf/table/VectorData.cpp | 4 +-- src/{ => schema}/hdmf/table/VectorData.hpp | 6 ++-- src/{ => schema/nwb}/device/Device.cpp | 4 +-- src/{ => schema/nwb}/device/Device.hpp | 6 ++-- src/{ => schema/nwb}/file/ElectrodeGroup.cpp | 4 +-- src/{ => schema/nwb}/file/ElectrodeGroup.hpp | 8 ++--- src/{ => schema/nwb}/file/ElectrodeTable.cpp | 4 +-- src/{ => schema/nwb}/file/ElectrodeTable.hpp | 10 +++---- tests/aq-nwb_test.cpp | 28 +++++++++--------- 24 files changed, 96 insertions(+), 95 deletions(-) rename src/{ => schema}/hdmf/base/Container.cpp (82%) rename src/{ => schema}/hdmf/base/Container.hpp (93%) rename src/{ => schema}/hdmf/base/Data.hpp (85%) rename src/{ => schema}/hdmf/table/DynamicTable.cpp (96%) rename src/{ => schema}/hdmf/table/DynamicTable.hpp (93%) rename src/{ => schema}/hdmf/table/ElementIdentifiers.hpp (65%) rename src/{ => schema}/hdmf/table/VectorData.cpp (54%) rename src/{ => schema}/hdmf/table/VectorData.hpp (81%) rename src/{ => schema/nwb}/device/Device.cpp (91%) rename src/{ => schema/nwb}/device/Device.hpp (93%) rename src/{ => schema/nwb}/file/ElectrodeGroup.cpp (93%) rename src/{ => schema/nwb}/file/ElectrodeGroup.hpp (93%) rename src/{ => schema/nwb}/file/ElectrodeTable.cpp (96%) rename src/{ => schema/nwb}/file/ElectrodeTable.hpp (93%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0755a9b..3342f9c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,14 +20,14 @@ add_library( src/Utils.hpp src/io/HDF5IO.cpp src/io/BaseIO.cpp - src/hdmf/base/Data.hpp - src/hdmf/base/Container.cpp - src/hdmf/table/DynamicTable.cpp - src/hdmf/table/ElementIdentifiers.hpp - src/hdmf/table/VectorData.hpp - src/device/Device.cpp - src/file/ElectrodeGroup.cpp - src/file/ElectrodeTable.cpp + src/schema/hdmf/base/Data.hpp + src/schema/hdmf/base/Container.cpp + src/schema/hdmf/table/DynamicTable.cpp + src/schema/hdmf/table/ElementIdentifiers.hpp + src/schema/hdmf/table/VectorData.hpp + src/schema/nwb/device/Device.cpp + src/schema/nwb/file/ElectrodeGroup.cpp + src/schema/nwb/file/ElectrodeTable.cpp ) target_include_directories( diff --git a/src/NWBFile.cpp b/src/NWBFile.cpp index 3f667292..69a5e123 100644 --- a/src/NWBFile.cpp +++ b/src/NWBFile.cpp @@ -9,13 +9,12 @@ #include "NWBFile.hpp" #include "Utils.hpp" -#include "device/Device.hpp" -#include "file/ElectrodeGroup.hpp" -#include "file/ElectrodeTable.hpp" #include "io/BaseIO.hpp" +#include "schema/nwb/device/Device.hpp" +#include "schema/nwb/file/ElectrodeGroup.hpp" +#include "schema/nwb/file/ElectrodeTable.hpp" -using namespace AQNWBIO; -namespace fs = std::filesystem; +using namespace AQNWB; // NWBFile @@ -98,17 +97,19 @@ Status NWBFile::startRecording() std::string devicePath = "general/devices/" + groupName; std::string elecPath = "general/extracellular_ephys/" + groupName; - Device device = Device(devicePath, io, "description", "unknown"); + Schema::Device device = + Schema::Device(devicePath, io, "description", "unknown"); device.initialize(); - ElectrodeGroup elecGroup = - ElectrodeGroup(elecPath, io, "description", "unknown", device); + Schema::ElectrodeGroup elecGroup = + Schema::ElectrodeGroup(elecPath, io, "description", "unknown", device); elecGroup.initialize(); } // Create electrode table std::string electrodePath = "general/extracellular_ephys/electrodes/"; - ElectrodeTable elecTable = ElectrodeTable(electrodePath, io, channels); + Schema::ElectrodeTable elecTable = + Schema::ElectrodeTable(electrodePath, io, channels); elecTable.initialize(); elecTable.electrodeDataset->dataset = createRecordingData( @@ -137,12 +138,14 @@ void NWBFile::cacheSpecifications(const std::string& specPath, io->createGroup("/specifications/" + specPath); io->createGroup("/specifications/" + specPath + versionNumber); - fs::path currentFile = __FILE__; - fs::path schemaDir = currentFile.parent_path().parent_path() + std::filesystem::path currentFile = __FILE__; + std::filesystem::path schemaDir = currentFile.parent_path().parent_path() / "resources/spec" / specPath / versionNumber; - for (auto const& entry : fs::directory_iterator {schemaDir}) - if (fs::is_regular_file(entry) && entry.path().extension() == ".json") { + for (auto const& entry : std::filesystem::directory_iterator {schemaDir}) + if (std::filesystem::is_regular_file(entry) + && entry.path().extension() == ".json") + { std::string specName = entry.path().filename().replace_extension("").string(); if (specName.find("namespace") != std::string::npos) diff --git a/src/NWBFile.hpp b/src/NWBFile.hpp index 978fa0aa..08969090 100644 --- a/src/NWBFile.hpp +++ b/src/NWBFile.hpp @@ -4,7 +4,7 @@ #include "io/BaseIO.hpp" -namespace AQNWBIO +namespace AQNWB { /** * @brief The NWBFile class provides an interface for setting up and managing @@ -168,4 +168,4 @@ class NWBRecordingEngine */ std::vector smpBuffer; }; -} // namespace AQNWBIO +} // namespace AQNWB diff --git a/src/Types.hpp b/src/Types.hpp index 17e699cc..0a346a7d 100644 --- a/src/Types.hpp +++ b/src/Types.hpp @@ -2,7 +2,7 @@ #include -namespace AQNWBIO +namespace AQNWB { /** * @brief Provides definitions for various types used in the project. @@ -29,4 +29,4 @@ class Types */ using SizeArray = std::vector; }; -} // namespace AQNWBIO +} // namespace AQNWB diff --git a/src/Utils.hpp b/src/Utils.hpp index 065ec026..039596c6 100644 --- a/src/Utils.hpp +++ b/src/Utils.hpp @@ -7,7 +7,7 @@ #include #include -namespace AQNWBIO +namespace AQNWB { /** * @brief Generates a UUID (Universally Unique Identifier) as a string. @@ -40,4 +40,4 @@ inline std::string getCurrentTime() return oss.str(); } -} // namespace AQNWBIO +} // namespace AQNWB diff --git a/src/io/BaseIO.cpp b/src/io/BaseIO.cpp index a8e4af10..f8c114b8 100644 --- a/src/io/BaseIO.cpp +++ b/src/io/BaseIO.cpp @@ -2,7 +2,7 @@ #include "Utils.hpp" -using namespace AQNWBIO; +using namespace AQNWB; // BaseDataType diff --git a/src/io/BaseIO.hpp b/src/io/BaseIO.hpp index c85c3673..cf867d18 100644 --- a/src/io/BaseIO.hpp +++ b/src/io/BaseIO.hpp @@ -10,11 +10,11 @@ #define DEFAULT_STR_SIZE 256 #define DEFAULT_ARRAY_SIZE 1 -using Status = AQNWBIO::Types::Status; -using SizeArray = AQNWBIO::Types::SizeArray; -using SizeType = AQNWBIO::Types::SizeType; +using Status = AQNWB::Types::Status; +using SizeArray = AQNWB::Types::SizeArray; +using SizeType = AQNWB::Types::SizeType; -namespace AQNWBIO +namespace AQNWB { class BaseRecordingData; @@ -372,4 +372,4 @@ class BaseRecordingData std::vector rowXPos; }; -} // namespace AQNWBIO +} // namespace AQNWB diff --git a/src/io/HDF5IO.cpp b/src/io/HDF5IO.cpp index 641b831a..3d098a32 100644 --- a/src/io/HDF5IO.cpp +++ b/src/io/HDF5IO.cpp @@ -11,7 +11,7 @@ #include "Utils.hpp" using namespace H5; -using namespace AQNWBIO; +using namespace AQNWB::HDF5; // HDF5IO @@ -342,7 +342,7 @@ Status HDF5IO::createStringDataSet(const std::string& path, return Status::Success; } -BaseRecordingData* HDF5IO::getDataSet(const std::string& path) +AQNWB::BaseRecordingData* HDF5IO::getDataSet(const std::string& path) { std::unique_ptr data; @@ -364,10 +364,10 @@ BaseRecordingData* HDF5IO::getDataSet(const std::string& path) } } -BaseRecordingData* HDF5IO::createDataSet(const BaseDataType& type, - const SizeArray& size, - const SizeArray& chunking, - const std::string& path) +AQNWB::BaseRecordingData* HDF5IO::createDataSet(const BaseDataType& type, + const SizeArray& size, + const SizeArray& chunking, + const std::string& path) { std::unique_ptr data; DSetCreatPropList prop; diff --git a/src/io/HDF5IO.hpp b/src/io/HDF5IO.hpp index cc0c5d8b..8dbe926d 100644 --- a/src/io/HDF5IO.hpp +++ b/src/io/HDF5IO.hpp @@ -14,7 +14,7 @@ class DataType; class Exception; } // namespace H5 -namespace AQNWBIO +namespace AQNWB::HDF5 { class HDF5RecordingData; // declare here because gets used in HDF5IO class @@ -275,4 +275,4 @@ class HDF5RecordingData : public BaseRecordingData */ Status checkStatus(int status); }; -} // namespace AQNWBIO +} // namespace AQNWB::HDF5 diff --git a/src/hdmf/base/Container.cpp b/src/schema/hdmf/base/Container.cpp similarity index 82% rename from src/hdmf/base/Container.cpp rename to src/schema/hdmf/base/Container.cpp index f687122f..9980ee9a 100644 --- a/src/hdmf/base/Container.cpp +++ b/src/schema/hdmf/base/Container.cpp @@ -1,6 +1,6 @@ -#include "Container.hpp" +#include "schema/hdmf/base/Container.hpp" -using namespace AQNWBIO; +using namespace AQNWB::Schema; // Container diff --git a/src/hdmf/base/Container.hpp b/src/schema/hdmf/base/Container.hpp similarity index 93% rename from src/hdmf/base/Container.hpp rename to src/schema/hdmf/base/Container.hpp index 1441a2a9..c6716f8b 100644 --- a/src/hdmf/base/Container.hpp +++ b/src/schema/hdmf/base/Container.hpp @@ -5,7 +5,7 @@ #include "io/BaseIO.hpp" -namespace AQNWBIO +namespace AQNWB::Schema { /** * @brief Abstract data type for a group storing collections of data and @@ -48,4 +48,4 @@ class Container */ std::shared_ptr io; }; -} // namespace AQNWBIO +} // namespace AQNWB::Schema diff --git a/src/hdmf/base/Data.hpp b/src/schema/hdmf/base/Data.hpp similarity index 85% rename from src/hdmf/base/Data.hpp rename to src/schema/hdmf/base/Data.hpp index 3d2a4817..e5ba635d 100644 --- a/src/hdmf/base/Data.hpp +++ b/src/schema/hdmf/base/Data.hpp @@ -4,7 +4,7 @@ #include "io/BaseIO.hpp" -namespace AQNWBIO +namespace AQNWB::Schema { /** * @brief An abstract data type for a dataset. @@ -27,4 +27,4 @@ class Data */ std::unique_ptr dataset; }; -} // namespace AQNWBIO +} // namespace AQNWB::Schema diff --git a/src/hdmf/table/DynamicTable.cpp b/src/schema/hdmf/table/DynamicTable.cpp similarity index 96% rename from src/hdmf/table/DynamicTable.cpp rename to src/schema/hdmf/table/DynamicTable.cpp index 1259510e..4f896c13 100644 --- a/src/hdmf/table/DynamicTable.cpp +++ b/src/schema/hdmf/table/DynamicTable.cpp @@ -1,6 +1,6 @@ -#include "DynamicTable.hpp" +#include "schema/hdmf/table/DynamicTable.hpp" -using namespace AQNWBIO; +using namespace AQNWB::Schema; // DynamicTable diff --git a/src/hdmf/table/DynamicTable.hpp b/src/schema/hdmf/table/DynamicTable.hpp similarity index 93% rename from src/hdmf/table/DynamicTable.hpp rename to src/schema/hdmf/table/DynamicTable.hpp index f8c759f6..bdbde58a 100644 --- a/src/hdmf/table/DynamicTable.hpp +++ b/src/schema/hdmf/table/DynamicTable.hpp @@ -2,12 +2,12 @@ #include -#include "hdmf/base/Container.hpp" -#include "hdmf/table/ElementIdentifiers.hpp" -#include "hdmf/table/VectorData.hpp" #include "io/BaseIO.hpp" +#include "schema/hdmf/base/Container.hpp" +#include "schema/hdmf/table/ElementIdentifiers.hpp" +#include "schema/hdmf/table/VectorData.hpp" -namespace AQNWBIO +namespace AQNWB::Schema { /** * @brief Represents a group containing multiple datasets that are aligned on @@ -94,4 +94,4 @@ class DynamicTable : public Container */ std::vector colNames; }; -} // namespace AQNWBIO +} // namespace AQNWB::Schema diff --git a/src/hdmf/table/ElementIdentifiers.hpp b/src/schema/hdmf/table/ElementIdentifiers.hpp similarity index 65% rename from src/hdmf/table/ElementIdentifiers.hpp rename to src/schema/hdmf/table/ElementIdentifiers.hpp index fbb0998d..f51b8452 100644 --- a/src/hdmf/table/ElementIdentifiers.hpp +++ b/src/schema/hdmf/table/ElementIdentifiers.hpp @@ -1,8 +1,8 @@ #pragma once -#include "hdmf/base/Data.hpp" +#include "schema/hdmf/base/Data.hpp" -namespace AQNWBIO +namespace AQNWB::Schema { /** * @brief A list of unique identifiers for values within a dataset, e.g. rows of @@ -11,4 +11,4 @@ namespace AQNWBIO class ElementIdentifiers : public Data { }; -} // namespace AQNWBIO +} // namespace AQNWB::Schema diff --git a/src/hdmf/table/VectorData.cpp b/src/schema/hdmf/table/VectorData.cpp similarity index 54% rename from src/hdmf/table/VectorData.cpp rename to src/schema/hdmf/table/VectorData.cpp index 1600cdf5..7b91e002 100644 --- a/src/hdmf/table/VectorData.cpp +++ b/src/schema/hdmf/table/VectorData.cpp @@ -1,6 +1,6 @@ -#include "VectorData.hpp" +#include "schema/hdmf/table/VectorData.hpp" -using namespace AQNWBIO; +using namespace AQNWB::Schema; // VectorData std::string VectorData::getDescription() const diff --git a/src/hdmf/table/VectorData.hpp b/src/schema/hdmf/table/VectorData.hpp similarity index 81% rename from src/hdmf/table/VectorData.hpp rename to src/schema/hdmf/table/VectorData.hpp index 45720806..561e3d8e 100644 --- a/src/hdmf/table/VectorData.hpp +++ b/src/schema/hdmf/table/VectorData.hpp @@ -2,9 +2,9 @@ #include -#include "hdmf/base/Data.hpp" +#include "schema/hdmf/base/Data.hpp" -namespace AQNWBIO +namespace AQNWB::Schema { /** * @brief An n-dimensional dataset representing a column of a DynamicTable. @@ -24,4 +24,4 @@ class VectorData : public Data */ std::string description; }; -} // namespace AQNWBIO +} // namespace AQNWB::Schema diff --git a/src/device/Device.cpp b/src/schema/nwb/device/Device.cpp similarity index 91% rename from src/device/Device.cpp rename to src/schema/nwb/device/Device.cpp index 24f5afeb..1436062e 100644 --- a/src/device/Device.cpp +++ b/src/schema/nwb/device/Device.cpp @@ -1,6 +1,6 @@ -#include "Device.hpp" +#include "schema/nwb/device/Device.hpp" -using namespace AQNWBIO; +using namespace AQNWB::Schema; // Device /** Constructor */ diff --git a/src/device/Device.hpp b/src/schema/nwb/device/Device.hpp similarity index 93% rename from src/device/Device.hpp rename to src/schema/nwb/device/Device.hpp index d8b7f190..d6a20be7 100644 --- a/src/device/Device.hpp +++ b/src/schema/nwb/device/Device.hpp @@ -2,10 +2,10 @@ #include -#include "hdmf/base/Container.hpp" #include "io/BaseIO.hpp" +#include "schema/hdmf/base/Container.hpp" -namespace AQNWBIO +namespace AQNWB::Schema { /** * @brief Metadata about a data acquisition device, e.g., recording system, @@ -60,4 +60,4 @@ class Device : public Container */ std::string manufacturer; }; -} // namespace AQNWBIO +} // namespace AQNWB::Schema diff --git a/src/file/ElectrodeGroup.cpp b/src/schema/nwb/file/ElectrodeGroup.cpp similarity index 93% rename from src/file/ElectrodeGroup.cpp rename to src/schema/nwb/file/ElectrodeGroup.cpp index fa1f6fa0..c095e542 100644 --- a/src/file/ElectrodeGroup.cpp +++ b/src/schema/nwb/file/ElectrodeGroup.cpp @@ -1,6 +1,6 @@ -#include "ElectrodeGroup.hpp" +#include "schema/nwb/file/ElectrodeGroup.hpp" -using namespace AQNWBIO; +using namespace AQNWB::Schema; // ElectrodeGroup diff --git a/src/file/ElectrodeGroup.hpp b/src/schema/nwb/file/ElectrodeGroup.hpp similarity index 93% rename from src/file/ElectrodeGroup.hpp rename to src/schema/nwb/file/ElectrodeGroup.hpp index 60441ad9..0a1cf21f 100644 --- a/src/file/ElectrodeGroup.hpp +++ b/src/schema/nwb/file/ElectrodeGroup.hpp @@ -2,11 +2,11 @@ #include -#include "device/Device.hpp" -#include "hdmf/base/Container.hpp" #include "io/BaseIO.hpp" +#include "schema/hdmf/base/Container.hpp" +#include "schema/nwb/device/Device.hpp" -namespace AQNWBIO +namespace AQNWB::Schema { /** * @brief The ElectrodeGroup class represents a physical grouping of electrodes, @@ -78,4 +78,4 @@ class ElectrodeGroup : public Container */ Device device; }; -} // namespace AQNWBIO +} // namespace AQNWB::Schema diff --git a/src/file/ElectrodeTable.cpp b/src/schema/nwb/file/ElectrodeTable.cpp similarity index 96% rename from src/file/ElectrodeTable.cpp rename to src/schema/nwb/file/ElectrodeTable.cpp index 721573df..3723e522 100644 --- a/src/file/ElectrodeTable.cpp +++ b/src/schema/nwb/file/ElectrodeTable.cpp @@ -1,6 +1,6 @@ -#include "ElectrodeTable.hpp" +#include "schema/nwb/file/ElectrodeTable.hpp" -using namespace AQNWBIO; +using namespace AQNWB::Schema; // ElectrodeTable diff --git a/src/file/ElectrodeTable.hpp b/src/schema/nwb/file/ElectrodeTable.hpp similarity index 93% rename from src/file/ElectrodeTable.hpp rename to src/schema/nwb/file/ElectrodeTable.hpp index 4732b6a5..7fd5d7dc 100644 --- a/src/file/ElectrodeTable.hpp +++ b/src/schema/nwb/file/ElectrodeTable.hpp @@ -2,12 +2,12 @@ #include -#include "hdmf/table/DynamicTable.hpp" -#include "hdmf/table/ElementIdentifiers.hpp" -#include "hdmf/table/VectorData.hpp" #include "io/BaseIO.hpp" +#include "schema/hdmf/table/DynamicTable.hpp" +#include "schema/hdmf/table/ElementIdentifiers.hpp" +#include "schema/hdmf/table/VectorData.hpp" -namespace AQNWBIO +namespace AQNWB::Schema { /** * @brief Represents a table containing electrode metadata. @@ -115,4 +115,4 @@ class ElectrodeTable : public DynamicTable */ std::string groupPath = "/general/extracellular_ephys/array1"; }; -} // namespace AQNWBIO +} // namespace AQNWB::Schema diff --git a/tests/aq-nwb_test.cpp b/tests/aq-nwb_test.cpp index 150e8312..010e0a3a 100644 --- a/tests/aq-nwb_test.cpp +++ b/tests/aq-nwb_test.cpp @@ -4,12 +4,11 @@ #include #include "NWBFile.hpp" -#include "file/ElectrodeTable.hpp" #include "io/BaseIO.hpp" #include "io/HDF5IO.hpp" +#include "schema/nwb/file/ElectrodeTable.hpp" -using namespace AQNWBIO; - +using namespace AQNWB; namespace fs = std::filesystem; std::string getTestFilePath(std::string filename) @@ -34,7 +33,7 @@ TEST_CASE("writeAttributes", "[hdf5io]") { // create and open file std::string filename = getTestFilePath("test_attributes.h5"); - HDF5IO hdf5io(filename); + HDF5::HDF5IO hdf5io(filename); hdf5io.open(); hdf5io.createGroup("/data"); @@ -43,8 +42,7 @@ TEST_CASE("writeAttributes", "[hdf5io]") SECTION("single_value") { const signed int data = 1; - hdf5io.createAttribute( - AQNWBIO::BaseDataType::I32, &data, "/data", "single_value"); + hdf5io.createAttribute(BaseDataType::I32, &data, "/data", "single_value"); } // integer array @@ -54,7 +52,7 @@ TEST_CASE("writeAttributes", "[hdf5io]") const int dataSize = sizeof(data) / sizeof(data[0]); hdf5io.createAttribute( - AQNWBIO::BaseDataType::I32, &data, "/data", "array", dataSize); + BaseDataType::I32, &data, "/data", "array", dataSize); } // string array @@ -80,7 +78,7 @@ TEST_CASE("saveNWBFile", "[nwb]") { std::string filename = getTestFilePath("test_nwb_file.h5"); - NWBFile nwbfile("123", std::make_unique(filename)); + NWBFile nwbfile("123", std::make_unique(filename)); nwbfile.initialize(); nwbfile.finalize(); } @@ -89,7 +87,7 @@ TEST_CASE("startRecording", "[nwb]") { std::string filename = getTestFilePath("test_recording.h5"); - NWBFile nwbfile("123", std::make_unique(filename)); + NWBFile nwbfile("123", std::make_unique(filename)); nwbfile.initialize(); Status result = nwbfile.startRecording(); nwbfile.finalize(); @@ -104,10 +102,10 @@ TEST_CASE("ElectrodeTable", "[datatypes]") { std::string filename = getTestFilePath("electrodeTable.h5"); std::vector channels = {1, 2, 3}; - std::shared_ptr io = std::make_unique(filename); + std::shared_ptr io = std::make_unique(filename); io->open(); io->createGroup("array1"); - ElectrodeTable electrodeTable(path, io, channels); + Schema::ElectrodeTable electrodeTable(path, io, channels); electrodeTable.initialize(); electrodeTable.setGroupPath("array1"); electrodeTable.electrodeDataset->dataset = @@ -126,8 +124,8 @@ TEST_CASE("ElectrodeTable", "[datatypes]") size_t numChannels = 3; BaseRecordingData* id_data = io->getDataSet(path + "id"); int* buffer = new int[numChannels]; - static_cast(id_data)->readDataBlock(BaseDataType::I32, - buffer); + static_cast(id_data)->readDataBlock( + BaseDataType::I32, buffer); std::vector read_channels(buffer, buffer + numChannels); delete[] buffer; REQUIRE(channels == read_channels); @@ -136,9 +134,9 @@ TEST_CASE("ElectrodeTable", "[datatypes]") SECTION("initialize without empty channels") { std::string filename = getTestFilePath("electrodeTableNoData.h5"); - std::shared_ptr io = std::make_unique(filename); + std::shared_ptr io = std::make_unique(filename); io->open(); - ElectrodeTable electrodeTable(path, io, std::vector(), "none"); + Schema::ElectrodeTable electrodeTable(path, io, std::vector(), "none"); electrodeTable.initialize(); } } From dd05ae1ff733053daf1f5a7c6d17307b225bf12f Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:42:32 -0700 Subject: [PATCH 3/7] restructure folders and namespace names --- CMakeLists.txt | 23 +++++++++--------- src/{io => }/BaseIO.cpp | 0 src/{io => }/BaseIO.hpp | 0 src/{io => hdf5}/HDF5IO.cpp | 0 src/{io => hdf5}/HDF5IO.hpp | 0 src/{ => nwb}/NWBFile.cpp | 24 +++++++++---------- src/{ => nwb}/NWBFile.hpp | 2 +- .../nwb => nwb/core}/device/Device.cpp | 4 ++-- .../nwb => nwb/core}/device/Device.hpp | 8 +++---- .../nwb => nwb/core}/file/ElectrodeGroup.cpp | 4 ++-- .../nwb => nwb/core}/file/ElectrodeGroup.hpp | 10 ++++---- .../nwb => nwb/core}/file/ElectrodeTable.cpp | 4 ++-- .../nwb => nwb/core}/file/ElectrodeTable.hpp | 12 +++++----- src/{schema => nwb}/hdmf/base/Container.cpp | 4 ++-- src/{schema => nwb}/hdmf/base/Container.hpp | 6 ++--- src/{schema => nwb}/hdmf/base/Data.hpp | 6 ++--- .../hdmf/table/DynamicTable.cpp | 4 ++-- .../hdmf/table/DynamicTable.hpp | 12 +++++----- .../hdmf/table/ElementIdentifiers.hpp | 6 ++--- src/{schema => nwb}/hdmf/table/VectorData.cpp | 4 ++-- src/{schema => nwb}/hdmf/table/VectorData.hpp | 6 ++--- tests/aq-nwb_test.cpp | 12 +++++----- 22 files changed, 75 insertions(+), 76 deletions(-) rename src/{io => }/BaseIO.cpp (100%) rename src/{io => }/BaseIO.hpp (100%) rename src/{io => hdf5}/HDF5IO.cpp (100%) rename src/{io => hdf5}/HDF5IO.hpp (100%) rename src/{ => nwb}/NWBFile.cpp (89%) rename src/{ => nwb}/NWBFile.hpp (99%) rename src/{schema/nwb => nwb/core}/device/Device.cpp (91%) rename src/{schema/nwb => nwb/core}/device/Device.hpp (91%) rename src/{schema/nwb => nwb/core}/file/ElectrodeGroup.cpp (93%) rename src/{schema/nwb => nwb/core}/file/ElectrodeGroup.hpp (92%) rename src/{schema/nwb => nwb/core}/file/ElectrodeTable.cpp (96%) rename src/{schema/nwb => nwb/core}/file/ElectrodeTable.hpp (93%) rename src/{schema => nwb}/hdmf/base/Container.cpp (82%) rename src/{schema => nwb}/hdmf/base/Container.hpp (91%) rename src/{schema => nwb}/hdmf/base/Data.hpp (79%) rename src/{schema => nwb}/hdmf/table/DynamicTable.cpp (96%) rename src/{schema => nwb}/hdmf/table/DynamicTable.hpp (92%) rename src/{schema => nwb}/hdmf/table/ElementIdentifiers.hpp (65%) rename src/{schema => nwb}/hdmf/table/VectorData.cpp (54%) rename src/{schema => nwb}/hdmf/table/VectorData.hpp (81%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3342f9c3..3493ad1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,18 +16,17 @@ include(cmake/variables.cmake) add_library( aq-nwb_lib OBJECT - src/NWBFile.cpp - src/Utils.hpp - src/io/HDF5IO.cpp - src/io/BaseIO.cpp - src/schema/hdmf/base/Data.hpp - src/schema/hdmf/base/Container.cpp - src/schema/hdmf/table/DynamicTable.cpp - src/schema/hdmf/table/ElementIdentifiers.hpp - src/schema/hdmf/table/VectorData.hpp - src/schema/nwb/device/Device.cpp - src/schema/nwb/file/ElectrodeGroup.cpp - src/schema/nwb/file/ElectrodeTable.cpp + src/BaseIO.cpp + src/hdf5/HDF5IO.cpp + src/nwb/NWBFile.cpp + src/nwb/hdmf/base/Data.hpp + src/nwb/hdmf/base/Container.cpp + src/nwb/hdmf/table/DynamicTable.cpp + src/nwb/hdmf/table/ElementIdentifiers.hpp + src/nwb/hdmf/table/VectorData.hpp + src/nwb/core/device/Device.cpp + src/nwb/core/file/ElectrodeGroup.cpp + src/nwb/core/file/ElectrodeTable.cpp ) target_include_directories( diff --git a/src/io/BaseIO.cpp b/src/BaseIO.cpp similarity index 100% rename from src/io/BaseIO.cpp rename to src/BaseIO.cpp diff --git a/src/io/BaseIO.hpp b/src/BaseIO.hpp similarity index 100% rename from src/io/BaseIO.hpp rename to src/BaseIO.hpp diff --git a/src/io/HDF5IO.cpp b/src/hdf5/HDF5IO.cpp similarity index 100% rename from src/io/HDF5IO.cpp rename to src/hdf5/HDF5IO.cpp diff --git a/src/io/HDF5IO.hpp b/src/hdf5/HDF5IO.hpp similarity index 100% rename from src/io/HDF5IO.hpp rename to src/hdf5/HDF5IO.hpp diff --git a/src/NWBFile.cpp b/src/nwb/NWBFile.cpp similarity index 89% rename from src/NWBFile.cpp rename to src/nwb/NWBFile.cpp index 69a5e123..7ac27701 100644 --- a/src/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -8,11 +8,11 @@ #include "NWBFile.hpp" +#include "BaseIO.hpp" #include "Utils.hpp" -#include "io/BaseIO.hpp" -#include "schema/nwb/device/Device.hpp" -#include "schema/nwb/file/ElectrodeGroup.hpp" -#include "schema/nwb/file/ElectrodeTable.hpp" +#include "nwb/core/device/Device.hpp" +#include "nwb/core/file/ElectrodeGroup.hpp" +#include "nwb/core/file/ElectrodeTable.hpp" using namespace AQNWB; @@ -97,19 +97,18 @@ Status NWBFile::startRecording() std::string devicePath = "general/devices/" + groupName; std::string elecPath = "general/extracellular_ephys/" + groupName; - Schema::Device device = - Schema::Device(devicePath, io, "description", "unknown"); + NWB::Device device = NWB::Device(devicePath, io, "description", "unknown"); device.initialize(); - Schema::ElectrodeGroup elecGroup = - Schema::ElectrodeGroup(elecPath, io, "description", "unknown", device); + NWB::ElectrodeGroup elecGroup = + NWB::ElectrodeGroup(elecPath, io, "description", "unknown", device); elecGroup.initialize(); } // Create electrode table std::string electrodePath = "general/extracellular_ephys/electrodes/"; - Schema::ElectrodeTable elecTable = - Schema::ElectrodeTable(electrodePath, io, channels); + NWB::ElectrodeTable elecTable = + NWB::ElectrodeTable(electrodePath, io, channels); elecTable.initialize(); elecTable.electrodeDataset->dataset = createRecordingData( @@ -139,8 +138,9 @@ void NWBFile::cacheSpecifications(const std::string& specPath, io->createGroup("/specifications/" + specPath + versionNumber); std::filesystem::path currentFile = __FILE__; - std::filesystem::path schemaDir = currentFile.parent_path().parent_path() - / "resources/spec" / specPath / versionNumber; + std::filesystem::path schemaDir = + currentFile.parent_path().parent_path().parent_path() / "resources/spec" + / specPath / versionNumber; for (auto const& entry : std::filesystem::directory_iterator {schemaDir}) if (std::filesystem::is_regular_file(entry) diff --git a/src/NWBFile.hpp b/src/nwb/NWBFile.hpp similarity index 99% rename from src/NWBFile.hpp rename to src/nwb/NWBFile.hpp index 08969090..9a10786d 100644 --- a/src/NWBFile.hpp +++ b/src/nwb/NWBFile.hpp @@ -2,7 +2,7 @@ #include -#include "io/BaseIO.hpp" +#include "BaseIO.hpp" namespace AQNWB { diff --git a/src/schema/nwb/device/Device.cpp b/src/nwb/core/device/Device.cpp similarity index 91% rename from src/schema/nwb/device/Device.cpp rename to src/nwb/core/device/Device.cpp index 1436062e..0676c53a 100644 --- a/src/schema/nwb/device/Device.cpp +++ b/src/nwb/core/device/Device.cpp @@ -1,6 +1,6 @@ -#include "schema/nwb/device/Device.hpp" +#include "nwb/core/device/Device.hpp" -using namespace AQNWB::Schema; +using namespace AQNWB::NWB; // Device /** Constructor */ diff --git a/src/schema/nwb/device/Device.hpp b/src/nwb/core/device/Device.hpp similarity index 91% rename from src/schema/nwb/device/Device.hpp rename to src/nwb/core/device/Device.hpp index d6a20be7..74ae7062 100644 --- a/src/schema/nwb/device/Device.hpp +++ b/src/nwb/core/device/Device.hpp @@ -2,10 +2,10 @@ #include -#include "io/BaseIO.hpp" -#include "schema/hdmf/base/Container.hpp" +#include "BaseIO.hpp" +#include "nwb/hdmf/base/Container.hpp" -namespace AQNWB::Schema +namespace AQNWB::NWB { /** * @brief Metadata about a data acquisition device, e.g., recording system, @@ -60,4 +60,4 @@ class Device : public Container */ std::string manufacturer; }; -} // namespace AQNWB::Schema +} // namespace AQNWB::NWB diff --git a/src/schema/nwb/file/ElectrodeGroup.cpp b/src/nwb/core/file/ElectrodeGroup.cpp similarity index 93% rename from src/schema/nwb/file/ElectrodeGroup.cpp rename to src/nwb/core/file/ElectrodeGroup.cpp index c095e542..8b984ba4 100644 --- a/src/schema/nwb/file/ElectrodeGroup.cpp +++ b/src/nwb/core/file/ElectrodeGroup.cpp @@ -1,6 +1,6 @@ -#include "schema/nwb/file/ElectrodeGroup.hpp" +#include "nwb/core/file/ElectrodeGroup.hpp" -using namespace AQNWB::Schema; +using namespace AQNWB::NWB; // ElectrodeGroup diff --git a/src/schema/nwb/file/ElectrodeGroup.hpp b/src/nwb/core/file/ElectrodeGroup.hpp similarity index 92% rename from src/schema/nwb/file/ElectrodeGroup.hpp rename to src/nwb/core/file/ElectrodeGroup.hpp index 0a1cf21f..58a56d76 100644 --- a/src/schema/nwb/file/ElectrodeGroup.hpp +++ b/src/nwb/core/file/ElectrodeGroup.hpp @@ -2,11 +2,11 @@ #include -#include "io/BaseIO.hpp" -#include "schema/hdmf/base/Container.hpp" -#include "schema/nwb/device/Device.hpp" +#include "BaseIO.hpp" +#include "nwb/core/device/Device.hpp" +#include "nwb/hdmf/base/Container.hpp" -namespace AQNWB::Schema +namespace AQNWB::NWB { /** * @brief The ElectrodeGroup class represents a physical grouping of electrodes, @@ -78,4 +78,4 @@ class ElectrodeGroup : public Container */ Device device; }; -} // namespace AQNWB::Schema +} // namespace AQNWB::NWB diff --git a/src/schema/nwb/file/ElectrodeTable.cpp b/src/nwb/core/file/ElectrodeTable.cpp similarity index 96% rename from src/schema/nwb/file/ElectrodeTable.cpp rename to src/nwb/core/file/ElectrodeTable.cpp index 3723e522..dfa2e67c 100644 --- a/src/schema/nwb/file/ElectrodeTable.cpp +++ b/src/nwb/core/file/ElectrodeTable.cpp @@ -1,6 +1,6 @@ -#include "schema/nwb/file/ElectrodeTable.hpp" +#include "nwb/core/file/ElectrodeTable.hpp" -using namespace AQNWB::Schema; +using namespace AQNWB::NWB; // ElectrodeTable diff --git a/src/schema/nwb/file/ElectrodeTable.hpp b/src/nwb/core/file/ElectrodeTable.hpp similarity index 93% rename from src/schema/nwb/file/ElectrodeTable.hpp rename to src/nwb/core/file/ElectrodeTable.hpp index 7fd5d7dc..40abdbbb 100644 --- a/src/schema/nwb/file/ElectrodeTable.hpp +++ b/src/nwb/core/file/ElectrodeTable.hpp @@ -2,12 +2,12 @@ #include -#include "io/BaseIO.hpp" -#include "schema/hdmf/table/DynamicTable.hpp" -#include "schema/hdmf/table/ElementIdentifiers.hpp" -#include "schema/hdmf/table/VectorData.hpp" +#include "BaseIO.hpp" +#include "nwb/hdmf/table/DynamicTable.hpp" +#include "nwb/hdmf/table/ElementIdentifiers.hpp" +#include "nwb/hdmf/table/VectorData.hpp" -namespace AQNWB::Schema +namespace AQNWB::NWB { /** * @brief Represents a table containing electrode metadata. @@ -115,4 +115,4 @@ class ElectrodeTable : public DynamicTable */ std::string groupPath = "/general/extracellular_ephys/array1"; }; -} // namespace AQNWB::Schema +} // namespace AQNWB::NWB diff --git a/src/schema/hdmf/base/Container.cpp b/src/nwb/hdmf/base/Container.cpp similarity index 82% rename from src/schema/hdmf/base/Container.cpp rename to src/nwb/hdmf/base/Container.cpp index 9980ee9a..525d82ed 100644 --- a/src/schema/hdmf/base/Container.cpp +++ b/src/nwb/hdmf/base/Container.cpp @@ -1,6 +1,6 @@ -#include "schema/hdmf/base/Container.hpp" +#include "nwb/hdmf/base/Container.hpp" -using namespace AQNWB::Schema; +using namespace AQNWB::NWB; // Container diff --git a/src/schema/hdmf/base/Container.hpp b/src/nwb/hdmf/base/Container.hpp similarity index 91% rename from src/schema/hdmf/base/Container.hpp rename to src/nwb/hdmf/base/Container.hpp index c6716f8b..1d89c875 100644 --- a/src/schema/hdmf/base/Container.hpp +++ b/src/nwb/hdmf/base/Container.hpp @@ -3,9 +3,9 @@ #include #include -#include "io/BaseIO.hpp" +#include "BaseIO.hpp" -namespace AQNWB::Schema +namespace AQNWB::NWB { /** * @brief Abstract data type for a group storing collections of data and @@ -48,4 +48,4 @@ class Container */ std::shared_ptr io; }; -} // namespace AQNWB::Schema +} // namespace AQNWB::NWB diff --git a/src/schema/hdmf/base/Data.hpp b/src/nwb/hdmf/base/Data.hpp similarity index 79% rename from src/schema/hdmf/base/Data.hpp rename to src/nwb/hdmf/base/Data.hpp index e5ba635d..ef146485 100644 --- a/src/schema/hdmf/base/Data.hpp +++ b/src/nwb/hdmf/base/Data.hpp @@ -2,9 +2,9 @@ #include -#include "io/BaseIO.hpp" +#include "BaseIO.hpp" -namespace AQNWB::Schema +namespace AQNWB::NWB { /** * @brief An abstract data type for a dataset. @@ -27,4 +27,4 @@ class Data */ std::unique_ptr dataset; }; -} // namespace AQNWB::Schema +} // namespace AQNWB::NWB diff --git a/src/schema/hdmf/table/DynamicTable.cpp b/src/nwb/hdmf/table/DynamicTable.cpp similarity index 96% rename from src/schema/hdmf/table/DynamicTable.cpp rename to src/nwb/hdmf/table/DynamicTable.cpp index 4f896c13..82871fdc 100644 --- a/src/schema/hdmf/table/DynamicTable.cpp +++ b/src/nwb/hdmf/table/DynamicTable.cpp @@ -1,6 +1,6 @@ -#include "schema/hdmf/table/DynamicTable.hpp" +#include "nwb/hdmf/table/DynamicTable.hpp" -using namespace AQNWB::Schema; +using namespace AQNWB::NWB; // DynamicTable diff --git a/src/schema/hdmf/table/DynamicTable.hpp b/src/nwb/hdmf/table/DynamicTable.hpp similarity index 92% rename from src/schema/hdmf/table/DynamicTable.hpp rename to src/nwb/hdmf/table/DynamicTable.hpp index bdbde58a..0e9f6cf7 100644 --- a/src/schema/hdmf/table/DynamicTable.hpp +++ b/src/nwb/hdmf/table/DynamicTable.hpp @@ -2,12 +2,12 @@ #include -#include "io/BaseIO.hpp" -#include "schema/hdmf/base/Container.hpp" -#include "schema/hdmf/table/ElementIdentifiers.hpp" -#include "schema/hdmf/table/VectorData.hpp" +#include "BaseIO.hpp" +#include "nwb/hdmf/base/Container.hpp" +#include "nwb/hdmf/table/ElementIdentifiers.hpp" +#include "nwb/hdmf/table/VectorData.hpp" -namespace AQNWB::Schema +namespace AQNWB::NWB { /** * @brief Represents a group containing multiple datasets that are aligned on @@ -94,4 +94,4 @@ class DynamicTable : public Container */ std::vector colNames; }; -} // namespace AQNWB::Schema +} // namespace AQNWB::NWB diff --git a/src/schema/hdmf/table/ElementIdentifiers.hpp b/src/nwb/hdmf/table/ElementIdentifiers.hpp similarity index 65% rename from src/schema/hdmf/table/ElementIdentifiers.hpp rename to src/nwb/hdmf/table/ElementIdentifiers.hpp index f51b8452..813f472e 100644 --- a/src/schema/hdmf/table/ElementIdentifiers.hpp +++ b/src/nwb/hdmf/table/ElementIdentifiers.hpp @@ -1,8 +1,8 @@ #pragma once -#include "schema/hdmf/base/Data.hpp" +#include "nwb/hdmf/base/Data.hpp" -namespace AQNWB::Schema +namespace AQNWB::NWB { /** * @brief A list of unique identifiers for values within a dataset, e.g. rows of @@ -11,4 +11,4 @@ namespace AQNWB::Schema class ElementIdentifiers : public Data { }; -} // namespace AQNWB::Schema +} // namespace AQNWB::NWB diff --git a/src/schema/hdmf/table/VectorData.cpp b/src/nwb/hdmf/table/VectorData.cpp similarity index 54% rename from src/schema/hdmf/table/VectorData.cpp rename to src/nwb/hdmf/table/VectorData.cpp index 7b91e002..1438387e 100644 --- a/src/schema/hdmf/table/VectorData.cpp +++ b/src/nwb/hdmf/table/VectorData.cpp @@ -1,6 +1,6 @@ -#include "schema/hdmf/table/VectorData.hpp" +#include "nwb/hdmf/table/VectorData.hpp" -using namespace AQNWB::Schema; +using namespace AQNWB::NWB; // VectorData std::string VectorData::getDescription() const diff --git a/src/schema/hdmf/table/VectorData.hpp b/src/nwb/hdmf/table/VectorData.hpp similarity index 81% rename from src/schema/hdmf/table/VectorData.hpp rename to src/nwb/hdmf/table/VectorData.hpp index 561e3d8e..7ee93f09 100644 --- a/src/schema/hdmf/table/VectorData.hpp +++ b/src/nwb/hdmf/table/VectorData.hpp @@ -2,9 +2,9 @@ #include -#include "schema/hdmf/base/Data.hpp" +#include "nwb/hdmf/base/Data.hpp" -namespace AQNWB::Schema +namespace AQNWB::NWB { /** * @brief An n-dimensional dataset representing a column of a DynamicTable. @@ -24,4 +24,4 @@ class VectorData : public Data */ std::string description; }; -} // namespace AQNWB::Schema +} // namespace AQNWB::NWB diff --git a/tests/aq-nwb_test.cpp b/tests/aq-nwb_test.cpp index 010e0a3a..5676ccc9 100644 --- a/tests/aq-nwb_test.cpp +++ b/tests/aq-nwb_test.cpp @@ -3,10 +3,10 @@ #include -#include "NWBFile.hpp" -#include "io/BaseIO.hpp" -#include "io/HDF5IO.hpp" -#include "schema/nwb/file/ElectrodeTable.hpp" +#include "BaseIO.hpp" +#include "hdf5/HDF5IO.hpp" +#include "nwb/NWBFile.hpp" +#include "nwb/core/file/ElectrodeTable.hpp" using namespace AQNWB; namespace fs = std::filesystem; @@ -105,7 +105,7 @@ TEST_CASE("ElectrodeTable", "[datatypes]") std::shared_ptr io = std::make_unique(filename); io->open(); io->createGroup("array1"); - Schema::ElectrodeTable electrodeTable(path, io, channels); + NWB::ElectrodeTable electrodeTable(path, io, channels); electrodeTable.initialize(); electrodeTable.setGroupPath("array1"); electrodeTable.electrodeDataset->dataset = @@ -136,7 +136,7 @@ TEST_CASE("ElectrodeTable", "[datatypes]") std::string filename = getTestFilePath("electrodeTableNoData.h5"); std::shared_ptr io = std::make_unique(filename); io->open(); - Schema::ElectrodeTable electrodeTable(path, io, std::vector(), "none"); + NWB::ElectrodeTable electrodeTable(path, io, std::vector(), "none"); electrodeTable.initialize(); } } From 3d932c50ab6c1762dcde2a0f354c223554cb9700 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:22:56 -0700 Subject: [PATCH 4/7] remove core subfolder --- CMakeLists.txt | 7 ++++--- src/hdf5/HDF5IO.hpp | 15 +++++++++------ src/nwb/NWBFile.cpp | 10 +++++----- src/nwb/NWBFile.hpp | 3 +++ src/nwb/{core => }/device/Device.cpp | 2 +- src/nwb/{core => }/device/Device.hpp | 7 +++++-- src/nwb/{core => }/file/ElectrodeGroup.cpp | 2 +- src/nwb/{core => }/file/ElectrodeGroup.hpp | 9 ++++++--- src/nwb/{core => }/file/ElectrodeTable.cpp | 2 +- src/nwb/{core => }/file/ElectrodeTable.hpp | 7 +++++-- src/nwb/hdmf/base/Container.hpp | 7 +++++-- src/nwb/hdmf/base/Data.hpp | 7 +++++-- src/nwb/hdmf/table/DynamicTable.hpp | 7 +++++-- src/nwb/hdmf/table/ElementIdentifiers.hpp | 7 +++++-- src/nwb/hdmf/table/VectorData.hpp | 7 +++++-- tests/aq-nwb_test.cpp | 6 +++--- 16 files changed, 68 insertions(+), 37 deletions(-) rename src/nwb/{core => }/device/Device.cpp (95%) rename src/nwb/{core => }/device/Device.hpp (94%) rename src/nwb/{core => }/file/ElectrodeGroup.cpp (96%) rename src/nwb/{core => }/file/ElectrodeGroup.hpp (94%) rename src/nwb/{core => }/file/ElectrodeTable.cpp (97%) rename src/nwb/{core => }/file/ElectrodeTable.hpp (97%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3493ad1d..c29870f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,14 +19,15 @@ add_library( src/BaseIO.cpp src/hdf5/HDF5IO.cpp src/nwb/NWBFile.cpp + src/nwb/device/Device.cpp + src/nwb/file/ElectrodeGroup.cpp + src/nwb/file/ElectrodeTable.cpp src/nwb/hdmf/base/Data.hpp src/nwb/hdmf/base/Container.cpp src/nwb/hdmf/table/DynamicTable.cpp src/nwb/hdmf/table/ElementIdentifiers.hpp src/nwb/hdmf/table/VectorData.hpp - src/nwb/core/device/Device.cpp - src/nwb/core/file/ElectrodeGroup.cpp - src/nwb/core/file/ElectrodeTable.cpp + ) target_include_directories( diff --git a/src/hdf5/HDF5IO.hpp b/src/hdf5/HDF5IO.hpp index 8dbe926d..94c42ebe 100644 --- a/src/hdf5/HDF5IO.hpp +++ b/src/hdf5/HDF5IO.hpp @@ -14,7 +14,9 @@ class DataType; class Exception; } // namespace H5 -namespace AQNWB::HDF5 +namespace AQNWB +{ +namespace HDF5 { class HDF5RecordingData; // declare here because gets used in HDF5IO class @@ -216,10 +218,10 @@ class HDF5IO : public BaseIO /** * @brief Represents an HDF5 Dataset that can be extended indefinitely in blocks. - * - * This class provides functionality for reading and writing 2D blocks of data - * (samples x channels) to an HDF5 dataset. - */ +* +* This class provides functionality for reading and writing 2D blocks of data +* (samples x channels) to an HDF5 dataset. +*/ class HDF5RecordingData : public BaseRecordingData { public: @@ -275,4 +277,5 @@ class HDF5RecordingData : public BaseRecordingData */ Status checkStatus(int status); }; -} // namespace AQNWB::HDF5 +} // namespace HDF5 +} // namespace AQNWB diff --git a/src/nwb/NWBFile.cpp b/src/nwb/NWBFile.cpp index 7ac27701..337abb25 100644 --- a/src/nwb/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -10,11 +10,11 @@ #include "BaseIO.hpp" #include "Utils.hpp" -#include "nwb/core/device/Device.hpp" -#include "nwb/core/file/ElectrodeGroup.hpp" -#include "nwb/core/file/ElectrodeTable.hpp" +#include "nwb/device/Device.hpp" +#include "nwb/file/ElectrodeGroup.hpp" +#include "nwb/file/ElectrodeTable.hpp" -using namespace AQNWB; +using namespace AQNWB::NWB; // NWBFile @@ -162,7 +162,7 @@ void NWBFile::cacheSpecifications(const std::string& specPath, } // recording data factory method / -std::unique_ptr NWBFile::createRecordingData( +std::unique_ptr NWBFile::createRecordingData( BaseDataType type, const SizeArray& size, const SizeArray& chunking, diff --git a/src/nwb/NWBFile.hpp b/src/nwb/NWBFile.hpp index 9a10786d..1bf7bf34 100644 --- a/src/nwb/NWBFile.hpp +++ b/src/nwb/NWBFile.hpp @@ -6,6 +6,8 @@ namespace AQNWB { +namespace NWB +{ /** * @brief The NWBFile class provides an interface for setting up and managing * the NWB file. @@ -168,4 +170,5 @@ class NWBRecordingEngine */ std::vector smpBuffer; }; +} // namespace NWB } // namespace AQNWB diff --git a/src/nwb/core/device/Device.cpp b/src/nwb/device/Device.cpp similarity index 95% rename from src/nwb/core/device/Device.cpp rename to src/nwb/device/Device.cpp index 0676c53a..262d9207 100644 --- a/src/nwb/core/device/Device.cpp +++ b/src/nwb/device/Device.cpp @@ -1,4 +1,4 @@ -#include "nwb/core/device/Device.hpp" +#include "nwb/device/Device.hpp" using namespace AQNWB::NWB; diff --git a/src/nwb/core/device/Device.hpp b/src/nwb/device/Device.hpp similarity index 94% rename from src/nwb/core/device/Device.hpp rename to src/nwb/device/Device.hpp index 74ae7062..e8c230ee 100644 --- a/src/nwb/core/device/Device.hpp +++ b/src/nwb/device/Device.hpp @@ -5,7 +5,9 @@ #include "BaseIO.hpp" #include "nwb/hdmf/base/Container.hpp" -namespace AQNWB::NWB +namespace AQNWB +{ +namespace NWB { /** * @brief Metadata about a data acquisition device, e.g., recording system, @@ -60,4 +62,5 @@ class Device : public Container */ std::string manufacturer; }; -} // namespace AQNWB::NWB +} // namespace NWB +} // namespace AQNWB diff --git a/src/nwb/core/file/ElectrodeGroup.cpp b/src/nwb/file/ElectrodeGroup.cpp similarity index 96% rename from src/nwb/core/file/ElectrodeGroup.cpp rename to src/nwb/file/ElectrodeGroup.cpp index 8b984ba4..b5beaa03 100644 --- a/src/nwb/core/file/ElectrodeGroup.cpp +++ b/src/nwb/file/ElectrodeGroup.cpp @@ -1,4 +1,4 @@ -#include "nwb/core/file/ElectrodeGroup.hpp" +#include "nwb/file/ElectrodeGroup.hpp" using namespace AQNWB::NWB; diff --git a/src/nwb/core/file/ElectrodeGroup.hpp b/src/nwb/file/ElectrodeGroup.hpp similarity index 94% rename from src/nwb/core/file/ElectrodeGroup.hpp rename to src/nwb/file/ElectrodeGroup.hpp index 58a56d76..210f6724 100644 --- a/src/nwb/core/file/ElectrodeGroup.hpp +++ b/src/nwb/file/ElectrodeGroup.hpp @@ -3,10 +3,12 @@ #include #include "BaseIO.hpp" -#include "nwb/core/device/Device.hpp" +#include "nwb/device/Device.hpp" #include "nwb/hdmf/base/Container.hpp" -namespace AQNWB::NWB +namespace AQNWB +{ +namespace NWB { /** * @brief The ElectrodeGroup class represents a physical grouping of electrodes, @@ -78,4 +80,5 @@ class ElectrodeGroup : public Container */ Device device; }; -} // namespace AQNWB::NWB +} // namespace NWB +} // namespace AQNWB diff --git a/src/nwb/core/file/ElectrodeTable.cpp b/src/nwb/file/ElectrodeTable.cpp similarity index 97% rename from src/nwb/core/file/ElectrodeTable.cpp rename to src/nwb/file/ElectrodeTable.cpp index dfa2e67c..b113a508 100644 --- a/src/nwb/core/file/ElectrodeTable.cpp +++ b/src/nwb/file/ElectrodeTable.cpp @@ -1,4 +1,4 @@ -#include "nwb/core/file/ElectrodeTable.hpp" +#include "nwb/file/ElectrodeTable.hpp" using namespace AQNWB::NWB; diff --git a/src/nwb/core/file/ElectrodeTable.hpp b/src/nwb/file/ElectrodeTable.hpp similarity index 97% rename from src/nwb/core/file/ElectrodeTable.hpp rename to src/nwb/file/ElectrodeTable.hpp index 40abdbbb..39c2716d 100644 --- a/src/nwb/core/file/ElectrodeTable.hpp +++ b/src/nwb/file/ElectrodeTable.hpp @@ -7,7 +7,9 @@ #include "nwb/hdmf/table/ElementIdentifiers.hpp" #include "nwb/hdmf/table/VectorData.hpp" -namespace AQNWB::NWB +namespace AQNWB +{ +namespace NWB { /** * @brief Represents a table containing electrode metadata. @@ -115,4 +117,5 @@ class ElectrodeTable : public DynamicTable */ std::string groupPath = "/general/extracellular_ephys/array1"; }; -} // namespace AQNWB::NWB +} // namespace NWB +} // namespace AQNWB diff --git a/src/nwb/hdmf/base/Container.hpp b/src/nwb/hdmf/base/Container.hpp index 1d89c875..e35b7dbf 100644 --- a/src/nwb/hdmf/base/Container.hpp +++ b/src/nwb/hdmf/base/Container.hpp @@ -5,7 +5,9 @@ #include "BaseIO.hpp" -namespace AQNWB::NWB +namespace AQNWB +{ +namespace NWB { /** * @brief Abstract data type for a group storing collections of data and @@ -48,4 +50,5 @@ class Container */ std::shared_ptr io; }; -} // namespace AQNWB::NWB +} // namespace NWB +} // namespace AQNWB diff --git a/src/nwb/hdmf/base/Data.hpp b/src/nwb/hdmf/base/Data.hpp index ef146485..32bdb0ca 100644 --- a/src/nwb/hdmf/base/Data.hpp +++ b/src/nwb/hdmf/base/Data.hpp @@ -4,7 +4,9 @@ #include "BaseIO.hpp" -namespace AQNWB::NWB +namespace AQNWB +{ +namespace NWB { /** * @brief An abstract data type for a dataset. @@ -27,4 +29,5 @@ class Data */ std::unique_ptr dataset; }; -} // namespace AQNWB::NWB +} // namespace NWB +} // namespace AQNWB diff --git a/src/nwb/hdmf/table/DynamicTable.hpp b/src/nwb/hdmf/table/DynamicTable.hpp index 0e9f6cf7..af1ae34f 100644 --- a/src/nwb/hdmf/table/DynamicTable.hpp +++ b/src/nwb/hdmf/table/DynamicTable.hpp @@ -7,7 +7,9 @@ #include "nwb/hdmf/table/ElementIdentifiers.hpp" #include "nwb/hdmf/table/VectorData.hpp" -namespace AQNWB::NWB +namespace AQNWB +{ +namespace NWB { /** * @brief Represents a group containing multiple datasets that are aligned on @@ -94,4 +96,5 @@ class DynamicTable : public Container */ std::vector colNames; }; -} // namespace AQNWB::NWB +} // namespace NWB +} // namespace AQNWB \ No newline at end of file diff --git a/src/nwb/hdmf/table/ElementIdentifiers.hpp b/src/nwb/hdmf/table/ElementIdentifiers.hpp index 813f472e..0af32db3 100644 --- a/src/nwb/hdmf/table/ElementIdentifiers.hpp +++ b/src/nwb/hdmf/table/ElementIdentifiers.hpp @@ -2,7 +2,9 @@ #include "nwb/hdmf/base/Data.hpp" -namespace AQNWB::NWB +namespace AQNWB +{ +namespace NWB { /** * @brief A list of unique identifiers for values within a dataset, e.g. rows of @@ -11,4 +13,5 @@ namespace AQNWB::NWB class ElementIdentifiers : public Data { }; -} // namespace AQNWB::NWB +} // namespace NWB +} // namespace AQNWB diff --git a/src/nwb/hdmf/table/VectorData.hpp b/src/nwb/hdmf/table/VectorData.hpp index 7ee93f09..0e574c81 100644 --- a/src/nwb/hdmf/table/VectorData.hpp +++ b/src/nwb/hdmf/table/VectorData.hpp @@ -4,7 +4,9 @@ #include "nwb/hdmf/base/Data.hpp" -namespace AQNWB::NWB +namespace AQNWB +{ +namespace NWB { /** * @brief An n-dimensional dataset representing a column of a DynamicTable. @@ -24,4 +26,5 @@ class VectorData : public Data */ std::string description; }; -} // namespace AQNWB::NWB +} // namespace NWB +} // namespace AQNWB diff --git a/tests/aq-nwb_test.cpp b/tests/aq-nwb_test.cpp index 5676ccc9..fb2268a5 100644 --- a/tests/aq-nwb_test.cpp +++ b/tests/aq-nwb_test.cpp @@ -6,7 +6,7 @@ #include "BaseIO.hpp" #include "hdf5/HDF5IO.hpp" #include "nwb/NWBFile.hpp" -#include "nwb/core/file/ElectrodeTable.hpp" +#include "nwb/file/ElectrodeTable.hpp" using namespace AQNWB; namespace fs = std::filesystem; @@ -78,7 +78,7 @@ TEST_CASE("saveNWBFile", "[nwb]") { std::string filename = getTestFilePath("test_nwb_file.h5"); - NWBFile nwbfile("123", std::make_unique(filename)); + NWB::NWBFile nwbfile("123", std::make_unique(filename)); nwbfile.initialize(); nwbfile.finalize(); } @@ -87,7 +87,7 @@ TEST_CASE("startRecording", "[nwb]") { std::string filename = getTestFilePath("test_recording.h5"); - NWBFile nwbfile("123", std::make_unique(filename)); + NWB::NWBFile nwbfile("123", std::make_unique(filename)); nwbfile.initialize(); Status result = nwbfile.startRecording(); nwbfile.finalize(); From 6d053b7d48454cf3c6d47ba371e2869701cdf3e4 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:26:49 -0700 Subject: [PATCH 5/7] update NWBFile.cpp to use NWB sub namespace --- src/nwb/NWBFile.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/nwb/NWBFile.cpp b/src/nwb/NWBFile.cpp index 337abb25..3da373bd 100644 --- a/src/nwb/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -97,18 +97,17 @@ Status NWBFile::startRecording() std::string devicePath = "general/devices/" + groupName; std::string elecPath = "general/extracellular_ephys/" + groupName; - NWB::Device device = NWB::Device(devicePath, io, "description", "unknown"); + Device device = Device(devicePath, io, "description", "unknown"); device.initialize(); - NWB::ElectrodeGroup elecGroup = - NWB::ElectrodeGroup(elecPath, io, "description", "unknown", device); + ElectrodeGroup elecGroup = + ElectrodeGroup(elecPath, io, "description", "unknown", device); elecGroup.initialize(); } // Create electrode table std::string electrodePath = "general/extracellular_ephys/electrodes/"; - NWB::ElectrodeTable elecTable = - NWB::ElectrodeTable(electrodePath, io, channels); + ElectrodeTable elecTable = ElectrodeTable(electrodePath, io, channels); elecTable.initialize(); elecTable.electrodeDataset->dataset = createRecordingData( From f59b94cbcdf6660c1e9e536e29a97ba51f3929aa Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:29:50 -0700 Subject: [PATCH 6/7] fix file line ending --- src/nwb/hdmf/table/DynamicTable.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nwb/hdmf/table/DynamicTable.hpp b/src/nwb/hdmf/table/DynamicTable.hpp index af1ae34f..07f804b2 100644 --- a/src/nwb/hdmf/table/DynamicTable.hpp +++ b/src/nwb/hdmf/table/DynamicTable.hpp @@ -97,4 +97,4 @@ class DynamicTable : public Container std::vector colNames; }; } // namespace NWB -} // namespace AQNWB \ No newline at end of file +} // namespace AQNWB From 9152fdb6e7209ce78749f5c295133d1aa6ee6223 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:04:19 -0700 Subject: [PATCH 7/7] update namespace definitions --- src/hdf5/HDF5IO.hpp | 7 ++----- src/nwb/NWBFile.hpp | 7 ++----- src/nwb/device/Device.hpp | 7 ++----- src/nwb/file/ElectrodeGroup.hpp | 7 ++----- src/nwb/file/ElectrodeTable.hpp | 7 ++----- src/nwb/hdmf/base/Container.hpp | 7 ++----- src/nwb/hdmf/base/Data.hpp | 7 ++----- src/nwb/hdmf/table/DynamicTable.hpp | 7 ++----- src/nwb/hdmf/table/ElementIdentifiers.hpp | 7 ++----- src/nwb/hdmf/table/VectorData.hpp | 7 ++----- 10 files changed, 20 insertions(+), 50 deletions(-) diff --git a/src/hdf5/HDF5IO.hpp b/src/hdf5/HDF5IO.hpp index 94c42ebe..06295260 100644 --- a/src/hdf5/HDF5IO.hpp +++ b/src/hdf5/HDF5IO.hpp @@ -14,9 +14,7 @@ class DataType; class Exception; } // namespace H5 -namespace AQNWB -{ -namespace HDF5 +namespace AQNWB::HDF5 { class HDF5RecordingData; // declare here because gets used in HDF5IO class @@ -277,5 +275,4 @@ class HDF5RecordingData : public BaseRecordingData */ Status checkStatus(int status); }; -} // namespace HDF5 -} // namespace AQNWB +} // namespace AQNWB::HDF5 diff --git a/src/nwb/NWBFile.hpp b/src/nwb/NWBFile.hpp index 1bf7bf34..cba9e50a 100644 --- a/src/nwb/NWBFile.hpp +++ b/src/nwb/NWBFile.hpp @@ -4,9 +4,7 @@ #include "BaseIO.hpp" -namespace AQNWB -{ -namespace NWB +namespace AQNWB::NWB { /** * @brief The NWBFile class provides an interface for setting up and managing @@ -170,5 +168,4 @@ class NWBRecordingEngine */ std::vector smpBuffer; }; -} // namespace NWB -} // namespace AQNWB +} // namespace AQNWB::NWB diff --git a/src/nwb/device/Device.hpp b/src/nwb/device/Device.hpp index e8c230ee..74ae7062 100644 --- a/src/nwb/device/Device.hpp +++ b/src/nwb/device/Device.hpp @@ -5,9 +5,7 @@ #include "BaseIO.hpp" #include "nwb/hdmf/base/Container.hpp" -namespace AQNWB -{ -namespace NWB +namespace AQNWB::NWB { /** * @brief Metadata about a data acquisition device, e.g., recording system, @@ -62,5 +60,4 @@ class Device : public Container */ std::string manufacturer; }; -} // namespace NWB -} // namespace AQNWB +} // namespace AQNWB::NWB diff --git a/src/nwb/file/ElectrodeGroup.hpp b/src/nwb/file/ElectrodeGroup.hpp index 210f6724..4f4c55ca 100644 --- a/src/nwb/file/ElectrodeGroup.hpp +++ b/src/nwb/file/ElectrodeGroup.hpp @@ -6,9 +6,7 @@ #include "nwb/device/Device.hpp" #include "nwb/hdmf/base/Container.hpp" -namespace AQNWB -{ -namespace NWB +namespace AQNWB::NWB { /** * @brief The ElectrodeGroup class represents a physical grouping of electrodes, @@ -80,5 +78,4 @@ class ElectrodeGroup : public Container */ Device device; }; -} // namespace NWB -} // namespace AQNWB +} // namespace AQNWB::NWB diff --git a/src/nwb/file/ElectrodeTable.hpp b/src/nwb/file/ElectrodeTable.hpp index 39c2716d..40abdbbb 100644 --- a/src/nwb/file/ElectrodeTable.hpp +++ b/src/nwb/file/ElectrodeTable.hpp @@ -7,9 +7,7 @@ #include "nwb/hdmf/table/ElementIdentifiers.hpp" #include "nwb/hdmf/table/VectorData.hpp" -namespace AQNWB -{ -namespace NWB +namespace AQNWB::NWB { /** * @brief Represents a table containing electrode metadata. @@ -117,5 +115,4 @@ class ElectrodeTable : public DynamicTable */ std::string groupPath = "/general/extracellular_ephys/array1"; }; -} // namespace NWB -} // namespace AQNWB +} // namespace AQNWB::NWB diff --git a/src/nwb/hdmf/base/Container.hpp b/src/nwb/hdmf/base/Container.hpp index e35b7dbf..1d89c875 100644 --- a/src/nwb/hdmf/base/Container.hpp +++ b/src/nwb/hdmf/base/Container.hpp @@ -5,9 +5,7 @@ #include "BaseIO.hpp" -namespace AQNWB -{ -namespace NWB +namespace AQNWB::NWB { /** * @brief Abstract data type for a group storing collections of data and @@ -50,5 +48,4 @@ class Container */ std::shared_ptr io; }; -} // namespace NWB -} // namespace AQNWB +} // namespace AQNWB::NWB diff --git a/src/nwb/hdmf/base/Data.hpp b/src/nwb/hdmf/base/Data.hpp index 32bdb0ca..ef146485 100644 --- a/src/nwb/hdmf/base/Data.hpp +++ b/src/nwb/hdmf/base/Data.hpp @@ -4,9 +4,7 @@ #include "BaseIO.hpp" -namespace AQNWB -{ -namespace NWB +namespace AQNWB::NWB { /** * @brief An abstract data type for a dataset. @@ -29,5 +27,4 @@ class Data */ std::unique_ptr dataset; }; -} // namespace NWB -} // namespace AQNWB +} // namespace AQNWB::NWB diff --git a/src/nwb/hdmf/table/DynamicTable.hpp b/src/nwb/hdmf/table/DynamicTable.hpp index 07f804b2..0e9f6cf7 100644 --- a/src/nwb/hdmf/table/DynamicTable.hpp +++ b/src/nwb/hdmf/table/DynamicTable.hpp @@ -7,9 +7,7 @@ #include "nwb/hdmf/table/ElementIdentifiers.hpp" #include "nwb/hdmf/table/VectorData.hpp" -namespace AQNWB -{ -namespace NWB +namespace AQNWB::NWB { /** * @brief Represents a group containing multiple datasets that are aligned on @@ -96,5 +94,4 @@ class DynamicTable : public Container */ std::vector colNames; }; -} // namespace NWB -} // namespace AQNWB +} // namespace AQNWB::NWB diff --git a/src/nwb/hdmf/table/ElementIdentifiers.hpp b/src/nwb/hdmf/table/ElementIdentifiers.hpp index 0af32db3..813f472e 100644 --- a/src/nwb/hdmf/table/ElementIdentifiers.hpp +++ b/src/nwb/hdmf/table/ElementIdentifiers.hpp @@ -2,9 +2,7 @@ #include "nwb/hdmf/base/Data.hpp" -namespace AQNWB -{ -namespace NWB +namespace AQNWB::NWB { /** * @brief A list of unique identifiers for values within a dataset, e.g. rows of @@ -13,5 +11,4 @@ namespace NWB class ElementIdentifiers : public Data { }; -} // namespace NWB -} // namespace AQNWB +} // namespace AQNWB::NWB diff --git a/src/nwb/hdmf/table/VectorData.hpp b/src/nwb/hdmf/table/VectorData.hpp index 0e574c81..7ee93f09 100644 --- a/src/nwb/hdmf/table/VectorData.hpp +++ b/src/nwb/hdmf/table/VectorData.hpp @@ -4,9 +4,7 @@ #include "nwb/hdmf/base/Data.hpp" -namespace AQNWB -{ -namespace NWB +namespace AQNWB::NWB { /** * @brief An n-dimensional dataset representing a column of a DynamicTable. @@ -26,5 +24,4 @@ class VectorData : public Data */ std::string description; }; -} // namespace NWB -} // namespace AQNWB +} // namespace AQNWB::NWB