Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move ElectrodesTable creation #161

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Conversation

stephprince
Copy link
Collaborator

Fix #155 by moving the creation of ElectrodesTable to a separate convenience function.

As part of these changes, I added some additional tests, a helper function for getting the size of a dataset, and a check for creating ElectricalSeries with electrodes indices outside of the possible range of the ElectrodesTable.

@codecov-commenter
Copy link

codecov-commenter commented Feb 20, 2025

Codecov Report

Attention: Patch coverage is 96.15385% with 8 lines in your changes missing coverage. Please review.

Project coverage is 93.96%. Comparing base (40fe1dc) to head (e3ef713).

Files with missing lines Patch % Lines
src/nwb/NWBFile.cpp 77.77% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #161      +/-   ##
==========================================
- Coverage   93.98%   93.96%   -0.02%     
==========================================
  Files          64       64              
  Lines        4952     5118     +166     
  Branches      273      274       +1     
==========================================
+ Hits         4654     4809     +155     
- Misses        288      299      +11     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 444 to 449
/**
* @brief Returns the size of the dataset for each dimension.
* @param path The location in the file of the dataset.
* @return The dataset size.
*/
virtual std::vector<SizeType> getDatasetSize(const std::string path) = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • It would be nice to have this function support both datasets and attributes. In that case, I would rename it to getStorageObjectShape.
  • It would be nice to also add the following function to ReadDataWrapper to make this new function convenient to use on read
inline std::vector<SizeType> getShape() const
{
   return m_io->getShape(m_path);
}

- We should be consistent in how we use `shape` and `size`. I think we should use `shape` to refer to the sizes along all dimensions and `size` to refer to the total number of elements.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have this function support both datasets and attributes. In that case, I would rename it to getStorageObjectShape.
It would be nice to also add the following function to ReadDataWrapper to make this new function convenient to use on read

That makes sense, I will add functionality for attributes and use shape to refer to sizes along all dimensions

@@ -28,7 +28,7 @@ constexpr SizeType CHUNK_XSIZE =
constexpr SizeType SPIKE_CHUNK_XSIZE =
8; // TODO - replace with io settings input

std::vector<SizeType> NWBFile::emptyContainerIndexes = {};
std::vector<SizeType> NWBFile::m_emptyContainerIndexes = {};
Copy link
Contributor

@oruebel oruebel Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Types.h is a better place for this. Alternatively, it seems that m_emptyContainerIndexes is only used to set default arguments of functions, so we could be explicit and just use "std::vector()" as default argument, i.e., use:

Status createAnnotationSeries(
      std::vector<std::string> recordingNames,
      RecordingContainers* recordingContainers = nullptr,
      std::vector<SizeType>& containerIndexes = std::vector<SizeType>());

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly, I think I set this up this way because you cannot pass a temporary empty initializer list as a default argument to a non constant reference parameter. Creating the empty vector in advance was a solution for that. Another potential option is to change the parameter to an rvalue reference, but then I think there might be additional complications in terms of transferring ownership.

@stephprince
Copy link
Collaborator Author

Based on our discussion, I made containerIndexes a required argument and removed the static m_emptyContainerIndexes variable. I think recordingContainers should likely also be required as an input for the user so I removed the default value for that parameter as well.

These changes will now also fix #162, if we want to take a different approach or discuss that particular issue more I can move the changes to getStorageObjectsShape to a separate PR.

@stephprince stephprince marked this pull request as ready for review February 22, 2025 01:10
@stephprince
Copy link
Collaborator Author

@oruebel this is ready for you to re-review

@@ -14,12 +14,15 @@
* 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
* file contents.
* 4. Create the \ref AQNWB::NWB::Container "Container" objects (e.g.,
* 4. Create the recording metadata stored in ``\general`` in NWB, e.g., the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 4. Create the recording metadata stored in ``\general`` in NWB, e.g., the
* 4. Create the recording metadata stored in ``/general`` in NWB, e.g., the

Comment on lines +445 to +447
* @brief Returns the size of the dataset for each dimension.
* @param path The location in the file of the dataset.
* @return The dataset shape.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @brief Returns the size of the dataset for each dimension.
* @param path The location in the file of the dataset.
* @return The dataset shape.
* @brief Returns the size of the dataset or attribute for each dimension.
* @param path The location of the dataset or attribute in the file
* @return The shape of the dataset or attribute.

Comment on lines +271 to +275
/**
* @brief Returns the size of the dataset for each dimension.
* @param path The location in the file of the dataset.
* @return The dataset shape.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* @brief Returns the size of the dataset for each dimension.
* @param path The location in the file of the dataset.
* @return The dataset shape.
*/
* @brief Returns the size of the dataset or attribute for each dimension.
* @param path The location of the dataset or attribute in the file
* @return The shape of the dataset or attribute.

}

// write electrodes information to datasets
// (requires that ElectrodeGroup data is written)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the ElectrodeGroup data must be written, should this function then call m_io->flush() here first?

@oruebel
Copy link
Contributor

oruebel commented Feb 22, 2025

I added a couple of minor comments (mostly updates to docs), but otherwise this looks good.

Note, there will be conflicts with #163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Electrodes indices can be out of range
3 participants