Skip to content

Commit

Permalink
Update member variable names to avoid shadowing (#102)
Browse files Browse the repository at this point in the history
* Update Channel.hpp/cpp to avoid shadowing

* Fix formatting

* Update names in RecordingContainers

* Update members in NWBFile

* Update members in Container

* Fix formatting

* Update members in Data.hpp

* Update member in HDF5RecordingData

* Update members in BaseIO and HDF5IO

* Update members in VectorData

* Fix formatting

* Fix ubuntu build error

* Fix Doxygen built errors

* Replace this->m_ with just m_

* Update src/nwb/ecephys/SpikeEventSeries.hpp

Co-authored-by: Steph Prince <[email protected]>

* Remove setters from channel

* Make simple getters in BaseIO in the header and remove redundant override of getFilename in HDF5IO

* Fix formatting

* Make simple getter for HDF5RecordingData inline

* Make simple getter for RecordingContainers inline

* replace this->m_ with just m_

* Move simple setters for DynamicTable and remove redundant definitions with ElectrodeTable

* fix formatting

* Fix formatting

* Move VectorData getters

* Fix hidden ElectrodeTable.colNames member and bad init

---------

Co-authored-by: Steph Prince <[email protected]>
  • Loading branch information
oruebel and stephprince authored Sep 20, 2024
1 parent 5c37c40 commit 33e3481
Show file tree
Hide file tree
Showing 27 changed files with 472 additions and 420 deletions.
82 changes: 41 additions & 41 deletions docs/pages/userdocs/workflow.dox
Original file line number Diff line number Diff line change
Expand Up @@ -8,94 +8,94 @@
* For users wanting to integrate NWB with a particular data acquisition software, here
* we outline the steps for a single recording from file creation to saving.
*
* 1. Create the I/O object (e.g,. \ref AQNWB::HDF5::HDF5IO "HDF5IO") used for
* 1. Create the I/O object (e.g,. \ref AQNWB::HDF5::HDF5IO "HDF5IO") used for
* writing data to the file on disk.
* 2. Create the \ref AQNWB::NWB::RecordingContainers "RecordingContainers" object
* 2. Create the \ref AQNWB::NWB::RecordingContainers "RecordingContainers" object
* used for managing \ref AQNWB::NWB::Container "Container" objects for storing recordings.
* 3. Create the \ref AQNWB::NWB::NWBFile "NWBFile" object used for managing and creating NWB
* 3. Create the \ref AQNWB::NWB::NWBFile "NWBFile" object used for managing and creating NWB
* file contents.
* 4. Create the \ref AQNWB::NWB::Container "Container" objects (e.g.,
* \ref AQNWB::NWB::ElectricalSeries "ElectricalSeries") used for recording and add them
* 4. Create the \ref AQNWB::NWB::Container "Container" objects (e.g.,
* \ref AQNWB::NWB::ElectricalSeries "ElectricalSeries") used for recording and add them
* to the \ref AQNWB::NWB::RecordingContainers "RecordingContainers".
* 5. Start the recording.
* 6. Write data.
* 7. Stop the recording and close the \ref AQNWB::NWB::NWBFile "NWBFile".
*
*
* Below, we walk through these steps in more detail.
*
*
*
*
* \subsection create_io 1. Create the I/O object.
*
* First, create an I/O object (e.g., \ref AQNWB::HDF5::HDF5IO "HDF5IO") used for writing
*
* First, create an I/O object (e.g., \ref AQNWB::HDF5::HDF5IO "HDF5IO") used for writing
* data to the file. AqNWB provides the convenience method, \ref AQNWB::createIO "createIO"
* to create this object using one of the supported backends. For more fine-grained
* control of different backend parameters, you can create your own `std::shared_ptr`
* control of different backend parameters, you can create your own `std::shared_ptr`
* using any of the derived \ref AQNWB::BaseIO "BaseIO" classes.
*
*
* \snippet tests/examples/testWorkflowExamples.cpp example_workflow_io_snippet
*
*
* \subsection create_recording_container 2. Create the RecordingContainer object.
*
* Next, create a \ref AQNWB::NWB::RecordingContainers "RecordingContainers" object to manage the
* different \ref AQNWB::NWB::Container "Container" objects with the datasets that you would
*
* Next, create a \ref AQNWB::NWB::RecordingContainers "RecordingContainers" object to manage the
* different \ref AQNWB::NWB::Container "Container" objects with the datasets that you would
* like to write data to.
*
*
* \snippet tests/examples/testWorkflowExamples.cpp example_workflow_recording_containers_snippet
*
*
*
* \subsection create_nwbfile 3. Create the NWBFile
*
* Next, constructs the \ref AQNWB::NWB::NWBFile "NWBFile" object, using the I/O object as an input.
*
* Next, constructs the \ref AQNWB::NWB::NWBFile "NWBFile" object, using the I/O object as an input.
* Then, initialize the object to create the basic file structure of the NWBFile.
*
* \snippet tests/examples/testWorkflowExamples.cpp example_workflow_nwbfile_snippet
*
*
*
* \subsection create_datasets 4. Create datasets and add to RecordingContainers.
*
* Next, create the different data types (e.g. \ref AQNWB::NWB::ElectricalSeries "ElectricalSeries"
* or other AQNWB::NWB::TimeSeries "TimeSeries") that you would like to write data into. After
* creation, these objects are added to the \ref AQNWB::NWB::RecordingContainers "RecordingContainers"
* object so that it can mana ge access and data writing during the recording process.
* When adding containers, ownership of the \ref AQNWB::NWB::Container "Container" is transferred to the
* \ref AQNWB::NWB::RecordingContainers "RecordingContainers" object, so that we can access it again via
* its index. New containers will always be appended to the end of the
* \ref AQNWB::NWB::RecordingContainers::containers "containers" object and their index can be tracked
* using the size of the input `recordingArrays`.
*
* Next, create the different data types (e.g. \ref AQNWB::NWB::ElectricalSeries "ElectricalSeries"
* or other AQNWB::NWB::TimeSeries "TimeSeries") that you would like to write data into. After
* creation, these objects are added to the \ref AQNWB::NWB::RecordingContainers "RecordingContainers"
* object so that it can mana ge access and data writing during the recording process.
* When adding containers, ownership of the \ref AQNWB::NWB::Container "Container" is transferred to the
* \ref AQNWB::NWB::RecordingContainers "RecordingContainers" object, so that we can access it again via
* its index. New containers will always be appended to the end of the private member
* ``RecordingContainers.m_containers` object and their index can be tracked
* using the \ref AQNWB::NWB::RecordingContainers::size "RecordingContainers.size" of the input `recordingArrays`.
*
* \snippet tests/examples/testWorkflowExamples.cpp example_workflow_datasets_snippet
*
*
* \subsection start_recording 5. Start the recording.
*
* Then, start the recording process with a call to the ``startRecording`` function of the I/O object.
* Then, start the recording process with a call to the ``startRecording`` function of the I/O object.
*
* \note
* When using \ref AQNWB::HDF5::HDF5IO "HDF5IO" for writing to HDF5, calling
* \note
* When using \ref AQNWB::HDF5::HDF5IO "HDF5IO" for writing to HDF5, calling
* \ref AQNWB::HDF5::HDF5IO::startRecording "startRecording" will by default enable
* \ref hdf5io_swmr "SWMR mode" to ensure file integrity and support concurrent read.
* \ref hdf5io_swmr "SWMR mode" to ensure file integrity and support concurrent read.
* As a result, no additional datasets or groups can be added to the file once a recording
* has been started unless the file is is closed and reopened.
*
* \snippet tests/examples/testWorkflowExamples.cpp example_workflow_start_snippet
*
*
*
* \subsection write_data 6. Write data.
*
* During the recording process, use the \ref AQNWB::NWB::RecordingContainers "RecordingContainers"
* as an interface to access the various \ref AQNWB::NWB::Container "Container" object and corresponding
* datasets and write blocks of data to the file. Calling `flush()` on the I/O object at any time will
* During the recording process, use the \ref AQNWB::NWB::RecordingContainers "RecordingContainers"
* as an interface to access the various \ref AQNWB::NWB::Container "Container" object and corresponding
* datasets and write blocks of data to the file. Calling `flush()` on the I/O object at any time will
* ensure the data is moved to disk.
*
*
* \snippet tests/examples/testWorkflowExamples.cpp example_workflow_write_snippet
*
*
*
* \subsection stop_recording 7. Stop the recording and finalize the file.
*
* When the recording process is finished, call `stopRecording` from the I/O object
* to flush any data and close the file.
*
*
* \snippet tests/examples/testWorkflowExamples.cpp example_workflow_stop_snippet
*
*
Expand Down
22 changes: 4 additions & 18 deletions src/BaseIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,15 @@ const BaseDataType BaseDataType::DSTR = BaseDataType(T_STR, DEFAULT_STR_SIZE);

// BaseIO

BaseIO::BaseIO()
: readyToOpen(true)
, opened(false)
BaseIO::BaseIO(const std::string& filename)
: m_filename(filename)
, m_readyToOpen(true)
, m_opened(false)
{
}

BaseIO::~BaseIO() {}

bool BaseIO::isOpen() const
{
return opened;
}

bool BaseIO::isReadyToOpen() const
{
return readyToOpen;
}

bool BaseIO::canModifyObjects()
{
return true;
}

Status BaseIO::createCommonNWBAttributes(const std::string& path,
const std::string& objectNamespace,
const std::string& neurodataType,
Expand Down
18 changes: 9 additions & 9 deletions src/BaseIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class BaseIO
/**
* @brief Constructor for the BaseIO class.
*/
BaseIO();
BaseIO(const std::string& filename);

/**
* @brief Copy constructor is deleted to prevent construction-copying.
Expand All @@ -115,7 +115,7 @@ class BaseIO
* @brief Returns the full path to the file.
* @return The full path to the file.
*/
virtual std::string getFileName() = 0;
virtual std::string getFileName() const { return m_filename; }

/**
* @brief Opens the file for writing.
Expand Down Expand Up @@ -267,7 +267,7 @@ class BaseIO
* override this function to check if objects can be modified.
* @return True if the file is in a modification mode, false otherwise.
*/
virtual bool canModifyObjects();
virtual bool canModifyObjects() { return true; }

/**
* @brief Creates an extendable dataset with a given base data type, size,
Expand Down Expand Up @@ -338,20 +338,20 @@ class BaseIO
* @brief Returns true if the file is open.
* @return True if the file is open, false otherwise.
*/
bool isOpen() const;
inline bool isOpen() const { return m_opened; }

/**
* @brief Returns true if the file is able to be opened.
* @return True if the file is able to be opened, false otherwise.
*/
bool isReadyToOpen() const;
inline bool isReadyToOpen() const { return m_readyToOpen; }

protected:
/**
* @brief The name of the file.
*/
const std::string filename;
const std::string m_filename;

protected:
/**
* @brief Creates a new group if it does not already exist.
* @param path The location of the group in the file.
Expand All @@ -362,12 +362,12 @@ class BaseIO
/**
* @brief Whether the file is ready to be opened.
*/
bool readyToOpen;
bool m_readyToOpen;

/**
* @brief Whether the file is currently open.
*/
bool opened;
bool m_opened;
};

/**
Expand Down
35 changes: 10 additions & 25 deletions src/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,17 @@ Channel::Channel(const std::string name,
const float bitVolts,
const std::array<float, 3> position,
const std::string comments)
: name(name)
, groupName(groupName)
, groupIndex(groupIndex)
, localIndex(localIndex)
, globalIndex(globalIndex)
, position(position)
, conversion(conversion)
, samplingRate(samplingRate)
, bitVolts(bitVolts)
, comments(comments)
: m_name(name)
, m_groupName(groupName)
, m_groupIndex(groupIndex)
, m_localIndex(localIndex)
, m_globalIndex(globalIndex)
, m_position(position)
, m_conversion(conversion)
, m_samplingRate(samplingRate)
, m_bitVolts(bitVolts)
, m_comments(comments)
{
}

Channel::~Channel() {}

float Channel::getConversion() const
{
return bitVolts / conversion;
}

float Channel::getSamplingRate() const
{
return samplingRate;
}

float Channel::getBitVolts() const
{
return bitVolts;
}
Loading

0 comments on commit 33e3481

Please sign in to comment.