Skip to content

Commit

Permalink
Add dataset to store list of software that produced a file (#1924)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Ly <[email protected]>
  • Loading branch information
stephprince and rly authored Nov 19, 2024
1 parent f05027e commit 1b46014
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

### Enhancements and minor changes
- Added support for NWB schema 2.8.0:
- Removed `SpatialSeries.bounds` field that was not functional. This will be fixed in a future release. @rly [#1907](https://github.com/NeurodataWithoutBorders/pynwb/pull/1907),
- Removed `SpatialSeries.bounds` field that was not functional. This will be fixed in a future release. @rly [#1907](https://github.com/NeurodataWithoutBorders/pynwb/pull/1907), [#1996](https://github.com/NeurodataWithoutBorders/pynwb/pull/1996)
- Added support for `NWBFile.was_generated_by` field. @stephprince [#1924](https://github.com/NeurodataWithoutBorders/pynwb/pull/1924)

## PyNWB 2.8.3 (Upcoming)

Expand Down
4 changes: 4 additions & 0 deletions src/pynwb/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ class NWBFile(MultiContainerInterface, HERDManager):
'slices',
'source_script',
'source_script_file_name',
'was_generated_by',
'data_collection',
'surgery',
'virus',
Expand Down Expand Up @@ -339,6 +340,8 @@ class NWBFile(MultiContainerInterface, HERDManager):
'doc': 'Script file used to create this NWB file.', 'default': None},
{'name': 'source_script_file_name', 'type': str,
'doc': 'Name of the source_script file', 'default': None},
{'name': 'was_generated_by', 'type': 'array_data',
'doc': 'List of software package names and versions used to generate this NWB File.', 'default': None},
{'name': 'data_collection', 'type': str,
'doc': 'Notes about data collection and analysis.', 'default': None},
{'name': 'surgery', 'type': str,
Expand Down Expand Up @@ -448,6 +451,7 @@ def __init__(self, **kwargs):
'slices',
'source_script',
'source_script_file_name',
'was_generated_by',
'surgery',
'virus',
'stimulus_notes',
Expand Down
1 change: 1 addition & 0 deletions src/pynwb/io/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def __init__(self, spec):
'session_id',
'slices',
'source_script',
'was_generated_by',
'stimulus',
'surgery',
'virus']
Expand Down
28 changes: 28 additions & 0 deletions tests/integration/hdf5/test_nwbfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def setUp(self):
session_id='007',
slices='noslices',
source_script='nosources',
was_generated_by=[('nosoftware', '0.0.0')],
surgery='nosurgery',
virus='novirus',
source_script_file_name='nofilename')
Expand Down Expand Up @@ -128,6 +129,7 @@ def build_nwbfile(self):
virus='a virus',
source_script='noscript',
source_script_file_name='nofilename',
was_generated_by=[('nosoftware', '0.0.0')],
stimulus_notes='test stimulus notes',
data_collection='test data collection notes',
keywords=('these', 'are', 'keywords'))
Expand Down Expand Up @@ -176,6 +178,32 @@ def build_nwbfile(self):
self.nwbfile.experimenter = ('experimenter1', 'experimenter2')


class TestWasGeneratedByConstructorRoundtrip(TestNWBFileIO):
""" Test that a list of software packages / versions in a constructor is written to and read from file """

def build_nwbfile(self):
description = 'test nwbfile was_generated_by'
identifier = 'TEST_was_generated_by'
self.nwbfile = NWBFile(session_description=description,
identifier=identifier,
session_start_time=self.start_time,
was_generated_by=[('software1', '0.1.0'),
('software2', '0.2.0'),
('software3', '0.3.0')],)

class TestWasGeneratedBySetterRoundtrip(TestNWBFileIO):
""" Test that a single tuple of software versions packages in a setter is written to and read from file """

def build_nwbfile(self):
description = 'test nwbfile was_generated_by'
identifier = 'TEST_was_generated_by'
self.nwbfile = NWBFile(session_description=description,
identifier=identifier,
session_start_time=self.start_time)
self.nwbfile.was_generated_by = [('software1', '0.1.0'),
('software2', '0.2.0'),
('software3', '0.3.0')]

class TestPublicationsConstructorRoundtrip(TestNWBFileIO):
""" Test that a list of multiple publications in a constructor is written to and read from file """

Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def setUp(self):
virus='a virus',
source_script='noscript',
source_script_file_name='nofilename',
was_generated_by=[('nosoftware', '0.0.0')],
stimulus_notes='test stimulus notes',
data_collection='test data collection notes',
keywords=('these', 'are', 'keywords'))
Expand All @@ -61,6 +62,7 @@ def test_constructor(self):
self.assertEqual(self.nwbfile.related_publications, ('my pubs',))
self.assertEqual(self.nwbfile.source_script, 'noscript')
self.assertEqual(self.nwbfile.source_script_file_name, 'nofilename')
self.assertEqual(self.nwbfile.was_generated_by, [('nosoftware', '0.0.0')])
self.assertEqual(self.nwbfile.keywords, ('these', 'are', 'keywords'))
self.assertEqual(self.nwbfile.timestamps_reference_time, self.ref_time)

Expand Down

0 comments on commit 1b46014

Please sign in to comment.