Skip to content

Commit

Permalink
Actual NWB files created with:
Browse files Browse the repository at this point in the history
```
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
TheChymera committed Dec 8, 2022
1 parent 57e9362 commit ea30161
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit ea30161

Please sign in to comment.