From 2dcc091a077dc858334e04706b2db93c51078be8 Mon Sep 17 00:00:00 2001 From: mavaylon1 Date: Tue, 9 Apr 2024 19:32:09 -0700 Subject: [PATCH] checkpoint passing --- docs/gallery/general/plot_configurator.py | 152 +++++++------- docs/gallery/general/plot_termset.py | 229 +++++++++++----------- tests/unit/test_config.py | 6 +- 3 files changed, 192 insertions(+), 195 deletions(-) diff --git a/docs/gallery/general/plot_configurator.py b/docs/gallery/general/plot_configurator.py index 899b8f68e..fa96eeaf9 100644 --- a/docs/gallery/general/plot_configurator.py +++ b/docs/gallery/general/plot_configurator.py @@ -1,75 +1,19 @@ -from datetime import datetime -from uuid import uuid4 -from hdmf.term_set import TermSetWrapper, TermSet - -import numpy as np -from dateutil import tz - -from pynwb import NWBHDF5IO, NWBFile -from pynwb.behavior import Position, SpatialSeries -from pynwb.file import Subject -from pynwb import unload_type_config, load_type_config - -load_type_config() -session_start_time = datetime(2018, 4, 25, 2, 30, 3, tzinfo=tz.gettz("US/Pacific")) -terms = TermSet(term_schema_path='/Users/mavaylon/Research/NWB/hdmf/docs/gallery/example_term_set.yaml') +# from datetime import datetime +# from uuid import uuid4 +# from hdmf.term_set import TermSetWrapper, TermSet # -nwbfile = NWBFile( - session_description="Mouse exploring an open field", # required - identifier=str(uuid4()), # required - session_start_time=session_start_time, # required - session_id="session_1234", # optional - experimenter=[ - "Ryan Ly", - ], # optional - lab="Bag End Laboratory", # optional - institution="University of My Institution", # optional - experiment_description="I went on an adventure to reclaim vast treasures.", # optional - related_publications="DOI:10.1016/j.neuron.2016.12.011", # optional -) -subject = Subject( - subject_id="01", - age="One shouldn't ask", - description="A human.", - species="Homo sapiens", - sex="M", -) - -nwbfile.subject = subject - -device = nwbfile.create_device( - name="array", description="the best array", manufacturer="Probe Company 9000" -) - -nwbfile.add_electrode_column(name="label", description="label of electrode") - -nshanks = 4 -nchannels_per_shank = 3 -electrode_counter = 0 - -for ishank in range(nshanks): - # create an electrode group for this shank - electrode_group = nwbfile.create_electrode_group( - name="shank{}".format(ishank), - description="electrode group for shank {}".format(ishank), - device=device, - location='Amygdala' - ) - # add electrodes to the electrode table - for ielec in range(nchannels_per_shank): - nwbfile.add_electrode( - group=electrode_group, - label="shank{}elec{}".format(ishank, ielec), - location='Amygdala' - ) - electrode_counter += 1 - -breakpoint() -# # nwbfile.subject = subject -# # breakpoint() -# unload_type_config() -# load_type_config() +# import numpy as np +# from dateutil import tz # +# from pynwb import NWBHDF5IO, NWBFile +# from pynwb.behavior import Position, SpatialSeries +# from pynwb.file import Subject +# from pynwb import unload_type_config, load_type_config +# +# load_type_config() +# session_start_time = datetime(2018, 4, 25, 2, 30, 3, tzinfo=tz.gettz("US/Pacific")) +# terms = TermSet(term_schema_path='/Users/mavaylon/Research/NWB/hdmf/docs/gallery/example_term_set.yaml') +# # # nwbfile = NWBFile( # session_description="Mouse exploring an open field", # required # identifier=str(uuid4()), # required @@ -83,13 +27,69 @@ # experiment_description="I went on an adventure to reclaim vast treasures.", # optional # related_publications="DOI:10.1016/j.neuron.2016.12.011", # optional # ) -# -# # subject = Subject( -# subject_id="001", -# age="P90D", -# description="mouse 5", -# species="Mus musculus", +# subject_id="01", +# age="One shouldn't ask", +# description="A human.", +# species="Homo sapiens", # sex="M", # ) +# +# nwbfile.subject = subject +# +# device = nwbfile.create_device( +# name="array", description="the best array", manufacturer="Probe Company 9000" +# ) +# +# nwbfile.add_electrode_column(name="label", description="label of electrode") +# +# nshanks = 4 +# nchannels_per_shank = 3 +# electrode_counter = 0 +# +# for ishank in range(nshanks): +# # create an electrode group for this shank +# electrode_group = nwbfile.create_electrode_group( +# name="shank{}".format(ishank), +# description="electrode group for shank {}".format(ishank), +# device=device, +# location='Amygdala' +# ) +# # add electrodes to the electrode table +# for ielec in range(nchannels_per_shank): +# nwbfile.add_electrode( +# group=electrode_group, +# label="shank{}elec{}".format(ishank, ielec), +# location='Amygdala' +# ) +# electrode_counter += 1 +# # breakpoint() +# # # nwbfile.subject = subject +# # # breakpoint() +# # unload_type_config() +# # load_type_config() +# # +# # nwbfile = NWBFile( +# # session_description="Mouse exploring an open field", # required +# # identifier=str(uuid4()), # required +# # session_start_time=session_start_time, # required +# # session_id="session_1234", # optional +# # experimenter=[ +# # "Ryan Ly", +# # ], # optional +# # lab="Bag End Laboratory", # optional +# # institution="University of My Institution", # optional +# # experiment_description="I went on an adventure to reclaim vast treasures.", # optional +# # related_publications="DOI:10.1016/j.neuron.2016.12.011", # optional +# # ) +# # +# # +# # subject = Subject( +# # subject_id="001", +# # age="P90D", +# # description="mouse 5", +# # species="Mus musculus", +# # sex="M", +# # ) +# # breakpoint() diff --git a/docs/gallery/general/plot_termset.py b/docs/gallery/general/plot_termset.py index 98c860556..7fe883047 100644 --- a/docs/gallery/general/plot_termset.py +++ b/docs/gallery/general/plot_termset.py @@ -1,124 +1,71 @@ -from hdmf.term_set import TermSet, TermSetWrapper -from pynwb.resources import HERD -from pynwb import NWBHDF5IO, NWBFile -from glob import glob -from tqdm import tqdm -from dandi.dandiapi import DandiAPIClient -import fsspec -from fsspec.implementations.cached import CachingFileSystem -import h5py -import pynwb -from pynwb.file import Subject - -from hdmf.common import VectorData - -from datetime import datetime -from dateutil import tz -import yaml - -from datetime import datetime -from uuid import uuid4 - -import numpy as np -from dateutil.tz import tzlocal - -from pynwb import NWBHDF5IO, NWBFile, get_type_map -from pynwb.file import ElectrodeTable -from pynwb.ecephys import LFP, ElectricalSeries - -from pynwb import unload_termset_config, load_termset_config, get_loaded_config - -experimenter_termset = TermSet(term_schema_path='/Users/mavaylon/Research/NWB/pynwb/src/pynwb/config/experimenter_termset.yaml') -location_termset = TermSet(term_schema_path='/Users/mavaylon/Research/NWB/pynwb/src/pynwb/config/location_termset.yaml') -species_termset = TermSet(term_schema_path='/Users/mavaylon/Research/NWB/pynwb/src/pynwb/config/nwb_subject_termset.yaml') - -# et = ElectrodeTable() +# from hdmf.term_set import TermSet, TermSetWrapper +# from pynwb.resources import HERD +# from pynwb import NWBHDF5IO, NWBFile +# from glob import glob +# from tqdm import tqdm +# from dandi.dandiapi import DandiAPIClient +# import fsspec +# from fsspec.implementations.cached import CachingFileSystem +# import h5py +# import pynwb +# from pynwb.file import Subject +# +# from hdmf.common import VectorData +# +# from datetime import datetime +# from dateutil import tz +# import yaml +# +# from datetime import datetime +# from uuid import uuid4 +# +# import numpy as np +# from dateutil.tz import tzlocal +# +# from pynwb import NWBHDF5IO, NWBFile, get_type_map +# from pynwb.file import ElectrodeTable +# from pynwb.ecephys import LFP, ElectricalSeries +# +# from pynwb import unload_termset_config, load_termset_config, get_loaded_config +# +# experimenter_termset = ... +# location_termset = ... +# species_termset = ... +# # et = ElectrodeTable() +# # breakpoint() +# # # tm=get_type_map() +# # cc=get_loaded_config() +# # breakpoint() +# # unload_termset_config() +# # cc2=get_loaded_config() +# # +# load_termset_config() +# cc2=get_loaded_config() # breakpoint() -# # tm=get_type_map() -# cc=get_loaded_config() +# load_termset_config('/Users/mavaylon/Research/NWB/hdmf2/hdmf/tests/unit/test_extension_config.yaml') +# cc3=get_loaded_config() +# # breakpoint() -# unload_termset_config() -# cc2=get_loaded_config() # -load_termset_config() -cc2=get_loaded_config() -breakpoint() -load_termset_config('/Users/mavaylon/Research/NWB/hdmf2/hdmf/tests/unit/test_extension_config.yaml') -cc3=get_loaded_config() - -breakpoint() - -tm=get_type_map() -location_termset = TermSet(term_schema_path='/Users/mavaylon/Research/NWB/pynwb/docs/gallery/general/location_termset.yaml') - - -# Example with Electrophys location, with species, with orcid - -nwbfile = NWBFile( - session_description="my first synthetic recording", - identifier=str(uuid4()), - session_start_time=datetime.now(tzlocal()), - experimenter=[ - "Ryan Ly", - ], - lab="Bag End Laboratory", - institution="University of Middle Earth at the Shire", - experiment_description="I went on an adventure to reclaim vast treasures.", - session_id="LONELYMTN001", -) - -device = nwbfile.create_device( - name="array", description="the best array", manufacturer="Probe Company 9000" -) - -nwbfile.add_electrode_column(name="label", description="label of electrode") - -nshanks = 4 -nchannels_per_shank = 3 -electrode_counter = 0 - -for ishank in range(nshanks): - # create an electrode group for this shank - electrode_group = nwbfile.create_electrode_group( - name="shank{}".format(ishank), - description="electrode group for shank {}".format(ishank), - device=device, - location='Amygdala', - ) - # add electrodes to the electrode table - for ielec in range(nchannels_per_shank): - nwbfile.add_electrode( - group=electrode_group, - label="shank{}elec{}".format(ishank, ielec), - location='Amygdala', - ) - electrode_counter += 1 - -nwbfile.electrodes.to_dataframe() -breakpoint() - -# Example with Electrophys location, with species, with orcid - +# tm=get_type_map() +# location_termset =... +# +# +# # Example with Electrophys location, with species, with orcid +# # nwbfile = NWBFile( # session_description="my first synthetic recording", # identifier=str(uuid4()), # session_start_time=datetime.now(tzlocal()), -# experimenter=TermSetWrapper(value=['Oliver Rübel', 'Ryan Ly'], termset=experimenter_termset), +# experimenter=[ +# "Ryan Ly", +# ], # lab="Bag End Laboratory", # institution="University of Middle Earth at the Shire", # experiment_description="I went on an adventure to reclaim vast treasures.", # session_id="LONELYMTN001", # ) # -# subject = Subject( -# subject_id="01", -# age="One shouldn't ask", -# description="A human.", -# species=TermSetWrapper(value="Homo sapiens", termset=species_termset), -# sex="M", -# ) -# -# nwbfile.subject = subject # device = nwbfile.create_device( # name="array", description="the best array", manufacturer="Probe Company 9000" # ) @@ -135,20 +82,72 @@ # name="shank{}".format(ishank), # description="electrode group for shank {}".format(ishank), # device=device, -# location=TermSetWrapper(value='Amygdala', termset=location_termset), +# location='Amygdala', # ) # # add electrodes to the electrode table # for ielec in range(nchannels_per_shank): # nwbfile.add_electrode( # group=electrode_group, # label="shank{}elec{}".format(ishank, ielec), -# location='Amygdala' +# location='Amygdala', # ) # electrode_counter += 1 +# +# nwbfile.electrodes.to_dataframe() # breakpoint() -# with NWBHDF5IO("basics_tutorial.nwb",herd_path='./HERD.zip', mode= "w") as io: -# io.write(nwbfile) # -# # Automatically writes HERD using TermSetWrapper as the flag. -# with NWBHDF5IO("basics_tutorial.nwb",herd_path='HERD.zip', mode="r") as io: -# read_nwbfile = io.read() +# # Example with Electrophys location, with species, with orcid +# +# # nwbfile = NWBFile( +# # session_description="my first synthetic recording", +# # identifier=str(uuid4()), +# # session_start_time=datetime.now(tzlocal()), +# # experimenter=TermSetWrapper(value=['Oliver Rübel', 'Ryan Ly'], termset=experimenter_termset), +# # lab="Bag End Laboratory", +# # institution="University of Middle Earth at the Shire", +# # experiment_description="I went on an adventure to reclaim vast treasures.", +# # session_id="LONELYMTN001", +# # ) +# # +# # subject = Subject( +# # subject_id="01", +# # age="One shouldn't ask", +# # description="A human.", +# # species=TermSetWrapper(value="Homo sapiens", termset=species_termset), +# # sex="M", +# # ) +# # +# # nwbfile.subject = subject +# # device = nwbfile.create_device( +# # name="array", description="the best array", manufacturer="Probe Company 9000" +# # ) +# # +# # nwbfile.add_electrode_column(name="label", description="label of electrode") +# # +# # nshanks = 4 +# # nchannels_per_shank = 3 +# # electrode_counter = 0 +# # +# # for ishank in range(nshanks): +# # # create an electrode group for this shank +# # electrode_group = nwbfile.create_electrode_group( +# # name="shank{}".format(ishank), +# # description="electrode group for shank {}".format(ishank), +# # device=device, +# # location=TermSetWrapper(value='Amygdala', termset=location_termset), +# # ) +# # # add electrodes to the electrode table +# # for ielec in range(nchannels_per_shank): +# # nwbfile.add_electrode( +# # group=electrode_group, +# # label="shank{}elec{}".format(ishank, ielec), +# # location='Amygdala' +# # ) +# # electrode_counter += 1 +# # breakpoint() +# # with NWBHDF5IO("basics_tutorial.nwb",herd_path='./HERD.zip', mode= "w") as io: +# # io.write(nwbfile) +# # +# # # Automatically writes HERD using TermSetWrapper as the flag. +# # with NWBHDF5IO("basics_tutorial.nwb",herd_path='HERD.zip', mode="r") as io: +# # read_nwbfile = io.read() diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index cb43d39ba..c6f263a9f 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -1,12 +1,10 @@ -import os -import numpy as np from dateutil import tz from datetime import datetime from uuid import uuid4 -from hdmf.term_set import TermSet, TermSetWrapper +from hdmf.term_set import TermSetWrapper -from pynwb import NWBHDF5IO, 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