Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Mar 22, 2024
1 parent d6b6882 commit c6e45ac
Show file tree
Hide file tree
Showing 22 changed files with 324 additions and 213 deletions.
38 changes: 22 additions & 16 deletions src/NWBFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@

#include "NWBFile.hpp"

#include "io/BaseIO.hpp"
#include "Utils.hpp"
#include "device/Device.hpp"
#include "file/ElectrodeGroup.hpp"
#include "file/ElectrodeTable.hpp"
#include "device/Device.hpp"
#include "Utils.hpp"
#include "io/BaseIO.hpp"

using namespace AQNWBIO;
namespace fs = std::filesystem;


// NWBFile

NWBFile::NWBFile(const std::string& idText, std::shared_ptr<BaseIO> io)
Expand Down Expand Up @@ -76,7 +75,7 @@ Status NWBFile::createFileStructure()

Status NWBFile::startRecording()
{
// Later channels/continuous array will be input from the acquisition system
// Later channels/continuous array will be input from the acquisition system
// with unknown size but self generating for now
std::vector<int> continuousArray;
for (int i = 1; i <= 1; ++i) {
Expand All @@ -100,21 +99,27 @@ Status NWBFile::startRecording()
Device device = Device(devicePath, io, "description", "unknown");
device.initialize();

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

// Create electrode table
std::string electrodePath = "general/extracellular_ephys/electrodes/";
ElectrodeTable elecTable = ElectrodeTable(electrodePath, io, channels);


elecTable.electrodeDataset->dataset =
createRecordingData(BaseDataType::I32, SizeArray{1}, SizeArray{1}, electrodePath + "id");
elecTable.groupNamesDataset->dataset = createRecordingData(
BaseDataType::STR(250), SizeArray{0}, SizeArray{1}, electrodePath + "group_name");
elecTable.locationsDataset->dataset = createRecordingData(
BaseDataType::STR(250), SizeArray{0}, SizeArray{1}, electrodePath + "location");
elecTable.electrodeDataset->dataset = createRecordingData(
BaseDataType::I32, SizeArray {1}, SizeArray {1}, electrodePath + "id");
elecTable.groupNamesDataset->dataset =
createRecordingData(BaseDataType::STR(250),
SizeArray {0},
SizeArray {1},
electrodePath + "group_name");
elecTable.locationsDataset->dataset =
createRecordingData(BaseDataType::STR(250),
SizeArray {0},
SizeArray {1},
electrodePath + "location");

elecTable.initialize();

Expand Down Expand Up @@ -150,11 +155,12 @@ void NWBFile::cacheSpecifications(const std::string& specPath,
}
}



// recording data factory method /
std::unique_ptr<BaseRecordingData> NWBFile::createRecordingData(
BaseDataType type, const SizeArray& size, const SizeArray& chunking, const std::string& path)
BaseDataType type,
const SizeArray& size,
const SizeArray& chunking,
const std::string& path)
{
return std::unique_ptr<BaseRecordingData>(
io->createDataSet(type, size, chunking, path));
Expand Down
25 changes: 17 additions & 8 deletions src/NWBFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
using namespace AQNWBIO;

/**
* @brief The NWBFile class provides an interface for setting up and managing the NWB file.
* @brief The NWBFile class provides an interface for setting up and managing
* the NWB file.
*/
class NWBFile
{
Expand Down Expand Up @@ -35,7 +36,8 @@ class NWBFile
~NWBFile();

/**
* @brief Initializes the NWB file by opening and setting up the file structure.
* @brief Initializes the NWB file by opening and setting up the file
* structure.
*/
void initialize();

Expand Down Expand Up @@ -79,25 +81,32 @@ class NWBFile
* @param size The size of the dataset.
* @param chunking The chunking size of the dataset.
* @param path The location in the file of the new dataset.
* @return std::unique_ptr<BaseRecordingData> The unique pointer to the created recording data.
* @return std::unique_ptr<BaseRecordingData> The unique pointer to the
* created recording data.
*/
std::unique_ptr<BaseRecordingData> createRecordingData(
BaseDataType type, const SizeArray& size, const SizeArray& chunking, const std::string& path);
BaseDataType type,
const SizeArray& size,
const SizeArray& chunking,
const std::string& path);

/**
* @brief Saves the specification files for the schema.
* @param specPath The location in the file to store the spec information.
* @param versionNumber The version number of the specification files.
*/
void cacheSpecifications(const std::string& specPath, const std::string& versionNumber);
void cacheSpecifications(const std::string& specPath,
const std::string& versionNumber);

/**
* @brief Creates a new dataset to hold text data (messages).
* @param path The location in the file for the dataset.
* @param name The name of the dataset.
* @param text The text data to be stored in the dataset.
*/
void createTextDataSet(const std::string& path, const std::string& name, const std::string& text);
void createTextDataSet(const std::string& path,
const std::string& name,
const std::string& text);

const std::string identifierText;
std::shared_ptr<BaseIO> io;
Expand All @@ -106,7 +115,6 @@ class NWBFile
SizeType bufferSize;
};


/**
* @brief The NWBRecordingEngine class manages the recording process
*/
Expand Down Expand Up @@ -144,7 +152,8 @@ class NWBRecordingEngine
int recordingNumber);

/**
* @brief Closes all the files and performs necessary cleanup when recording stops.
* @brief Closes all the files and performs necessary cleanup when recording
* stops.
*/
void closeFiles();

Expand Down
31 changes: 18 additions & 13 deletions src/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@
/**
* @brief Provides definitions for various types used in the project.
*/
class Types {
class Types
{
public:
/**
* @brief Represents the status of an operation.
*/
enum Status {Success = 0, Failure = -1};
/**
* @brief Represents the status of an operation.
*/
enum Status
{
Success = 0,
Failure = -1
};

/**
* @brief Alias for the size type used in the project.
*/
using SizeType = size_t;
/**
* @brief Alias for the size type used in the project.
*/
using SizeType = size_t;

/**
* @brief Alias for an array of size types used in the project.
*/
using SizeArray = std::vector<size_t>;
/**
* @brief Alias for an array of size types used in the project.
*/
using SizeArray = std::vector<size_t>;
};
2 changes: 1 addition & 1 deletion src/Utils.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <chrono>
#include <ctime>
#include <sstream>
#include <iomanip>
#include <sstream>

#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
Expand Down
9 changes: 7 additions & 2 deletions src/device/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

// Device
/** Constructor */
Device::Device(const std::string& path, std::shared_ptr<BaseIO> io, const std::string& description, const std::string& manufacturer)
: Container(path, io), description(description), manufacturer(manufacturer)
Device::Device(const std::string& path,
std::shared_ptr<BaseIO> io,
const std::string& description,
const std::string& manufacturer)
: Container(path, io)
, description(description)
, manufacturer(manufacturer)
{
}

Expand Down
16 changes: 11 additions & 5 deletions src/device/Device.hpp
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
#pragma once

#include <string>

#include "hdmf/base/Container.hpp"
#include "io/BaseIO.hpp"

using namespace AQNWBIO;

/**
* @brief Metadata about a data acquisition device, e.g., recording system, electrode, microscope.
* @brief Metadata about a data acquisition device, e.g., recording system,
* electrode, microscope.
*/
class Device : public Container
{
public:
/**
* @brief Constructer.
* @brief Constructor.
* @param path The location of the device in the file.
* @param io A shared pointer to the IO object.
* @param description The description of the device.
* @param manufacturer The manufacturer of the device.
*/
Device(const std::string& path, std::shared_ptr<BaseIO> io, const std::string& description, const std::string& manufacturer);
Device(const std::string& path,
std::shared_ptr<BaseIO> io,
const std::string& description,
const std::string& manufacturer);

/**
* @brief Destructor
*/
~Device();

/**
* @brief Initializes the device by creating NWB related attributes and writing the manufactor and description metadata.
* @brief Initializes the device by creating NWB related attributes and
* writing the manufactor and description metadata.
*/
void initialize();

Expand All @@ -42,7 +48,7 @@ class Device : public Container
* @return The description of the device.
*/
std::string getDescription() const;

private:
/**
* @brief The description of the device.
Expand Down
12 changes: 9 additions & 3 deletions src/file/ElectrodeGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
// ElectrodeGroup

/** Constructor */
ElectrodeGroup::ElectrodeGroup(const std::string& path, std::shared_ptr<BaseIO> io, const std::string& description, const std::string& location, const Device& device)
: Container(path, io), description(description), location(location), device(device)
ElectrodeGroup::ElectrodeGroup(const std::string& path,
std::shared_ptr<BaseIO> io,
const std::string& description,
const std::string& location,
const Device& device)
: Container(path, io)
, description(description)
, location(location)
, device(device)
{
}

Expand All @@ -16,7 +23,6 @@ void ElectrodeGroup::initialize()
io->createCommonNWBAttributes(path, "core", "ElectrodeGroup", description);
io->createAttribute(location, path, "location");
io->createLink("/" + path + "/device", "/" + device.getPath());

}

// Getter for description
Expand Down
31 changes: 20 additions & 11 deletions src/file/ElectrodeGroup.hpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
#pragma once

#include <string>

#include "device/Device.hpp"
#include "hdmf/base/Container.hpp"
#include "io/BaseIO.hpp"
#include "device/Device.hpp"

using namespace AQNWBIO;

/**
* @brief The ElectrodeGroup class represents a physical grouping of electrodes, e.g. a shank of an array.
* @brief The ElectrodeGroup class represents a physical grouping of electrodes,
* e.g. a shank of an array.
*/
class ElectrodeGroup : public Container
{
public:
/**
* @brief Constructer.
* @brief Constructor.
* @param path The location in the file of the electrode group.
* @param io A shared pointer to the IO object.
* @param description The description of the electrode group.
* @param location The location of electrode group within the subject e.g. brain region.
* @param location The location of electrode group within the subject e.g.
* brain region.
* @param device The device associated with the electrode group.
*/
ElectrodeGroup(const std::string& path, std::shared_ptr<BaseIO> io, const std::string& description, const std::string& location, const Device& device);
ElectrodeGroup(const std::string& path,
std::shared_ptr<BaseIO> io,
const std::string& description,
const std::string& location,
const Device& device);

/**
* @brief Destructor.
Expand All @@ -30,8 +37,9 @@ class ElectrodeGroup : public Container

/**
* @brief Initializes the ElectrodeGroup object.
*
* Initializes the ElectrodeGroup by creating NWB related attributes and linking to the Device object.
*
* Initializes the ElectrodeGroup by creating NWB related attributes and
* linking to the Device object.
*/
void initialize();

Expand All @@ -56,16 +64,17 @@ class ElectrodeGroup : public Container
private:
/**
* @brief The description of the electrode group.
*/
*/
std::string description;

/**
* @brief The location of electrode group within the subject e.g. brain region.
*/
* @brief The location of electrode group within the subject e.g. brain
* region.
*/
std::string location;

/**
* @brief The device associated with the electrode group.
*/
*/
Device device;
};
Loading

0 comments on commit c6e45ac

Please sign in to comment.