Skip to content

Commit fef8824

Browse files
Merge pull request #54 from SilverLabUCL/usage-docs-for-metadata
update usage docs to cover creating from metadata
2 parents cfd91b0 + 04a2b86 commit fef8824

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

docs/usage.rst

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Usage
33
=====
44

55

6-
Two main programs are provided: ``labview2nwb`` and ``nwb_metadata_editor``.
6+
Three main programs are provided: ``labview2nwb``, ``metadata2nwb`` and ``nwb_metadata_editor``.
77

88
``labview2nwb`` imports Labview data to the NWB format.
99
You need to provide it the path to the NWB file to create,
@@ -19,6 +19,17 @@ By default the import process will start by running a simple graphical editor,
1919
allowing you to input metadata required or recommended by the NWB format,
2020
but that is not available within the Labview data folder.
2121

22+
``metadata2nwb`` creates a minimal NWB file by loading metadata describing
23+
an experiment from a YAML file. You need to provide it the path to the NWB file
24+
to create, the path to the metadata YAML file and optionally a user.
25+
The user must be mentioned in the metadata file. If there is only one user in the file,
26+
you don't need to specify them when running this. An example for a metadata YAML file
27+
can be found on the `PySilverLabNWB Github directory`__. Metadata YAML files are intended
28+
to be created, read and modified by users to quickly set up a new NWB file without
29+
having to go via the metadata editor.
30+
31+
__ https://github.com/SilverLabUCL/PySilverLabNWB/blob/master/tests/data/meta_two_users.yaml
32+
2233
``nwb_metadata_editor`` runs the metadata editor in standalone mode.
2334
It is useful for setting up details of new researchers or new experiments,
2435
that can then be used quickly when importing experiment data.
@@ -28,16 +39,23 @@ Python library usage
2839
====================
2940

3041
The main class is ``silverlabnwb.NwbFile`` defined in ``nwb_file.py``.
31-
All its methods are documented with docstrings.
42+
All its methods are documented with docstrings. There are two entry points,
43+
``import_labview_folder`` and ``create_from_metadata``, which mirror the first
44+
two command line tools described above.
3245

3346
Quick examples::
3447

3548
from silverlabnwb import NwbFile
3649

37-
# Write a new file
50+
# Write a new file from a LabView folder
3851
with NwbFile(nwb_path, mode='w') as nwb:
3952
nwb.import_labview_folder(labview_path)
4053

54+
# Write a new file from metadata
55+
with NwbFile(nwb_path, mode='w') as nwb:
56+
nwb.create_from_metadata(metadata_path, user)
57+
4158
# Read an existing file
4259
with NwbFile(nwb_path) as nwb:
4360
print('Opened NWB with ID {}'.format(nwb['/identifier']))
61+

src/silverlabnwb/nwb_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def import_labview_folder(self, folder_path, compress=True):
102102
self.import_labview_data(folder_path, folder_name, speed_data, expt_start_time)
103103
self.log('All data imported')
104104

105-
def create_from_metadata(self, metadata_file, user=None, session_id=None):
105+
def create_from_metadata(self, metadata_file, user=None):
106106
"""Create a base NWB file containing only experimental metadata."""
107107
assert self.nwb_open_mode == 'w', ("Can only create a file if opening "
108108
"in 'w' mode")

0 commit comments

Comments
 (0)