From 21fd33fe34480dcfbc8c58262f2b73973b365dbc Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:12:32 -0700 Subject: [PATCH] update mock channel and recording array creation --- tests/testEcephys.cpp | 8 ++++---- tests/testNWBRecording.cpp | 11 ++++++----- tests/testUtils.hpp | 19 ++++++++++++------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/tests/testEcephys.cpp b/tests/testEcephys.cpp index 8f83b4fd..bb410128 100644 --- a/tests/testEcephys.cpp +++ b/tests/testEcephys.cpp @@ -20,13 +20,13 @@ TEST_CASE("ElectrodeTable", "[ecephys]") io->open(); io->createGroup("/general"); io->createGroup("/general/extracellular_ephys"); - io->createGroup("/general/extracellular_ephys/array1"); + io->createGroup("/general/extracellular_ephys/array0"); std::vector channelIDs = {0, 1, 2}; std::vector channels = { - Channel("ch0", "array1", channelIDs[0], 0), - Channel("ch1", "array1", channelIDs[1], 1), - Channel("ch2", "array1", channelIDs[2], 2), + Channel("ch0", "array0", channelIDs[0], 0), + Channel("ch1", "array0", channelIDs[1], 1), + Channel("ch2", "array0", channelIDs[2], 2), }; NWB::ElectrodeTable electrodeTable(path, io); diff --git a/tests/testNWBRecording.cpp b/tests/testNWBRecording.cpp index 84f897c7..881e5cee 100644 --- a/tests/testNWBRecording.cpp +++ b/tests/testNWBRecording.cpp @@ -74,7 +74,7 @@ TEST_CASE("writeContinuousData", "[recording]") nwbRecording.closeFile(); // check contents of data - std::string dataPath = "/acquisition/array1/data"; + std::string dataPath = "/acquisition/array0/data"; std::unique_ptr file = std::make_unique(path + "Recording1.nwb", H5F_ACC_RDONLY); std::unique_ptr dataset = std::make_unique(file->openDataSet(dataPath)); SizeType numChannelsToRead = numChannels / 2; @@ -97,7 +97,7 @@ TEST_CASE("writeContinuousData", "[recording]") REQUIRE_THAT(dataOut[1], Catch::Matchers::Approx(mockData[1]).margin(1)); // check contents of timestamps - std::string timestampsPath = "/acquisition/array1/timestamps"; + std::string timestampsPath = "/acquisition/array0/timestamps"; std::unique_ptr tsDataset = std::make_unique(file->openDataSet(timestampsPath)); double* tsBuffer = new double[numSamples]; @@ -119,13 +119,14 @@ TEST_CASE("writeContinuousData", "[recording]") } // setup mock data - SizeType numChannels = 2; + SizeType numChannels = 1; + SizeType numArrays = 1; SizeType numSamples = 45000; std::vector dataBuffer(numSamples); std::vector timestampsBuffer(numSamples); std::vector mockRecordingArrays = - getMockChannelArrays(); + getMockChannelArrays(numChannels, numArrays); std::vector> mockData = getMockData(numChannels, numSamples); std::vector mockTimestamps = getMockTimestamps(numSamples); @@ -153,7 +154,7 @@ TEST_CASE("writeContinuousData", "[recording]") nwbRecording.closeFile(); // check contents of data - std::string dataPath = "/acquisition/array1/data"; + std::string dataPath = "/acquisition/array0/data"; std::unique_ptr file = std::make_unique(path + "Recording1.nwb", H5F_ACC_RDONLY); std::unique_ptr dataset = std::make_unique(file->openDataSet(dataPath)); diff --git a/tests/testUtils.hpp b/tests/testUtils.hpp index 0e0a7997..08096de6 100644 --- a/tests/testUtils.hpp +++ b/tests/testUtils.hpp @@ -30,14 +30,19 @@ inline std::string getTestFilePath(std::string filename) return filepath.u8string(); } -inline std::vector getMockChannelArrays() +inline std::vector getMockChannelArrays(SizeType numChannels = 2, SizeType numArrays = 2) { - Channel ch0 = Channel("ch0", "array1", 0, 0); - Channel ch1 = Channel("ch1", "array1", 1, 1); - Channel ch2 = Channel("ch2", "array2", 0, 2); - Channel ch3 = Channel("ch3", "array2", 1, 3); - std::vector arrays = {Types::ChannelGroup {ch0, ch1}, - Types::ChannelGroup {ch2, ch3}}; + std::vector arrays(numArrays); + for (SizeType i = 0; i < numArrays; i++) + { + std::vector chGroup; + for (SizeType j = 0; j < numChannels; j++) + { + Channel ch ("ch" + std::to_string(j), "array" + std::to_string(i), j, i*numArrays + j); + chGroup.push_back(ch); + } + arrays[i] = chGroup; + } return arrays; }