Skip to content

Commit

Permalink
update mock channel and recording array creation
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Jun 5, 2024
1 parent fe11579 commit 21fd33f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
8 changes: 4 additions & 4 deletions tests/testEcephys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SizeType> channelIDs = {0, 1, 2};
std::vector<Channel> 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);
Expand Down
11 changes: 6 additions & 5 deletions tests/testNWBRecording.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<H5::H5File> file = std::make_unique<H5::H5File>(path + "Recording1.nwb", H5F_ACC_RDONLY);
std::unique_ptr<H5::DataSet> dataset = std::make_unique<H5::DataSet>(file->openDataSet(dataPath));
SizeType numChannelsToRead = numChannels / 2;
Expand All @@ -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<H5::DataSet> tsDataset = std::make_unique<H5::DataSet>(file->openDataSet(timestampsPath));
double* tsBuffer = new double[numSamples];

Expand All @@ -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<float> dataBuffer(numSamples);
std::vector<double> timestampsBuffer(numSamples);

std::vector<Types::ChannelGroup> mockRecordingArrays =
getMockChannelArrays();
getMockChannelArrays(numChannels, numArrays);
std::vector<std::vector<float>> mockData =
getMockData(numChannels, numSamples);
std::vector<double> mockTimestamps = getMockTimestamps(numSamples);
Expand Down Expand Up @@ -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<H5::H5File> file = std::make_unique<H5::H5File>(path + "Recording1.nwb", H5F_ACC_RDONLY);
std::unique_ptr<H5::DataSet> dataset = std::make_unique<H5::DataSet>(file->openDataSet(dataPath));

Expand Down
19 changes: 12 additions & 7 deletions tests/testUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ inline std::string getTestFilePath(std::string filename)
return filepath.u8string();
}

inline std::vector<Types::ChannelGroup> getMockChannelArrays()
inline std::vector<Types::ChannelGroup> 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<Types::ChannelGroup> arrays = {Types::ChannelGroup {ch0, ch1},
Types::ChannelGroup {ch2, ch3}};
std::vector<Types::ChannelGroup> arrays(numArrays);
for (SizeType i = 0; i < numArrays; i++)
{
std::vector<Channel> 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;
}

Expand Down

0 comments on commit 21fd33f

Please sign in to comment.