Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Sep 10, 2024
1 parent 3d32106 commit cd2d098
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 35 deletions.
3 changes: 2 additions & 1 deletion src/BaseIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ class BaseIO
const std::string& path) = 0;

/**
* @brief Checks whether a Dataset, Group, or Link already exists at the location in the file.
* @brief Checks whether a Dataset, Group, or Link already exists at the
* location in the file.
* @param path The location of the object in the file.
* @return Whether the object exists.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/hdf5/HDF5IO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ class HDF5IO : public BaseIO
const std::string& path) override;

/**
* @brief Checks whether a Dataset, Group, or Link already exists at the location in the file.
* @brief Checks whether a Dataset, Group, or Link already exists at the
* location in the file.
* @param path The location of the object in the file.
* @return Whether the object exists.
*/
Expand Down
14 changes: 8 additions & 6 deletions src/nwb/NWBFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ Status NWBFile::createElectricalSeries(
std::string electrodePath = "/general/extracellular_ephys/" + sourceName;
std::string electricalSeriesPath = acquisitionPath + "/" + groupName;

// Check if device exists for groupName, create device and electrode group if not
if (!io->objectExists(devicePath)){
// Check if device exists for groupName, create device and electrode group
// if not
if (!io->objectExists(devicePath)) {
Device device = Device(devicePath, io, "description", "unknown");
device.initialize();

ElectrodeGroup elecGroup =
ElectrodeGroup(electrodePath, io, "description", "unknown", device);
ElectrodeGroup(electrodePath, io, "description", "unknown", device);
elecGroup.initialize();
}

Expand Down Expand Up @@ -192,13 +193,14 @@ Status NWBFile::createSpikeEventSeries(
std::string electrodePath = "/general/extracellular_ephys/" + sourceName;
std::string spikeEventSeriesPath = acquisitionPath + "/" + groupName;

// Check if device exists for groupName, create device and electrode group if not
if (!io->objectExists(devicePath)){
// Check if device exists for groupName, create device and electrode group
// if not
if (!io->objectExists(devicePath)) {
Device device = Device(devicePath, io, "description", "unknown");
device.initialize();

ElectrodeGroup elecGroup =
ElectrodeGroup(electrodePath, io, "description", "unknown", device);
ElectrodeGroup(electrodePath, io, "description", "unknown", device);
elecGroup.initialize();
}

Expand Down
46 changes: 22 additions & 24 deletions tests/testEcephys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ TEST_CASE("SpikeEventSeries", "[ecephys]")
// setup mock data
SizeType numChannels = 4;
std::vector<Types::ChannelVector> mockArrays =
getMockChannelArrays(numChannels);
getMockChannelArrays(numChannels);
std::vector<std::vector<float>> mockData =
getMockData2D(numSamples * numChannels, numEvents);
getMockData2D(numSamples * numChannels, numEvents);

// setup io object
std::string path = getTestFilePath("SpikeEventSeries3D.h5");
Expand All @@ -188,14 +188,14 @@ TEST_CASE("SpikeEventSeries", "[ecephys]")
elecTable.initialize();

// setup electrical series
NWB::SpikeEventSeries ses = NWB::SpikeEventSeries(
dataPath,
io,
dataType,
mockArrays[0],
"no description",
SizeArray {0, numChannels, numSamples},
SizeArray {8, 1, 1});
NWB::SpikeEventSeries ses =
NWB::SpikeEventSeries(dataPath,
io,
dataType,
mockArrays[0],
"no description",
SizeArray {0, numChannels, numSamples},
SizeArray {8, 1, 1});
ses.initialize();

// write channel data
Expand Down Expand Up @@ -230,13 +230,12 @@ TEST_CASE("SpikeEventSeries", "[ecephys]")
REQUIRE_THAT(dataOut[1], Catch::Matchers::Approx(mockData[1]).margin(1));
}

SECTION("test writing events - events x samples")
SECTION("test writing events - events x samples")
{
// setup mock data
std::vector<Types::ChannelVector> mockArrays =
getMockChannelArrays(1);
std::vector<Types::ChannelVector> mockArrays = getMockChannelArrays(1);
std::vector<std::vector<float>> mockData =
getMockData2D(numSamples, numEvents);
getMockData2D(numSamples, numEvents);

// setup io object
std::string path = getTestFilePath("SpikeEventSeries2D.h5");
Expand All @@ -250,14 +249,13 @@ SECTION("test writing events - events x samples")
elecTable.initialize();

// setup electrical series
NWB::SpikeEventSeries ses = NWB::SpikeEventSeries(
dataPath,
io,
dataType,
mockArrays[0],
"no description",
SizeArray {0, numSamples},
SizeArray {8, 1});
NWB::SpikeEventSeries ses = NWB::SpikeEventSeries(dataPath,
io,
dataType,
mockArrays[0],
"no description",
SizeArray {0, numSamples},
SizeArray {8, 1});
ses.initialize();

// write channel data
Expand All @@ -272,8 +270,8 @@ SECTION("test writing events - events x samples")
std::make_unique<H5::H5File>(path, H5F_ACC_RDONLY);
std::unique_ptr<H5::DataSet> dataset =
std::make_unique<H5::DataSet>(file->openDataSet(dataPath + "/data"));
std::vector<std::vector<float>> dataOut(
numEvents, std::vector<float>(numSamples));
std::vector<std::vector<float>> dataOut(numEvents,
std::vector<float>(numSamples));
float* buffer = new float[numEvents * numSamples];

H5::DataSpace fSpace = dataset->getSpace();
Expand Down
5 changes: 3 additions & 2 deletions tests/testNWBFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ TEST_CASE("createMultipleEcephysDatasets", "[nwb]")
std::unique_ptr<NWB::RecordingContainers> recordingContainers =
std::make_unique<NWB::RecordingContainers>();
Status resultCreateES = nwbfile.createElectricalSeries(
mockArrays, BaseDataType::F32, recordingContainers.get());
mockArrays, BaseDataType::F32, recordingContainers.get());
REQUIRE(resultCreateES == Status::Success);

// create SpikeEventSeries
SizeType numSamples = 5;
std::vector<Types::ChannelVector> mockSpikeArrays = getMockChannelArrays(1, 2, "spikedata");
std::vector<Types::ChannelVector> mockSpikeArrays =
getMockChannelArrays(1, 2, "spikedata");
Status resultCreateSES = nwbfile.createSpikeEventSeries(
mockSpikeArrays, BaseDataType::F32, recordingContainers.get());

Expand Down
4 changes: 3 additions & 1 deletion tests/testUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ inline std::string getTestFilePath(std::string filename)
}

inline std::vector<Types::ChannelVector> getMockChannelArrays(
SizeType numChannels = 2, SizeType numArrays = 2, std::string groupName = "esdata")
SizeType numChannels = 2,
SizeType numArrays = 2,
std::string groupName = "esdata")
{
std::vector<Types::ChannelVector> arrays(numArrays);
for (SizeType i = 0; i < numArrays; i++) {
Expand Down

0 comments on commit cd2d098

Please sign in to comment.