Skip to content

Commit

Permalink
fix electricalSeries default inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Aug 6, 2024
1 parent 1202931 commit 5254d8a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 37 deletions.
13 changes: 5 additions & 8 deletions src/nwb/NWBFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ Status NWBFile::createFileStructure()
io->createGroup("/stimulus/presentation");
io->createGroup("/stimulus/templates");
io->createGroup("/general");
io->createGroup("general/devices");
io->createGroup("general/extracellular_ephys");
io->createGroup("/general/devices");
io->createGroup("/general/extracellular_ephys");

io->createGroup("/specifications");
io->createReferenceAttribute("/specifications", "/", ".specloc");
Expand All @@ -86,16 +86,15 @@ Status NWBFile::createElectricalSeries(
std::string rootPath = "/acquisition/";

// Setup electrode table
std::string electrodeTablePath = "general/extracellular_ephys/electrodes/";
ElectrodeTable elecTable = ElectrodeTable(electrodeTablePath, io);
ElectrodeTable elecTable = ElectrodeTable(io);
elecTable.initialize();

// Create continuous datasets
for (const auto& channelVector : recordingArrays) {
// Setup electrodes and devices
std::string groupName = channelVector[0].groupName;
std::string devicePath = "general/devices/" + groupName;
std::string electrodePath = "general/extracellular_ephys/" + groupName;
std::string devicePath = "/general/devices/" + groupName;
std::string electrodePath = "/general/extracellular_ephys/" + groupName;
std::string electricalSeriesPath = rootPath + groupName;

Device device = Device(devicePath, io, "description", "unknown");
Expand All @@ -111,8 +110,6 @@ Status NWBFile::createElectricalSeries(
io,
dataType,
channelVector,
elecTable.getPath(),
"volts",
"Stores continuously sampled voltage data from an "
"extracellular ephys recording",
SizeArray {0, channelVector.size()},
Expand Down
5 changes: 1 addition & 4 deletions src/nwb/ecephys/ElectricalSeries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ ElectricalSeries::ElectricalSeries(const std::string& path,
std::shared_ptr<BaseIO> io,
const BaseDataType& dataType,
const Types::ChannelVector& channelVector,
const std::string& electrodesTablePath,
const std::string& unit,
const std::string& description,
const SizeArray& dsetSize,
const SizeArray& chunkSize,
Expand All @@ -20,7 +18,7 @@ ElectricalSeries::ElectricalSeries(const std::string& path,
: TimeSeries(path,
io,
dataType,
unit,
"volts", // default unit for Electrical Series
description,
channelVector[0].comments,
dsetSize,
Expand All @@ -29,7 +27,6 @@ ElectricalSeries::ElectricalSeries(const std::string& path,
resolution,
offset)
, channelVector(channelVector)
, electrodesTablePath(electrodesTablePath)
{
}

Expand Down
12 changes: 4 additions & 8 deletions src/nwb/ecephys/ElectricalSeries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class ElectricalSeries : public TimeSeries
* @param io A shared pointer to the IO object.
* @param dataType The data type to use for storing the recorded voltage
* @param channelVector The electrodes to use for recording
* @param electrodesTablePath Path to the electrodes table
* @param unit Unit for the electrical signal. Must be "volts".
* @param description The description of the TimeSeries.
* @param dsetSize Initial size of the main dataset. This must be a vector
* with two elements. The first element specifies the length
Expand All @@ -41,11 +39,9 @@ class ElectricalSeries : public TimeSeries
std::shared_ptr<BaseIO> io,
const BaseDataType& dataType,
const Types::ChannelVector& channelVector,
const std::string& electrodesTablePath,
const std::string& unit = "volts",
const std::string& description = "no description",
const SizeArray& dsetSize = SizeArray {0},
const SizeArray& chunkSize = SizeArray {1},
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);
Expand Down Expand Up @@ -81,7 +77,7 @@ class ElectricalSeries : public TimeSeries
/**
* @brief Path to the electrodes table this time series references
*/
std::string electrodesTablePath;
std::string electrodesTablePath = "/general/extracellular_ephys/electrodes/";

/**
* @brief Pointer to channel-specific conversion factor dataset.
Expand Down
9 changes: 6 additions & 3 deletions src/nwb/file/ElectrodeTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ using namespace AQNWB::NWB;
// ElectrodeTable

/** Constructor */
ElectrodeTable::ElectrodeTable(const std::string& path,
std::shared_ptr<BaseIO> io,
ElectrodeTable::ElectrodeTable(std::shared_ptr<BaseIO> io,
const std::string& description)
: DynamicTable(path, io, description)
: DynamicTable(
"/general/extracellular_ephys/electrodes/", // default value for
// electrodes table
io,
description)
{
}

Expand Down
4 changes: 1 addition & 3 deletions src/nwb/file/ElectrodeTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ class ElectrodeTable : public DynamicTable
public:
/**
* @brief Constructor.
* @param path The path of the table.
* @param io The shared pointer to the BaseIO object.
* @param description The description of the table (default: "metadata about
* extracellular electrodes").
*/
ElectrodeTable(const std::string& path,
std::shared_ptr<BaseIO> io,
ElectrodeTable(std::shared_ptr<BaseIO> io,
const std::string& description =
"metadata about extracellular electrodes");

Expand Down
14 changes: 6 additions & 8 deletions tests/testEcephys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ TEST_CASE("ElectricalSeries", "[ecephys]")
std::string path = getTestFilePath("ElectricalSeries.h5");
std::shared_ptr<BaseIO> io = createIO("HDF5", path);
io->open();
io->createGroup("/general");
io->createGroup("/general/extracellular_ephys");

// setup electrode table, device, and electrode group
std::string elecTablePath = "/electrodes/";
NWB::ElectrodeTable elecTable = NWB::ElectrodeTable(elecTablePath, io);
NWB::ElectrodeTable elecTable = NWB::ElectrodeTable(io);
elecTable.initialize();

// setup electrical series
Expand All @@ -60,8 +61,6 @@ TEST_CASE("ElectricalSeries", "[ecephys]")
io,
dataType,
mockArrays[0],
elecTable.getPath(),
"volts",
"no description",
SizeArray {0, mockArrays[0].size()},
SizeArray {1, 1});
Expand Down Expand Up @@ -104,10 +103,11 @@ TEST_CASE("ElectricalSeries", "[ecephys]")
std::string path = getTestFilePath("ElectricalSeriesSampleTracking.h5");
std::shared_ptr<BaseIO> io = createIO("HDF5", path);
io->open();
io->createGroup("/general");
io->createGroup("/general/extracellular_ephys");

// setup electrode table
std::string elecTablePath = "/electrodes/";
NWB::ElectrodeTable elecTable = NWB::ElectrodeTable(elecTablePath, io);
NWB::ElectrodeTable elecTable = NWB::ElectrodeTable(io);
elecTable.initialize();

// setup electrical series
Expand All @@ -116,8 +116,6 @@ TEST_CASE("ElectricalSeries", "[ecephys]")
io,
dataType,
mockArrays[0],
elecTable.getPath(),
"volts",
"no description",
SizeArray {0, mockArrays[0].size()},
SizeArray {1, 1});
Expand Down
8 changes: 5 additions & 3 deletions tests/testFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using namespace AQNWB;

TEST_CASE("ElectrodeTable", "[ecephys]")
{
std::string path = "/electrodes/";
std::string path = "/general/extracellular_ephys/electrodes/";
SECTION("test initialization")
{
std::string filename = getTestFilePath("electrodeTable.h5");
Expand All @@ -28,7 +28,7 @@ TEST_CASE("ElectrodeTable", "[ecephys]")
Channel("ch2", "array0", channelIDs[2], 2),
};

NWB::ElectrodeTable electrodeTable(path, io);
NWB::ElectrodeTable electrodeTable(io);
electrodeTable.initialize();
electrodeTable.addElectrodes(channels);
electrodeTable.finalize();
Expand All @@ -52,7 +52,9 @@ TEST_CASE("ElectrodeTable", "[ecephys]")
std::string filename = getTestFilePath("electrodeTableNoData.h5");
std::shared_ptr<BaseIO> io = std::make_unique<HDF5::HDF5IO>(filename);
io->open();
NWB::ElectrodeTable electrodeTable(path, io);
io->createGroup("/general");
io->createGroup("/general/extracellular_ephys");
NWB::ElectrodeTable electrodeTable(io);
electrodeTable.initialize();
}

Expand Down

0 comments on commit 5254d8a

Please sign in to comment.