From 4d7b1eaf47da07dc30117b791d9af991ae4dc0fd Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Sat, 31 Aug 2024 14:19:23 -0700 Subject: [PATCH] Start refactor containers for read --- src/nwb/NWBFile.cpp | 16 ++--- src/nwb/NWBFile.hpp | 9 ++- src/nwb/NWBRecording.cpp | 5 +- src/nwb/base/TimeSeries.cpp | 32 ++++----- src/nwb/base/TimeSeries.hpp | 97 +++++++--------------------- src/nwb/device/Device.cpp | 21 +----- src/nwb/device/Device.hpp | 22 ++----- src/nwb/ecephys/ElectricalSeries.cpp | 41 ++++++------ src/nwb/ecephys/ElectricalSeries.hpp | 40 ++++++------ src/nwb/file/ElectrodeTable.cpp | 18 ++++-- src/nwb/file/ElectrodeTable.hpp | 9 +-- src/nwb/hdmf/base/Container.hpp | 7 ++ src/nwb/hdmf/base/Data.hpp | 2 +- src/nwb/hdmf/table/DynamicTable.cpp | 8 +-- src/nwb/hdmf/table/DynamicTable.hpp | 8 +-- tests/testBase.cpp | 9 +-- tests/testEcephys.cpp | 26 ++++---- tests/testNWBFile.cpp | 17 ++--- 18 files changed, 154 insertions(+), 233 deletions(-) diff --git a/src/nwb/NWBFile.cpp b/src/nwb/NWBFile.cpp index 132840ca..0c59ba37 100644 --- a/src/nwb/NWBFile.cpp +++ b/src/nwb/NWBFile.cpp @@ -25,16 +25,16 @@ constexpr SizeType CHUNK_XSIZE = 2048; // NWBFile -NWBFile::NWBFile(const std::string& idText, std::shared_ptr io) - : identifierText(idText) - , io(io) +NWBFile::NWBFile(std::shared_ptr io) + : Container("/", io) { } NWBFile::~NWBFile() {} -Status NWBFile::initialize() +Status NWBFile::initialize(const std::string& idText) { + this->identifierText = idText; if (std::filesystem::exists(io->getFileName())) { return io->open(false); } else { @@ -114,8 +114,8 @@ Status NWBFile::createElectricalSeries( std::string electrodePath = "/general/extracellular_ephys/" + groupName; std::string electricalSeriesPath = rootPath + groupName; - Device device = Device(devicePath, io, "description", "unknown"); - device.initialize(); + Device device = Device(devicePath, io); + device.initialize("description", "unknown"); ElectrodeGroup elecGroup = ElectrodeGroup(electrodePath, io, "description", "unknown", device); @@ -124,14 +124,14 @@ Status NWBFile::createElectricalSeries( // Setup electrical series datasets auto electricalSeries = std::make_unique( electricalSeriesPath, - io, + io); + electricalSeries->initialize( dataType, channelVector, "Stores continuously sampled voltage data from an " "extracellular ephys recording", SizeArray {0, channelVector.size()}, SizeArray {CHUNK_XSIZE, 0}); - electricalSeries->initialize(); recordingContainers->addData(std::move(electricalSeries)); // Add electrode information to electrode table (does not write to datasets diff --git a/src/nwb/NWBFile.hpp b/src/nwb/NWBFile.hpp index 08a22d41..13896b08 100644 --- a/src/nwb/NWBFile.hpp +++ b/src/nwb/NWBFile.hpp @@ -24,7 +24,7 @@ class RecordingContainers; // declare here because gets used in NWBFile class * @brief The NWBFile class provides an interface for setting up and managing * the NWB file. */ -class NWBFile +class NWBFile : public Container { public: /** @@ -32,7 +32,7 @@ class NWBFile * @param idText The identifier text for the NWBFile. * @param io The shared pointer to the IO object. */ - NWBFile(const std::string& idText, std::shared_ptr io); + NWBFile(std::shared_ptr io); /** * @brief Deleted copy constructor to prevent construction-copying. @@ -53,7 +53,7 @@ class NWBFile * @brief Initializes the NWB file by opening and setting up the file * structure. */ - Status initialize(); + Status initialize(const std::string& idText); /** * @brief Finalizes the NWB file by closing it. @@ -140,8 +140,7 @@ class NWBFile std::unique_ptr recordingContainers = std::make_unique("RecordingContainers"); - const std::string identifierText; - std::shared_ptr io; + std::string identifierText; // TODO Remove this for read }; /** diff --git a/src/nwb/NWBRecording.cpp b/src/nwb/NWBRecording.cpp index 1747471b..2895aef6 100644 --- a/src/nwb/NWBRecording.cpp +++ b/src/nwb/NWBRecording.cpp @@ -27,9 +27,8 @@ Status NWBRecording::openFile(const std::string& filename, } // initialize nwbfile object and create base structure - nwbfile = std::make_unique(generateUuid(), - createIO(IOType, filename)); - nwbfile->initialize(); + nwbfile = std::make_unique(createIO(IOType, filename)); + nwbfile->initialize(generateUuid()); // create the datasets nwbfile->createElectricalSeries(recordingArrays); diff --git a/src/nwb/base/TimeSeries.cpp b/src/nwb/base/TimeSeries.cpp index a9c008b3..bc2668f6 100644 --- a/src/nwb/base/TimeSeries.cpp +++ b/src/nwb/base/TimeSeries.cpp @@ -6,36 +6,28 @@ using namespace AQNWB::NWB; /** Constructor */ TimeSeries::TimeSeries(const std::string& path, - std::shared_ptr io, - const BaseDataType& dataType, - const std::string& unit, - const std::string& description, - const std::string& comments, - const SizeArray& dsetSize, - const SizeArray& chunkSize, - const float& conversion, - const float& resolution, - const float& offset) + std::shared_ptr io) : Container(path, io) - , dataType(dataType) - , unit(unit) - , description(description) - , comments(comments) - , dsetSize(dsetSize) - , chunkSize(chunkSize) - , conversion(conversion) - , resolution(resolution) - , offset(offset) { } /** Destructor */ TimeSeries::~TimeSeries() {} -void TimeSeries::initialize() +void TimeSeries::initialize(const BaseDataType& dataType, + const std::string& unit, + const std::string& description, + const std::string& comments, + const SizeArray& dsetSize, + const SizeArray& chunkSize, + const float& conversion, + const float& resolution, + const float& offset) { Container::initialize(); + this->dataType = dataType; + // setup attributes io->createCommonNWBAttributes(path, "core", neurodataType, description); io->createAttribute(comments, path, "comments"); diff --git a/src/nwb/base/TimeSeries.hpp b/src/nwb/base/TimeSeries.hpp index 08537856..71fafeda 100644 --- a/src/nwb/base/TimeSeries.hpp +++ b/src/nwb/base/TimeSeries.hpp @@ -17,30 +17,9 @@ class TimeSeries : public Container * @brief Constructor. * @param path The location of the TimeSeries in the file. * @param io A shared pointer to the IO object. - * @param dataType The data type to use for storing the recorded signal - * @param unit Unit for the electrical signal. Must be "volts" - * @param description The description of the TimeSeries. - * @param comments Human-readable comments about the TimeSeries - * @param dsetSize Initial size of the main dataset - * @param chunkSize Chunk size to use - * @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' */ TimeSeries(const std::string& path, - std::shared_ptr io, - const BaseDataType& dataType, - const std::string& unit, - const std::string& description = "no description", - const std::string& comments = "no comments", - const SizeArray& dsetSize = SizeArray {0}, - const SizeArray& chunkSize = SizeArray {1}, - const float& conversion = 1.0f, - const float& resolution = -1.0f, - const float& offset = 0.0f); + std::shared_ptr io); /** * @brief Destructor @@ -65,8 +44,29 @@ class TimeSeries : public Container /** * @brief Initializes the TimeSeries by creating NWB related attributes and * writing the description and comment metadata. + * + * @param dataType The data type to use for storing the recorded signal + * @param unit Unit for the electrical signal. Must be "volts" + * @param description The description of the TimeSeries. + * @param comments Human-readable comments about the TimeSeries + * @param dsetSize Initial size of the main dataset + * @param chunkSize Chunk size to use + * @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' */ - void initialize(); + void initialize(const BaseDataType& dataType, + const std::string& unit, + const std::string& description = "no description", + const std::string& comments = "no comments", + const SizeArray& dsetSize = SizeArray {0}, + const SizeArray& chunkSize = SizeArray {1}, + const float& conversion = 1.0f, + const float& resolution = -1.0f, + const float& offset = 0.0f); /** * @brief Pointer to data values. @@ -88,57 +88,6 @@ class TimeSeries : public Container */ BaseDataType timestampsType = BaseDataType::F64; - /** - * @brief Base unit of measurement for working with the data. Actual stored - * values are not necessarily stored in these units. To access the data in - * these units, multiply ‘data’ by ‘conversion’ and add ‘offset’. - */ - std::string unit; - - /** - * @brief The description of the TimeSeries. - */ - std::string description; - - /** - * @brief Human-readable comments about the TimeSeries. - */ - std::string comments; - - /** - * @brief Size used in dataset creation. Can be expanded when writing if - * needed. - */ - SizeArray dsetSize; - - /** - * @brief Chunking size used in dataset creation. - */ - SizeArray chunkSize; - - /** - * @brief Scalar to multiply each element in data to convert it to the - * specified ‘unit’. - */ - float conversion; - - /** - * @brief Smallest meaningful difference between values in data, stored in the - * specified by unit. - */ - float resolution; - - /** - * @brief Scalar to add to the data after scaling by ‘conversion’ to finalize - * its coercion to the specified ‘unit’. - */ - float offset; - - /** - * @brief The starting time of the TimeSeries. - */ - float startingTime = 0.0; - private: /** * @brief The neurodataType of the TimeSeries. diff --git a/src/nwb/device/Device.cpp b/src/nwb/device/Device.cpp index 262d9207..21bd4e50 100644 --- a/src/nwb/device/Device.cpp +++ b/src/nwb/device/Device.cpp @@ -5,34 +5,19 @@ using namespace AQNWB::NWB; // Device /** Constructor */ Device::Device(const std::string& path, - std::shared_ptr io, - const std::string& description, - const std::string& manufacturer) + std::shared_ptr io) : Container(path, io) - , description(description) - , manufacturer(manufacturer) { } /** Destructor */ Device::~Device() {} -void Device::initialize() +void Device::initialize(const std::string& description, + const std::string& manufacturer) { Container::initialize(); io->createCommonNWBAttributes(path, "core", "Device", description); io->createAttribute(manufacturer, path, "manufacturer"); } - -// Getter for manufacturer -std::string Device::getManufacturer() const -{ - return manufacturer; -} - -// Getter for description -std::string Device::getDescription() const -{ - return description; -} diff --git a/src/nwb/device/Device.hpp b/src/nwb/device/Device.hpp index 74ae7062..83e0cb2a 100644 --- a/src/nwb/device/Device.hpp +++ b/src/nwb/device/Device.hpp @@ -18,13 +18,9 @@ class Device : public Container * @brief Constructor. * @param path The location of the device in the file. * @param io A shared pointer to the IO object. - * @param description The description of the device. - * @param manufacturer The manufacturer of the device. */ Device(const std::string& path, - std::shared_ptr io, - const std::string& description, - const std::string& manufacturer); + std::shared_ptr io); /** * @brief Destructor @@ -34,8 +30,12 @@ class Device : public Container /** * @brief Initializes the device by creating NWB related attributes and * writing the manufactor and description metadata. + * + * @param description The description of the device. + * @param manufacturer The manufacturer of the device. */ - void initialize(); + void initialize(const std::string& description, + const std::string& manufacturer); /** * @brief Gets the manufacturer of the device. @@ -49,15 +49,5 @@ class Device : public Container */ std::string getDescription() const; -private: - /** - * @brief The description of the device. - */ - std::string description; - - /** - * @brief The manufacturer of the device. - */ - std::string manufacturer; }; } // namespace AQNWB::NWB diff --git a/src/nwb/ecephys/ElectricalSeries.cpp b/src/nwb/ecephys/ElectricalSeries.cpp index ec3a3bb2..e561676b 100644 --- a/src/nwb/ecephys/ElectricalSeries.cpp +++ b/src/nwb/ecephys/ElectricalSeries.cpp @@ -9,27 +9,9 @@ using namespace AQNWB::NWB; /** Constructor */ ElectricalSeries::ElectricalSeries(const std::string& path, - std::shared_ptr io, - const BaseDataType& dataType, - const Types::ChannelVector& channelVector, - const std::string& description, - const SizeArray& dsetSize, - const SizeArray& chunkSize, - const float& conversion, - const float& resolution, - const float& offset) + std::shared_ptr io) : TimeSeries(path, - io, - dataType, - "volts", // default unit for Electrical Series - description, - channelVector[0].comments, - dsetSize, - chunkSize, - channelVector[0].getConversion(), - resolution, - offset) - , channelVector(channelVector) + io) { } @@ -37,9 +19,24 @@ ElectricalSeries::ElectricalSeries(const std::string& path, ElectricalSeries::~ElectricalSeries() {} /** Initialization function*/ -void ElectricalSeries::initialize() +void ElectricalSeries::initialize(const BaseDataType& dataType, + const Types::ChannelVector& channelVector, + const std::string& description, + const SizeArray& dsetSize, + const SizeArray& chunkSize, + const float& conversion, + const float& resolution, + const float& offset) { - TimeSeries::initialize(); + TimeSeries::initialize(dataType, + "volts", + description, + channelVector[0].comments, + dsetSize, + chunkSize, + channelVector[0].getConversion(), + resolution, + offset); // setup variables based on number of channels std::vector electrodeInds(channelVector.size()); diff --git a/src/nwb/ecephys/ElectricalSeries.hpp b/src/nwb/ecephys/ElectricalSeries.hpp index 597669be..a438dbb6 100644 --- a/src/nwb/ecephys/ElectricalSeries.hpp +++ b/src/nwb/ecephys/ElectricalSeries.hpp @@ -18,6 +18,18 @@ class ElectricalSeries : public TimeSeries * @brief Constructor. * @param path The location of the ElectricalSeries in the file. * @param io A shared pointer to the IO object. + */ + ElectricalSeries(const std::string& path, + std::shared_ptr io); + + /** + * @brief Destructor + */ + ~ElectricalSeries(); + + /** + * @brief Initializes the Electrical Series + * * @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. @@ -35,26 +47,14 @@ class ElectricalSeries : public TimeSeries * @param offset Scalar to add to the data after scaling by ‘conversion’ to * finalize its coercion to the specified ‘unit' */ - ElectricalSeries(const std::string& path, - std::shared_ptr io, - const BaseDataType& dataType, - const Types::ChannelVector& channelVector, - const std::string& description, - const SizeArray& dsetSize, - const SizeArray& chunkSize, - const float& conversion = 1.0f, - const float& resolution = -1.0f, - const float& offset = 0.0f); - - /** - * @brief Destructor - */ - ~ElectricalSeries(); - - /** - * @brief Initializes the Electrical Series - */ - void initialize(); + void initialize(const BaseDataType& dataType, + const Types::ChannelVector& channelVector, + const std::string& description, + const SizeArray& dsetSize, + const SizeArray& chunkSize, + const float& conversion = 1.0f, + const float& resolution = -1.0f, + const float& offset = 0.0f); /** * @brief Writes a channel to an ElectricalSeries dataset. diff --git a/src/nwb/file/ElectrodeTable.cpp b/src/nwb/file/ElectrodeTable.cpp index 027c9f6a..3b1b5a66 100644 --- a/src/nwb/file/ElectrodeTable.cpp +++ b/src/nwb/file/ElectrodeTable.cpp @@ -7,22 +7,28 @@ using namespace AQNWB::NWB; // ElectrodeTable /** Constructor */ -ElectrodeTable::ElectrodeTable(std::shared_ptr io, - const std::string& description) +ElectrodeTable::ElectrodeTable(std::shared_ptr io) : DynamicTable(electrodeTablePath, // use the electrodeTablePath - io, - description) + io) { } +ElectrodeTable::ElectrodeTable(const std::string& path, + std::shared_ptr io) + : DynamicTable(electrodeTablePath, // use the electrodeTablePath + io) +{ + assert(path == electrodeTablePath); +} + /** Destructor */ ElectrodeTable::~ElectrodeTable() {} /** Initialization function*/ -void ElectrodeTable::initialize() +void ElectrodeTable::initialize(const std::string& description) { // create group - DynamicTable::initialize(); + DynamicTable::initialize(description); electrodeDataset->dataset = std::unique_ptr(io->createArrayDataSet( diff --git a/src/nwb/file/ElectrodeTable.hpp b/src/nwb/file/ElectrodeTable.hpp index b8611a32..5693db43 100644 --- a/src/nwb/file/ElectrodeTable.hpp +++ b/src/nwb/file/ElectrodeTable.hpp @@ -21,9 +21,10 @@ class ElectrodeTable : public DynamicTable * @param description The description of the table (default: "metadata about * extracellular electrodes"). */ - ElectrodeTable(std::shared_ptr io, - const std::string& description = - "metadata about extracellular electrodes"); + ElectrodeTable(std::shared_ptr io); + + // required so we can call create + ElectrodeTable(const std::string& path, std::shared_ptr io); /** * @brief Destructor. @@ -36,7 +37,7 @@ class ElectrodeTable : public DynamicTable * Initializes the ElectrodeTable by creating NWB related attributes and * adding required columns. */ - void initialize(); + void initialize(const std::string& description = "metadata about extracellular electrodes"); /** * @brief Finalizes the ElectrodeTable. diff --git a/src/nwb/hdmf/base/Container.hpp b/src/nwb/hdmf/base/Container.hpp index 1d89c875..41b09fa9 100644 --- a/src/nwb/hdmf/base/Container.hpp +++ b/src/nwb/hdmf/base/Container.hpp @@ -37,6 +37,13 @@ class Container */ std::string getPath() const; + template + static std::unique_ptr create(const BaseIO& io, const std::string& path) + { + static_assert(std::is_base_of::value, "T must be a derived class of Container"); + return std::unique_ptr(new T(path, io)); + } + protected: /** * @brief The path of the container. diff --git a/src/nwb/hdmf/base/Data.hpp b/src/nwb/hdmf/base/Data.hpp index ef146485..656fbcab 100644 --- a/src/nwb/hdmf/base/Data.hpp +++ b/src/nwb/hdmf/base/Data.hpp @@ -25,6 +25,6 @@ class Data /** * @brief Pointer to dataset. */ - std::unique_ptr dataset; + std::unique_ptr dataset; // TODO For read we may not want this here if we ned Data for reads }; } // namespace AQNWB::NWB diff --git a/src/nwb/hdmf/table/DynamicTable.cpp b/src/nwb/hdmf/table/DynamicTable.cpp index d8b8c989..28d517e7 100644 --- a/src/nwb/hdmf/table/DynamicTable.cpp +++ b/src/nwb/hdmf/table/DynamicTable.cpp @@ -6,8 +6,7 @@ using namespace AQNWB::NWB; /** Constructor */ DynamicTable::DynamicTable(const std::string& path, - std::shared_ptr io, - const std::string& description) + std::shared_ptr io) : Container(path, io) , description(description) { @@ -17,12 +16,13 @@ DynamicTable::DynamicTable(const std::string& path, DynamicTable::~DynamicTable() {} /** Initialization function*/ -void DynamicTable::initialize() +void DynamicTable::initialize(const std::string& description) { Container::initialize(); + this->description = description; io->createCommonNWBAttributes( - path, "hdmf-common", "DynamicTable", getDescription()); + path, "hdmf-common", "DynamicTable", this->description); io->createAttribute(getColNames(), path, "colnames"); } diff --git a/src/nwb/hdmf/table/DynamicTable.hpp b/src/nwb/hdmf/table/DynamicTable.hpp index 6cd8c2a5..4a864aa5 100644 --- a/src/nwb/hdmf/table/DynamicTable.hpp +++ b/src/nwb/hdmf/table/DynamicTable.hpp @@ -23,11 +23,9 @@ class DynamicTable : public Container * @brief Constructor. * @param path The location of the table in the file. * @param io A shared pointer to the IO object. - * @param description The description of the table (optional). */ DynamicTable(const std::string& path, - std::shared_ptr io, - const std::string& description); + std::shared_ptr io); /** * @brief Destructor @@ -37,8 +35,10 @@ class DynamicTable : public Container /** * @brief Initializes the `DynamicTable` object by creating NWB attributes and * column names. + * + * @param description The description of the table (optional). */ - void initialize(); + void initialize(const std::string& description); /** * @brief Adds a column of vector string data to the table. diff --git a/tests/testBase.cpp b/tests/testBase.cpp index b3f46bc1..cb44db62 100644 --- a/tests/testBase.cpp +++ b/tests/testBase.cpp @@ -17,7 +17,7 @@ TEST_CASE("TimeSeries", "[base]") std::vector dataShape = {numSamples}; std::vector positionOffset = {0}; BaseDataType dataType = BaseDataType::F32; - std::vector data = getMockData1D(numSamples); + std::vector data = {0,1,2,3,4,5,6,7,8,9}; // getMockData1D(numSamples); BaseDataType timestampsType = BaseDataType::F64; std::vector timestamps = getMockTimestamps(numSamples, 1); @@ -27,15 +27,16 @@ TEST_CASE("TimeSeries", "[base]") std::string path = getTestFilePath("testTimeseries.h5"); std::shared_ptr io = createIO("HDF5", path); io->open(); - NWB::TimeSeries ts = NWB::TimeSeries(dataPath, io, dataType, "unit"); - ts.initialize(); + NWB::TimeSeries ts = NWB::TimeSeries(dataPath, io); + ts.initialize(dataType, "unit"); // Write data to file Status writeStatus = ts.writeData(dataShape, positionOffset, data.data(), timestamps.data()); REQUIRE(writeStatus == Status::Success); + io->flush(); - // Read data back from file + // Read timestamps back from file double* tsBuffer = new double[numSamples]; std::unique_ptr tsDset = io->getDataSet(dataPath + "/timestamps"); diff --git a/tests/testEcephys.cpp b/tests/testEcephys.cpp index 48737171..e830c474 100644 --- a/tests/testEcephys.cpp +++ b/tests/testEcephys.cpp @@ -58,13 +58,12 @@ TEST_CASE("ElectricalSeries", "[ecephys]") // setup electrical series NWB::ElectricalSeries es = NWB::ElectricalSeries(dataPath, - io, - dataType, - mockArrays[0], - "no description", - SizeArray {0, mockArrays[0].size()}, - SizeArray {1, 1}); - es.initialize(); + io); + es.initialize(dataType, + mockArrays[0], + "no description", + SizeArray {0, mockArrays[0].size()}, + SizeArray {1, 1}); // write channel data for (SizeType ch = 0; ch < numChannels; ++ch) { @@ -113,13 +112,12 @@ TEST_CASE("ElectricalSeries", "[ecephys]") // setup electrical series NWB::ElectricalSeries es = NWB::ElectricalSeries(dataPath, - io, - dataType, - mockArrays[0], - "no description", - SizeArray {0, mockArrays[0].size()}, - SizeArray {1, 1}); - es.initialize(); + io); + es.initialize(dataType, + mockArrays[0], + "no description", + SizeArray {0, mockArrays[0].size()}, + SizeArray {1, 1}); // write channel data in segments for (SizeType ch = 0; ch < numChannels; ++ch) { diff --git a/tests/testNWBFile.cpp b/tests/testNWBFile.cpp index bae35f42..86c563dd 100644 --- a/tests/testNWBFile.cpp +++ b/tests/testNWBFile.cpp @@ -14,9 +14,8 @@ TEST_CASE("saveNWBFile", "[nwb]") std::string filename = getTestFilePath("testSaveNWBFile.nwb"); // initialize nwbfile object and create base structure - NWB::NWBFile nwbfile(generateUuid(), - std::make_unique(filename)); - nwbfile.initialize(); + NWB::NWBFile nwbfile(std::make_unique(filename)); + nwbfile.initialize(generateUuid()); nwbfile.finalize(); } @@ -25,9 +24,8 @@ TEST_CASE("createElectricalSeries", "[nwb]") std::string filename = getTestFilePath("createElectricalSeries.nwb"); // initialize nwbfile object and create base structure - NWB::NWBFile nwbfile(generateUuid(), - std::make_unique(filename)); - nwbfile.initialize(); + NWB::NWBFile nwbfile(std::make_unique(filename)); + nwbfile.initialize(generateUuid()); // create Electrical Series std::vector mockArrays = getMockChannelArrays(1, 2); @@ -60,16 +58,15 @@ TEST_CASE("setCanModifyObjectsMode", "[nwb]") std::string filename = getTestFilePath("testCanModifyObjectsMode.nwb"); // initialize nwbfile object and create base structure with HDF5IO object - NWB::NWBFile nwbfile(generateUuid(), - std::make_unique(filename)); - nwbfile.initialize(); + NWB::NWBFile nwbfile(std::make_unique(filename)); + nwbfile.initialize(generateUuid()); // start recording Status resultStart = nwbfile.startRecording(); REQUIRE(resultStart == Status::Success); // test that modifying the file structure after starting the recording fails - Status resultInitializePostStart = nwbfile.initialize(); + Status resultInitializePostStart = nwbfile.initialize(generateUuid()); REQUIRE(resultInitializePostStart == Status::Failure); // test that dataset creation fails after starting the recording