From 94f8e964200fb16e7b8c808af1897385a4501bed Mon Sep 17 00:00:00 2001 From: Neha Thomas Date: Tue, 2 Sep 2025 16:07:31 -0400 Subject: [PATCH 1/3] Add new catalog entry for ndx-multisubjects --- ndx-multisubjects/README.md | 119 ++++++++++++++++++++++++++++++++ ndx-multisubjects/ndx-meta.yaml | 8 +++ 2 files changed, 127 insertions(+) create mode 100644 ndx-multisubjects/README.md create mode 100644 ndx-multisubjects/ndx-meta.yaml diff --git a/ndx-multisubjects/README.md b/ndx-multisubjects/README.md new file mode 100644 index 0000000..5832c48 --- /dev/null +++ b/ndx-multisubjects/README.md @@ -0,0 +1,119 @@ +# ndx-miniscope Extension for NWB:N + +# ndx-multisubjects Extension for NWB + +Allow for multiple subjects to be represented in a single nwb file. This is for experiments where subjects are being recorded at the same time in the same session. + +## Installation + + +## Usage + +First create an NWB file: + +```python +# CREATE NWB FILE +nwbfile = NdxMultiSubjectsNWBFile( + session_description = "test multi subjects", + identifier = str(uuid4()), + session_start_time = datetime.now(tz=timezone.utc)) +``` + + +Next, add the subjects table and populate the subjects' metadata by using `.add_row` +```python +# ADD SUBJECTS TABLE + + subjects_table = SubjectsTable( + + description="description", + + ) + +subjects_table.add_row( + age="P70D", + + subject_description="Test subject", + genotype="WT", + sex = "M", + species="Mus musculus", + strain="C57BL/6", + subject_id="subject_001", + weight="20g", + individual_subj_link="relfilepath/subj_001.nwb" +) + +subjects_table.add_row( + age="P30D", + + subject_description="Test subject2", + genotype="WT", + sex = "F", + species="Mus musculus", + strain="C57BL/6", + subject_id="subject_003", + weight="25g", + individual_subj_link="relfilepath/subj_003.nwb" +) + +subjects_table.add_row( + age="P42D", + + subject_description="Test subject5", + genotype="WT", + sex = "F", + species="Mus musculus", + strain="C57BL/6", + subject_id="subject_005", + weight="25g", + individual_subj_link="relfilepath/subj_005.nwb" +) +``` +Add the subjects table to the NWB file with `nwbfile.add_acquisition(subjects_table)` +In the future, this should be fixed so that the table can be added into the general section of the NWB file. + +To add data that is specific to a selection of the subjects (less than the total number of subjects), use a SelectsSubjectsContainer as shown below: + +```python + # ADD SELECTSUBJECTSCONTAINER + + + subjects = DynamicTableRegion( + name="subjects", + description="A DynamicTableRegion that selects the subjects from the SubjectsTable that are included in this container.", + table=subjects_table, + data=[0, 1] # Select both subjects + ) + + dummyTimeSeries = TimeSeries( + name="dummy_time_series", + data=np.random.rand(100), + unit="mV", + timestamps=np.arange(100) * 0.1, + ) + subjects_container = SelectSubjectsContainer( + subjects = subjects, + name = 'Interaction Subjects' + + + + ) + + subjects_container.add_nwb_data_interfaces(dummyTimeSeries) + + module = nwbfile.create_processing_module( + name='Behavior', + description='Processing module for subjects data' + ) + + module.add(subjects_container) + + nwbfile + + +``` + +--- +This extension was created using [ndx-template](https://github.com/nwb-extensions/ndx-template). + + diff --git a/ndx-multisubjects/ndx-meta.yaml b/ndx-multisubjects/ndx-meta.yaml new file mode 100644 index 0000000..8ac0a2d --- /dev/null +++ b/ndx-multisubjects/ndx-meta.yaml @@ -0,0 +1,8 @@ +name: ndx-multisubjects +version: 0.1.0 +src: https://github.com/nehatk17/ndx-multisubjects +pip: +license: BSD +maintainers: + - rly, nehatk17 + From 6d1241b8ece76ed230d025f5586d364ae5d9eac4 Mon Sep 17 00:00:00 2001 From: Ryan Ly Date: Tue, 2 Sep 2025 14:09:42 -0700 Subject: [PATCH 2/3] Update maintainers list format in ndx-meta.yaml --- ndx-multisubjects/ndx-meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ndx-multisubjects/ndx-meta.yaml b/ndx-multisubjects/ndx-meta.yaml index 8ac0a2d..9101b93 100644 --- a/ndx-multisubjects/ndx-meta.yaml +++ b/ndx-multisubjects/ndx-meta.yaml @@ -4,5 +4,5 @@ src: https://github.com/nehatk17/ndx-multisubjects pip: license: BSD maintainers: - - rly, nehatk17 - + - rly + - nehatk17 From 659508e93fff2692223bc0de53459924e9210c27 Mon Sep 17 00:00:00 2001 From: Ryan Ly Date: Tue, 2 Sep 2025 14:10:00 -0700 Subject: [PATCH 3/3] Update ndx-multisubjects/README.md --- ndx-multisubjects/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/ndx-multisubjects/README.md b/ndx-multisubjects/README.md index 5832c48..64cac76 100644 --- a/ndx-multisubjects/README.md +++ b/ndx-multisubjects/README.md @@ -1,5 +1,3 @@ -# ndx-miniscope Extension for NWB:N - # ndx-multisubjects Extension for NWB Allow for multiple subjects to be represented in a single nwb file. This is for experiments where subjects are being recorded at the same time in the same session.