Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Sep 9, 2024
1 parent c060e13 commit ab6a995
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 40 deletions.
13 changes: 8 additions & 5 deletions src/nwb/NWBFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
#include "spec/hdmf_common.hpp"
#include "spec/hdmf_experimental.hpp"


using namespace AQNWB::NWB;

constexpr SizeType CHUNK_XSIZE = 2048; // TODO - replace these with io settings input
constexpr SizeType SPIKE_CHUNK_XSIZE = 8; // TODO - replace with io settings input
constexpr SizeType CHUNK_XSIZE =
2048; // TODO - replace these with io settings input
constexpr SizeType SPIKE_CHUNK_XSIZE =
8; // TODO - replace with io settings input

std::vector<SizeType> NWBFile::emptyContainerIndexes = {};

Expand Down Expand Up @@ -110,7 +111,8 @@ Status NWBFile::createElectricalSeries(
}

// Setup electrode table if it was not yet created
bool electrodeTableCreated = io->objectExists(ElectrodeTable::electrodeTablePath);
bool electrodeTableCreated =
io->objectExists(ElectrodeTable::electrodeTablePath);
if (!electrodeTableCreated) {
elecTable = std::make_unique<ElectrodeTable>(io);
elecTable->initialize();
Expand Down Expand Up @@ -171,7 +173,8 @@ Status NWBFile::createSpikeEventSeries(
}

// Setup electrode table if it was not yet created
bool electrodeTableCreated = io->objectExists(ElectrodeTable::electrodeTablePath);
bool electrodeTableCreated =
io->objectExists(ElectrodeTable::electrodeTablePath);
if (!electrodeTableCreated) {
elecTable = std::make_unique<ElectrodeTable>(io);
elecTable->initialize();
Expand Down
13 changes: 5 additions & 8 deletions src/nwb/RecordingContainers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "nwb/ecephys/SpikeEventSeries.hpp"
#include "nwb/hdmf/base/Container.hpp"


using namespace AQNWB::NWB;
// Recording Container

Expand Down Expand Up @@ -66,13 +65,11 @@ Status RecordingContainers::writeElectricalSeriesData(
es->writeChannel(channel.localIndex, numSamples, data, timestamps);
}


Status RecordingContainers::writeSpikeEventData(
const SizeType& containerInd,
const SizeType& numSamples,
const SizeType& numChannels,
const void* data,
const void* timestamps)
Status RecordingContainers::writeSpikeEventData(const SizeType& containerInd,
const SizeType& numSamples,
const SizeType& numChannels,
const void* data,
const void* timestamps)
{
SpikeEventSeries* ses =
dynamic_cast<SpikeEventSeries*>(getContainer(containerInd));
Expand Down
8 changes: 4 additions & 4 deletions src/nwb/RecordingContainers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ class RecordingContainers
* @return The status of the write operation.
*/
Status writeSpikeEventData(const SizeType& containerInd,
const SizeType& numSamples,
const SizeType& numChannels,
const void* data,
const void* timestamps);
const SizeType& numSamples,
const SizeType& numChannels,
const void* data,
const void* timestamps);

std::vector<std::unique_ptr<Container>> containers;
std::string name;
Expand Down
6 changes: 2 additions & 4 deletions src/nwb/ecephys/SpikeEventSeries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,14 @@ Status SpikeEventSeries::writeSpike(const SizeType& numSamples,
std::vector<SizeType> dataShape;
std::vector<SizeType> positionOffset;
if (numChannels == 1) {
dataShape = {1, numSamples};
dataShape = {1, numSamples};
positionOffset = {this->eventsRecorded, 0};
}
else {
} else {
dataShape = {1, numChannels, numSamples};
positionOffset = {this->eventsRecorded, 0, 0};
}
this->eventsRecorded += 1;

// write channel data
return writeData(dataShape, positionOffset, data, timestamps);

}
8 changes: 4 additions & 4 deletions src/nwb/ecephys/SpikeEventSeries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class SpikeEventSeries : public ElectricalSeries
* @param timestamps The timestamps of the event
* @param
*/
Status writeSpike(const SizeType& numSamples,
const SizeType& numChannels,
const void* data,
const void* timestamps);
Status writeSpike(const SizeType& numSamples,
const SizeType& numChannels,
const void* data,
const void* timestamps);

private:
/**
Expand Down
30 changes: 15 additions & 15 deletions tests/testEcephys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,12 @@ TEST_CASE("SpikeEventSeries", "[ecephys]")
SizeType numSamples = 32;
SizeType numChannels = 4;
SizeType numEvents = 10;
std::vector<Types::ChannelVector> mockArrays = getMockChannelArrays(numChannels);
std::vector<Types::ChannelVector> mockArrays =
getMockChannelArrays(numChannels);
std::string dataPath = "/sesdata";
BaseDataType dataType = BaseDataType::F32;
std::vector<std::vector<float>> mockData =
getMockData2D(numSamples*numChannels, numEvents);
getMockData2D(numSamples * numChannels, numEvents);
std::vector<double> mockTimestamps = getMockTimestamps(numEvents, 1);
std::string devicePath = "/device";
std::string electrodePath = "/elecgroup/";
Expand All @@ -185,21 +186,20 @@ 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}, // TODO - fix the size inputs
SizeArray {8, 1, 1});
NWB::SpikeEventSeries ses = NWB::SpikeEventSeries(
dataPath,
io,
dataType,
mockArrays[0],
"no description",
SizeArray {0, numChannels, numSamples}, // TODO - fix the size inputs
SizeArray {8, 1, 1});
ses.initialize();

// write channel data
for (SizeType e = 0; e < numEvents; ++e) {
double timestamp = mockTimestamps[e];
ses.writeSpike(
numSamples, numChannels, mockData[e].data(), &timestamp);
ses.writeSpike(numSamples, numChannels, mockData[e].data(), &timestamp);
}
io->close();

Expand All @@ -208,9 +208,9 @@ TEST_CASE("SpikeEventSeries", "[ecephys]")
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 * numChannels));
float* buffer = new float[numEvents* numSamples * numChannels];
std::vector<std::vector<float>> dataOut(
numEvents, std::vector<float>(numSamples * numChannels));
float* buffer = new float[numEvents * numSamples * numChannels];

H5::DataSpace fSpace = dataset->getSpace();
hsize_t dims[3];
Expand Down

0 comments on commit ab6a995

Please sign in to comment.