From d1bc20f93c599d9d3510408afd2a5418a199d61e Mon Sep 17 00:00:00 2001 From: mavaylon1 Date: Mon, 20 May 2024 13:41:20 -0700 Subject: [PATCH] checkpoint --- .../general}/experimenter_termset.yaml | 10 +++---- docs/gallery/general/nwb_gallery_config.yaml | 13 +++++++++ docs/gallery/general/nwb_subject_termset.yaml | 27 +++++++++++++++++++ docs/gallery/general/plot_configurator.py | 24 +++++++++++------ src/pynwb/config/location_termset.yaml | 16 ----------- src/pynwb/config/nwb_config.yaml | 6 ----- tests/unit/test_config.py | 5 ++-- 7 files changed, 62 insertions(+), 39 deletions(-) rename {src/pynwb/config => docs/gallery/general}/experimenter_termset.yaml (60%) create mode 100644 docs/gallery/general/nwb_gallery_config.yaml create mode 100644 docs/gallery/general/nwb_subject_termset.yaml delete mode 100644 src/pynwb/config/location_termset.yaml diff --git a/src/pynwb/config/experimenter_termset.yaml b/docs/gallery/general/experimenter_termset.yaml similarity index 60% rename from src/pynwb/config/experimenter_termset.yaml rename to docs/gallery/general/experimenter_termset.yaml index 4f6754c51..78ed35e67 100644 --- a/src/pynwb/config/experimenter_termset.yaml +++ b/docs/gallery/general/experimenter_termset.yaml @@ -10,10 +10,8 @@ default_range: string enums: Experimenters: permissible_values: - Oliver RĂ¼bel: + Bilbo Baggins: description: He who must not be named. - meaning: ORC:0000-0001-9902-1984 - Ryan Ly: - description: The chosen one. - meaning: ORC:0000-0001-9238-0642 - \ No newline at end of file + meaning: ORC:111 + + diff --git a/docs/gallery/general/nwb_gallery_config.yaml b/docs/gallery/general/nwb_gallery_config.yaml new file mode 100644 index 000000000..97e988ae2 --- /dev/null +++ b/docs/gallery/general/nwb_gallery_config.yaml @@ -0,0 +1,13 @@ +namespaces: + core: + version: 2.7.0-alpha + data_types: + Subject: + species: + termset: nwb_subject_termset.yaml + NWBFile: + experimenter: + termset: experimenter_termset.yaml + # ElectrodeGroup: This will return when electrode table is redefined + # location: + # termset: location_termset.yaml diff --git a/docs/gallery/general/nwb_subject_termset.yaml b/docs/gallery/general/nwb_subject_termset.yaml new file mode 100644 index 000000000..e952c6776 --- /dev/null +++ b/docs/gallery/general/nwb_subject_termset.yaml @@ -0,0 +1,27 @@ +id: termset/species_example +name: Species +version: 0.0.1 +prefixes: + NCBI_TAXON: https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id= +imports: + - linkml:types +default_range: string + +enums: + Species: + permissible_values: + Homo sapiens: + description: the species is human + meaning: NCBI_TAXON:9606 + Mus musculus: + description: the species is a house mouse + meaning: NCBI_TAXON:10090 + Ursus arctos horribilis: + description: the species is a grizzly bear + meaning: NCBI_TAXON:116960 + Myrmecophaga tridactyla: + description: the species is an anteater + meaning: NCBI_TAXON:71006 + Ailuropoda melanoleuca: + description: the species is a panda + meaning: NCBI_TAXON:9646 diff --git a/docs/gallery/general/plot_configurator.py b/docs/gallery/general/plot_configurator.py index 200d3a5bf..8add07994 100644 --- a/docs/gallery/general/plot_configurator.py +++ b/docs/gallery/general/plot_configurator.py @@ -29,7 +29,7 @@ -------------------------------- Before taking advantage of the all the wonders that comes with using a configuration file, the user needs to create one following some simple guidelines. To follow along with an example, -please refer to ``nwb_config.yaml`` under ``src/config``. +please refer to ``nwb_config.yaml`` under ``src/config``. The configuration files is built on the foundation of the YAML syntax. The user will construct a series of nested dictioanries to encompass all the necessary information. @@ -44,7 +44,14 @@ import linkml_runtime # noqa: F401 except ImportError as e: raise ImportError("Please install linkml-runtime to run this example: pip install linkml-runtime") from e -from hdmf.term_set import TermSet, TermSetWrapper + +from dateutil import tz +from datetime import datetime +from uuid import uuid4 +import os + +from pynwb import NWBFile, get_loaded_type_config, load_type_config, unload_type_config +from pynwb.file import Subject # How to use a Configuration file # ------------------------------- @@ -53,12 +60,13 @@ # It is important to remember that with the configuration loaded, the fields # are wrapped automatically, meaning the user should proceed with creating # the instances normally, i.e., without wrapping directly. In this example, -# we load the the NWB curated configuration file that associates a -# :py:class:`~hdmf.term_set.TermSet` for the species field in Subject. -# The NWB configuration file is the default when you call -# :py:func:`~pynwb.load_type_config`. +# we load the a configuration file that associates a +# :py:class:`~hdmf.term_set.TermSet` for the ``species`` field in +# :py:class:`~pynwb.file.Subject`. -load_type_config() +dir_path = os.path.dirname(os.path.abspath(__file__)) +yaml_file = os.path.join(dir_path, 'nwb_gallery_config.yaml') +load_type_config(config_path=yaml_file) session_start_time = datetime(2018, 4, 25, hour=2, minute=30, second=3, tzinfo=tz.gettz("US/Pacific")) @@ -68,7 +76,7 @@ session_start_time=session_start_time, # required session_id="session_1234", # optional experimenter=[ - "Baggins, Bilbo", + "Bilbo Baggins", ], # optional lab="Bag End Laboratory", # optional institution="University of My Institution", # optional diff --git a/src/pynwb/config/location_termset.yaml b/src/pynwb/config/location_termset.yaml deleted file mode 100644 index 608cd7815..000000000 --- a/src/pynwb/config/location_termset.yaml +++ /dev/null @@ -1,16 +0,0 @@ -id: termset/location_example -name: Locations -version: 0.0.1 -prefixes: - NCI: http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl# -imports: - - linkml:types -default_range: string - -enums: - Brain Location: - permissible_values: - Amygdala: - description: A cluster of nuclei located deep and medially within each temporal lobe of the brain. - meaning: NCI:C12440 - diff --git a/src/pynwb/config/nwb_config.yaml b/src/pynwb/config/nwb_config.yaml index 97e988ae2..f7b5b8368 100644 --- a/src/pynwb/config/nwb_config.yaml +++ b/src/pynwb/config/nwb_config.yaml @@ -5,9 +5,3 @@ namespaces: Subject: species: termset: nwb_subject_termset.yaml - NWBFile: - experimenter: - termset: experimenter_termset.yaml - # ElectrodeGroup: This will return when electrode table is redefined - # location: - # termset: location_termset.yaml diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index c6f263a9f..1ebfe9dc5 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -4,7 +4,7 @@ from hdmf.term_set import TermSetWrapper -from pynwb import NWBFile,get_loaded_type_config, load_type_config, unload_type_config +from pynwb import NWBFile, get_loaded_type_config, load_type_config, unload_type_config from pynwb.file import Subject from pynwb.testing import TestCase @@ -28,8 +28,7 @@ def test_get_loaded_type_config(self): config = get_loaded_type_config() self.assertEqual(config, {'namespaces': {'core': {'version': '2.7.0-alpha', - 'data_types': {'Subject': {'species': {'termset': 'nwb_subject_termset.yaml'}}, - 'NWBFile': {'experimenter': {'termset': 'experimenter_termset.yaml'}}}}}}) + 'data_types': {'Subject': {'species': {'termset': 'nwb_subject_termset.yaml'}}}}}}) def test_default_config(self): session_start_time = datetime(2018, 4, 25, 2, 30, 3, tzinfo=tz.gettz("US/Pacific"))