Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
``` import os from uuid import uuid4 from datetime import datetime, timezone from dateutil.tz import tzlocal, tzutc import pynwb from dandi.pynwb_utils import make_nwb_file, metadata_nwb_file_fields def simple1_nwb_metadata(): # very simple assignment with the same values as the key with 1 as suffix metadata = {f: f"{f}1" for f in metadata_nwb_file_fields} metadata["identifier"] = uuid4().hex # subject_fields # tune specific ones: # Needs an explicit time zone since otherwise pynwb would add one # But then comparison breaks anyways any ways yoh have tried to set it # for datetime.now. Taking example from pynwb tests metadata["session_start_time"] = datetime(2017, 4, 15, 12, tzinfo=tzutc()) metadata["keywords"] = ["keyword1", "keyword 2"] # since NWB 2.1.0 some fields values become "arrays" which are # then reloaded as tuples, so we force them being tuples here # See e.g. NeurodataWithoutBorders/pynwb#1091 for f in "related_publications", "experimenter": metadata[f] = (metadata[f],) return metadata for i in os.listdir("."): if i.endswith("nwb"): b = simple1_nwb_metadata() a = make_nwb_file( i+"1", subject=pynwb.file.Subject( subject_id="mouse001", date_of_birth=datetime(2016, 12, 1, tzinfo=tzutc()), sex="U", species="Mus musculus", ), **b, ) print(a) ```
- Loading branch information