Ejemplo n.º 1
0
def test_general_intra():
    if __file__.startswith("./"):
        fname = "s" + __file__[3:-3] + ".nwb"
    else:
        fname = "s" + __file__[1:-3] + ".nwb"
    create_general_intra(fname)
    #
    val = ut.verify_present(fname, "general/intracellular_ephys/", "intra_custom")
    if not ut.strcmp(val, "INTRA_CUSTOM"):
        ut.error("Checking custom", "Field value incorrect")
    #

    test_field(fname, "DESCRIPTION", "p1")
    test_field(fname, "FILTERING", "p1")
    test_field(fname, "DEVICE", "p1")
    test_field(fname, "LOCATION", "p1")
    test_field(fname, "RESISTANCE", "p1")
    test_field(fname, "SLICE", "p1")
    test_field(fname, "SEAL", "p1")
    test_field(fname, "INITIAL_ACCESS_RESISTANCE", "p1")
    test_field(fname, "INTRA_ELECTRODE_CUSTOM", "p1")
    #
    test_field(fname, "DESCRIPTION", "e2")
    test_field(fname, "FILTERING", "e2")
    test_field(fname, "DEVICE", "e2")
    test_field(fname, "LOCATION", "e2")
    test_field(fname, "RESISTANCE", "e2")
    test_field(fname, "SLICE", "e2")
    test_field(fname, "SEAL", "e2")
    test_field(fname, "INITIAL_ACCESS_RESISTANCE", "e2")
    test_field(fname, "INTRA_ELECTRODE_CUSTOM", "e2")
Ejemplo n.º 2
0
def test_general_top():
    if __file__.startswith("./"):
        fname = "x" + __file__[3:-3] + ".nwb"
    else:
        fname = "x" + __file__[1:-3] + ".nwb"
    create_general_top(fname)
    test_field(fname, "DATA_COLLECTION")
    test_field(fname, "EXPERIMENT_DESCRIPTION")
    test_field(fname, "EXPERIMENTER")
    test_field(fname, "INSTITUTION")
    test_field(fname, "LAB")
    test_field(fname, "NOTES")
    test_field(fname, "PROTOCOL")
    test_field(fname, "PHARMACOLOGY")
    test_field(fname, "RELATED_PUBLICATIONS")
    test_field(fname, "SESSION_ID")
    test_field(fname, "SLICES")
    test_field(fname, "STIMULUS")
    test_field(fname, "SURGERY")
    test_field(fname, "VIRUS")
    val = ut.verify_present(fname, "general/", "source_script")
    if len(val) < 1000:
        ut.error("Checking metadata_from_file", "unexpected field size")
    val = ut.verify_attribute_present(fname, "general/source_script",
                                      "neurodata_type")
    if val != "Custom" and val != b"Custom":
        ut.error("Checking custom tag", "neurodata_type incorrect")
Ejemplo n.º 3
0
def test_general_top():
    if __file__.startswith("./"):
        fname = "x" + __file__[3:-3] + ".nwb"
    else:
        fname = "x" + __file__[1:-3] + ".nwb"
    create_general_top(fname)
    test_field(fname, "DATA_COLLECTION")
    test_field(fname, "EXPERIMENT_DESCRIPTION")
    test_field(fname, "EXPERIMENTER")
    test_field(fname, "INSTITUTION")
    test_field(fname, "LAB")
    test_field(fname, "NOTES")
    test_field(fname, "PROTOCOL")
    test_field(fname, "PHARMACOLOGY")
    test_field(fname, "RELATED_PUBLICATIONS")
    test_field(fname, "SESSION_ID")
    test_field(fname, "SLICES")
    test_field(fname, "STIMULUS")
    test_field(fname, "SURGERY")
    test_field(fname, "VIRUS")
    val = ut.verify_present(fname, "general/", "source_script")
    if len(val) < 1000:
        ut.error("Checking metadata_from_file", "unexpected field size")
    val = ut.verify_attribute_present(fname, "general/source_script", "neurodata_type")
    if val != "Custom" and val != b"Custom":
        ut.error("Checking custom tag", "neurodata_type incorrect")
Ejemplo n.º 4
0
def test_image(fname, iname, img):
    val = ut.verify_present(fname, iname, img)
    if len(val) != 2 or len(val[0]) != 3:
        ut.error("Checking image "+img, "wrong dimension")
    if val[1][1] != 144:
        ut.error("Checking image "+img, "wrong contents")
    val = ut.verify_attribute_present(fname, iname+"/"+img, "format")
    if not ut.strcmp(val, "raw"):
        ut.error("Checking image "+img+" format", "wrong contents")
    val = ut.verify_attribute_present(fname, iname+"/"+img, "dimension")
    if len(val) != 2 or val[0] != 2 or val[1] != 3:
        ut.error("Checking image "+img+" dimension", "wrong contents")
    val = ut.verify_attribute_present(fname, iname+"/"+img, "bits_per_pixel")
    if val != 8:
        ut.error("Checking image "+img+" bpp", "wrong contents")
Ejemplo n.º 5
0
def test_general_subject():
    if __file__.startswith("./"):
        fname = "s" + __file__[3:-3] + ".nwb"
    else:
        fname = "s" + __file__[1:-3] + ".nwb"
    create_general_subject(fname)
    val = ut.verify_present(fname, "general/subject/", "description")
    if not ut.strcmp(val, "SUBJECT"):
        ut.error("Checking metadata", "field value incorrect")
    test_field(fname, "SUBJECT_ID")
    test_field(fname, "SPECIES")
    test_field(fname, "GENOTYPE")
    test_field(fname, "SEX")
    test_field(fname, "AGE")
    test_field(fname, "WEIGHT")
Ejemplo n.º 6
0
def test_nodata_series():
    if __file__.startswith("./"):
        fname = "x" + __file__[3:-3] + ".nwb"
    else:
        fname = "x" + __file__[1:-3] + ".nwb"
    name = "starting_time"
    create_startingtime_series(fname, name, "acquisition")
    ut.verify_timeseries(fname, name, "acquisition/timeseries", "TimeSeries")
    ut.verify_absent(fname, "acquisition/timeseries/"+name, "timestamps")
    val = ut.verify_present(fname, "acquisition/timeseries/"+name, "starting_time")
    if val != 0.125:
        ut.error("Checking start time", "Incorrect value")
    val = ut.verify_attribute_present(fname, "acquisition/timeseries/starting_time/"+name, "rate")
    if val != 2:
        ut.error("Checking rate", "Incorrect value")
Ejemplo n.º 7
0
def test_general_subject():
    if __file__.startswith("./"):
        fname = "x" + __file__[3:-3] + ".nwb"
    else:
        fname = "x" + __file__[1:-3] + ".nwb"
    create_general_subject(fname)
    val = ut.verify_present(fname, "general/subject/", "description")
    if not ut.strcmp(val, "SUBJECT"):
        ut.error("Checking metadata", "field value incorrect")
    test_field(fname, "SUBJECT_ID")
    test_field(fname, "SPECIES")
    test_field(fname, "GENOTYPE")
    test_field(fname, "SEX")
    test_field(fname, "AGE")
    test_field(fname, "WEIGHT")
Ejemplo n.º 8
0
def test_nodata_series():
    if __file__.startswith("./"):
        fname = "x" + __file__[3:-3] + ".nwb"
    else:
        fname = "x" + __file__[1:-3] + ".nwb"
    name = "starting_time"
    create_startingtime_series(fname, name, "acquisition")
    ut.verify_timeseries(fname, name, "acquisition/timeseries", "TimeSeries")
    ut.verify_absent(fname, "acquisition/timeseries/" + name, "timestamps")
    val = ut.verify_present(fname, "acquisition/timeseries/" + name,
                            "starting_time")
    if val != 0.125:
        ut.error("Checking start time", "Incorrect value")
    val = ut.verify_attribute_present(
        fname, "acquisition/timeseries/starting_time/" + name, "rate")
    if val != 2:
        ut.error("Checking rate", "Incorrect value")
Ejemplo n.º 9
0
def test_isi_iface():
    if __file__.startswith("./"):
        fname = "s" + __file__[3:-3] + ".nwb"
    else:
        fname = "s" + __file__[1:-3] + ".nwb"
    name = "test_module"
    iname = "processing/" + name + "/ImagingRetinotopy"
    create_isi_iface(fname, name)

    test_axis(fname, iname, "1")
    test_axis(fname, iname, "2")
    val = ut.verify_present(fname, iname, "axis_descriptions")
    if len(val) != 2:
        ut.error("Checking axis_description", "wrong dimension")
    if not ut.strcmp(val[0], "altitude") or not ut.strcmp(val[1], "azimuth"):
        ut.error("Checking axis_description", "wrong contents")
    test_image(fname, iname, "vasculature_image")
    test_image(fname, iname, "focal_depth_image")
    test_sign_map(fname, iname)
Ejemplo n.º 10
0
def test_general_optogen():
    if __file__.startswith("./"):
        fname = "x" + __file__[3:-3] + ".nwb"
    else:
        fname = "x" + __file__[1:-3] + ".nwb"
    create_general_optogen(fname)
    #
    val = ut.verify_present(fname, "general/optogenetics/", "optogen_custom")
    if not ut.strcmp(val, "OPTOGEN_CUSTOM"):
        ut.error("Checking custom", "Field value incorrect")
    #

    test_field(fname, "DESCRIPTION", "p1")
    #test_field(fname, "DESCRIPTIONx", "p1")
    #test_field(fname, "DESCRIPTION", "p1x")
    test_field(fname, "DEVICE", "p1")
    test_field(fname, "LAMBDA", "p1")
    test_field(fname, "LOCATION", "p1")
    val = ut.verify_present(fname, "general/optogenetics/p1/", "optogen_site_custom") 
    if not ut.strcmp(val, "OPTOGEN_SITE_CUSTOM"):
        ut.error("Checking metadata", "field value incorrect")
Ejemplo n.º 11
0
def test_general_optogen():
    if __file__.startswith("./"):
        fname = "x" + __file__[3:-3] + ".nwb"
    else:
        fname = "x" + __file__[1:-3] + ".nwb"
    create_general_optogen(fname)
    #
    val = ut.verify_present(fname, "general/optogenetics/", "optogen_custom")
    if not ut.strcmp(val, "OPTOGEN_CUSTOM"):
        ut.error("Checking custom", "Field value incorrect")
    #

    test_field(fname, "DESCRIPTION", "p1")
    #test_field(fname, "DESCRIPTIONx", "p1")
    #test_field(fname, "DESCRIPTION", "p1x")
    test_field(fname, "DEVICE", "p1")
    test_field(fname, "LAMBDA", "p1")
    test_field(fname, "LOCATION", "p1")
    val = ut.verify_present(fname, "general/optogenetics/p1/",
                            "optogen_site_custom")
    if not ut.strcmp(val, "OPTOGEN_SITE_CUSTOM"):
        ut.error("Checking metadata", "field value incorrect")
Ejemplo n.º 12
0
def test_sign_map(fname, iname):
    val = ut.verify_present(fname, iname, "sign_map")
    if len(val) != 2 or len(val[0]) != 3:
        ut.error("Checking sign map", "wrong dimension")
    if val[1][1] != -.5:
        ut.error("Checking sign map", "wrong content")
    val = ut.verify_attribute_present(fname, iname+"/sign_map", "dimension")
    if len(val) != 2 or val[0] != 2 or val[1] != 3:
        ut.error("Checking sign map dimension", "wrong contents")
Ejemplo n.º 13
0
def test_refimage_series():
    if __file__.startswith("./"):
        fname = "s" + __file__[3:-3] + ".nwb"
    else:
        fname = "s" + __file__[1:-3] + ".nwb"
    name = "refimage"
    create_refimage(fname, name)
    val = ut.verify_present(fname, "acquisition/images/", name)
    #if len(val) != 6:
    if len(val) != 5:
        ut.error("Checking ref image contents", "wrong dimension")
    val = ut.verify_attribute_present(fname, "acquisition/images/"+name, "format")
    if not ut.strcmp(val, "raw"):
        ut.error("Checking ref image format", "Wrong value")
    val = ut.verify_attribute_present(fname, "acquisition/images/"+name, "description")
    if not ut.strcmp(val, "test"):
        ut.error("Checking ref image description", "Wrong value")
Ejemplo n.º 14
0
def test_refimage_series():
    if __file__.startswith("./"):
        fname = "s" + __file__[3:-3] + ".nwb"
    else:
        fname = "s" + __file__[1:-3] + ".nwb"
    name = "refimage"
    create_refimage(fname, name)
    val = ut.verify_present(fname, "/", "identifier")
    if not ut.strcmp(val, "vwx"):
        ut.error("Checking file idenfier", "wrong contents")
    val = ut.verify_present(fname, "/", "file_create_date")
    val = ut.verify_present(fname, "/", "session_start_time")
    if not ut.strcmp(val, "xyz"):
        ut.error("Checking session start time", "wrong contents")
    val = ut.verify_present(fname, "/", "session_description")
    if not ut.strcmp(val, "wxy"):
        ut.error("Checking session start time", "wrong contents")
def test_refimage_series():
    if __file__.startswith("./"):
        fname = "s" + __file__[3:-3] + ".nwb"
    else:
        fname = "s" + __file__[1:-3] + ".nwb"
    name = "refimage"
    create_refimage(fname, name)
    val = ut.verify_present(fname, "/", "identifier")
    if not ut.strcmp(val, "vwx"):
        ut.error("Checking file idenfier", "wrong contents")
    val = ut.verify_present(fname, "/", "file_create_date")
    val = ut.verify_present(fname, "/", "session_start_time")
    if not ut.strcmp(val, "xyz"):
        ut.error("Checking session start time", "wrong contents")
    val = ut.verify_present(fname, "/", "session_description")
    if not ut.strcmp(val, "wxy"):
        ut.error("Checking session start time", "wrong contents")
Ejemplo n.º 16
0
def test_refimage_series():
    if __file__.startswith("./"):
        fname = "s" + __file__[3:-3] + ".nwb"
    else:
        fname = "s" + __file__[1:-3] + ".nwb"
    name = "refimage"
    create_refimage(fname, name)
    val = ut.verify_present(fname, "acquisition/images/", name)
    #if len(val) != 6:
    if len(val) != 5:
        ut.error("Checking ref image contents", "wrong dimension")
    val = ut.verify_attribute_present(fname, "acquisition/images/"+name, "format")
    if not ut.strcmp(val, "raw"):
        ut.error("Checking ref image format", "Wrong value")
    val = ut.verify_attribute_present(fname, "acquisition/images/"+name, "description")
    if not ut.strcmp(val, "test"):
        ut.error("Checking ref image description", "Wrong value")
Ejemplo n.º 17
0
def test_axis(fname, iname, num):
    val = ut.verify_present(fname, iname, "axis_"+num+"_phase_map")
    if len(val) != 2 or len(val[0]) != 3:
        ut.error("Checking axis-"+num, "wrong dimension")
    if num == "1": 
        if val[0][0] != 1.0:
            ut.error("Checking axis-"+num, "wrong contents")
    elif num == "2":
        if val[0][0] != 3.0:
            ut.error("Checking axis-"+num+" contents", "wrong contents")
    val = ut.verify_attribute_present(fname, iname+"/axis_"+num+"_phase_map", "unit")
    if not ut.strcmp(val, "degrees"):
        ut.error("Checking axis-"+num+" unit", "Wrong value")
    val = ut.verify_attribute_present(fname, iname+"/axis_"+num+"_phase_map", "dimension")
    if val[0] != 2 or val[1] != 3:
        ut.error("Double-checking axis-"+num+" dimension", "Wrong value")
    val = ut.verify_attribute_present(fname, iname+"/axis_"+num+"_phase_map", "field_of_view")
    if val[0] != .1 or val[1] != .1:
        ut.error("Checking axis-"+num+" field-of-view", "Wrong value")
    # now check power map. it only exists for axis 1
    if num == "1":
        val = ut.verify_present(fname, iname, "axis_"+num+"_phase_map")
        if len(val) != 2 or len(val[0]) != 3:
            ut.error("Checking axis-"+num+" power map", "wrong dimension")
        val = ut.verify_attribute_present(fname, iname+"/axis_"+num+"_power_map", "dimension")
        if val[0] != 2 or val[1] != 3:
            ut.error("Double-checking axis-"+num+"-power dimension", "Wrong value")
        val = ut.verify_attribute_present(fname, iname+"/axis_"+num+"_power_map", "field_of_view")
        if val[0] != .1 or val[1] != .1:
            ut.error("Checking axis-"+num+"-power field-of-view", "Wrong value")
Ejemplo n.º 18
0
# epoch2 = borg.create_epoch("epoch-2", 1, 4);
epoch2 = f.make_group("<epoch_X>", "epoch-2")
epoch2.set_dataset("start_time", 1)
epoch2.set_dataset("stop_time", 4)

# for i in range(len(tags)-1):
#     epoch2.add_tag(tags[i])
epoch2.set_dataset("tags", tags[0:-1])

f.close()

# this test modified because tags are stored as dataset rather than attribute
# tags = ut.verify_attribute_present(fname, "epochs/epoch-1", "tags");
tags = ut.verify_present(fname, "epochs/epoch-1", "tags")
for i in range(len(tags) - 1):
    if tags[i + 1] not in tags:
        ut.error("Verifying epoch tag content", "All tags not present")

# tags = ut.verify_attribute_present(fname, "epochs/epoch-2", "tags");
tags = ut.verify_present(fname, "epochs/epoch-2", "tags")
for i in range(len(tags) - 1):
    if tags[i] not in tags:
        ut.error("Verifying epoch tag content", "All tags not present")

tags = ut.verify_attribute_present(fname, "epochs", "tags")
for i in range(len(tags)):
    if tags[i] not in tags:
        ut.error("Verifying epoch tag content", "All tags not present")

print("%s PASSED" % __file__)
Ejemplo n.º 19
0
def test_general_extra():
    if __file__.startswith("./"):
        fname = "s" + __file__[3:-3] + ".nwb"
    else:
        fname = "s" + __file__[1:-3] + ".nwb"
    create_general_extra(fname)
    #
    val = ut.verify_present(fname, "general/extracellular_ephys",
                            "electrode_map")
    if len(val) != 2 and len(val[0]) != 3:
        ut.error("Checking electrode map", "incorrect dimensions")
    #
    val = ut.verify_present(fname, "general/extracellular_ephys",
                            "electrode_group")
    if len(val) != 2:
        ut.error("Checking electrode group", "incorrect dimensions")
    if val[0] != "p1" and val[0] != b"p1":
        ut.error("Checking electrode group p1", "incorrect values")
    if val[1] != "p2" and val[1] != b"p2":
        ut.error("Checking electrode group p2", "incorrect values")
    #
    val = ut.verify_present(fname, "general/extracellular_ephys", "impedance")
    if len(val) != 2:
        ut.error("Checking electrode impedance", "incorrect dimensions")
    #
    val = ut.verify_present(fname, "general/extracellular_ephys/", "filtering")
    if val != "EXTRA_FILTERING" and val != b"EXTRA_FILTERING":
        ut.error("Checking filtering", "Field value incorrect")
    #
    val = ut.verify_present(fname, "general/extracellular_ephys/",
                            "EXTRA_CUSTOM")
    if val != "EXTRA_CUSTOM" and val != b"EXTRA_CUSTOM":
        ut.error("Checking custom", "Field value incorrect")
    #

    test_field(fname, "DESCRIPTION", "p1")
    test_field(fname, "LOCATION", "p1")
    test_field(fname, "DEVICE", "p1")
    test_field(fname, "EXTRA_SHANK_CUSTOM", "p1")
    test_field(fname, "DESCRIPTION", "p2")
    test_field(fname, "LOCATION", "p2")
    test_field(fname, "DEVICE", "p2")
    test_field(fname, "EXTRA_SHANK_CUSTOM", "p2")
Ejemplo n.º 20
0
def test_field(fname, name, subdir):
    val = ut.verify_present(fname,
                            "general/extracellular_ephys/" + subdir + "/",
                            name.lower())
    if val != name and val != np.bytes_(name):
        ut.error("Checking metadata", "field value incorrect")
Ejemplo n.º 21
0
tags = ["tag-a", "tag-b", "tag-c"]

epoch1 = borg.create_epoch("epoch-1", 0, 3);
for i in range(len(tags)-1):
    epoch1.add_tag(tags[i+1])

epoch2 = borg.create_epoch("epoch-2", 1, 4);
for i in range(len(tags)-1):
    epoch2.add_tag(tags[i])

borg.close()

tags = ut.verify_attribute_present(fname, "epochs/epoch-1", "tags");
for i in range(len(tags)-1):
    if tags[i+1] not in tags:
        ut.error("Verifying epoch tag content", "All tags not present")

tags = ut.verify_attribute_present(fname, "epochs/epoch-2", "tags");
for i in range(len(tags)-1):
    if tags[i] not in tags:
        ut.error("Verifying epoch tag content", "All tags not present")

tags = ut.verify_attribute_present(fname, "epochs", "tags");
for i in range(len(tags)):
    if tags[i] not in tags:
        ut.error("Verifying epoch tag content", "All tags not present")


print("%s PASSED" % __file__)

Ejemplo n.º 22
0
def test_ts_link():
    if __file__.startswith("./"):
        fname = "s" + __file__[3:-3] + ".nwb"
    else:
        fname = "s" + __file__[1:-3] + ".nwb"
    root = "root"
    create_linked_series(fname, root)
    ut.verify_timeseries(fname, root+"1", "stimulus/templates", "TimeSeries")
    ut.verify_timeseries(fname, root+"2", "stimulus/presentation", "TimeSeries")
    ut.verify_timeseries(fname, root+"3", "acquisition/timeseries", "TimeSeries")
    ##################################################
    # make sure data is present in ts using link
    val = ut.verify_present(fname, "stimulus/presentation/root2", "data")
    if val[0] != 1:
        ut.error("Checking link content", "Incorrect value")
    # make sure link is documented
    val = ut.verify_attribute_present(fname, "stimulus/presentation/root2", "data_link")
    if not ut.search_for_substring(val, "root1"):
        ut.error("Checking attribute data_link", "Name missing")
    if not ut.search_for_substring(val, "root2"):
        ut.error("Checking attribute data_link", "Name missing")
    val = ut.verify_attribute_present(fname, "stimulus/templates/root1", "data_link")
    if not ut.search_for_substring(val, "root1"):
        ut.error("Checking attribute data_link", "Name missing")
    if not ut.search_for_substring(val, "root2"):
        ut.error("Checking attribute data_link", "Name missing")
    ##################################################
    # make sure timestamps is present in ts using link
    val = ut.verify_present(fname, "acquisition/timeseries/root3", "timestamps")
    if val[0] != 2:
        ut.error("Checking link content", "Incorrect value")
    # make sure link is documented
    val = ut.verify_attribute_present(fname, "stimulus/presentation/root2", "timestamp_link")
    if not ut.search_for_substring(val, "root2"):
        ut.error("Checking attribute timestamp_link", "Name missing")
    if not ut.search_for_substring(val, "root3"):
        ut.error("Checking attribute timestamp_link", "Name missing")
    val = ut.verify_attribute_present(fname, "acquisition/timeseries/root3", "timestamp_link")
    if not ut.search_for_substring(val, "root2"):
        ut.error("Checking attribute timestamp_link", "Name missing")
    if not ut.search_for_substring(val, "root3"):
        ut.error("Checking attribute timestamp_link", "Name missing")
Ejemplo n.º 23
0
def test_field(fname, name, subdir):
    val = ut.verify_present(fname, "general/intracellular_ephys/"+subdir+"/", name.lower())
    if not ut.strcmp(val, name):
        ut.error("Checking metadata", "field value incorrect")
Ejemplo n.º 24
0
def test_field(fname, name):
    val = ut.verify_present(fname, "general/subject/", name.lower())
    if not ut.strcmp(val, name):
        ut.error("Checking metadata", "field value incorrect")
def test_field(fname, name, subdir):
    val = ut.verify_present(fname, "general/optogenetics/"+subdir+"/", name.lower())
    if not ut.strcmp(val, name):
        ut.error("Checking metadata", "field value incorrect")
Ejemplo n.º 26
0
def test_field(fname, name, subdir):
    val = ut.verify_present(fname, "general/extracellular_ephys/"+subdir+"/", name.lower())
    if val != name and val != np.bytes_(name):
        ut.error("Checking metadata", "field value incorrect")
Ejemplo n.º 27
0
def test_field(fname, name):
    val = ut.verify_present(fname, "general/subject/", name.lower())
    if not ut.strcmp(val, name):
        ut.error("Checking metadata", "field value incorrect")
Ejemplo n.º 28
0
neurodata = nwb.NWB(**settings)
neurodata.close()

#time.sleep(1)
settings = {}
settings["filename"] = fname
settings["overwrite"] = False
settings["modify"] = True
neurodata = nwb.NWB(**settings)
neurodata.set_metadata(INSTITUTION, "Allen Institute for Brain Science")
neurodata.close()

#time.sleep(1)
settings = {}
settings["filename"] = fname
settings["overwrite"] = False
settings["modify"] = True
attrs = {}
attrs["phrasebook"] = "Sir William, I cannot wait until lunchtime"
neurodata.set_metadata(EXPERIMENT_DESCRIPTION, "My hovercraft is full of eels", **attrs)
neurodata = nwb.NWB(**settings)
neurodata.close()

f = h5py.File(fname)
dates = f["file_create_date"]
if len(dates) != 3:
    ut.error(__file__, "Expected 3 entries in file_create_date; found %d" % len(dates))

print("%s PASSED" % __file__)

settings["identifier"] = nwb.create_identifier("Modification example")
settings["overwrite"] = True
settings["description"] = "Modified empty file"
settings["start_time"] = "Sat Jul 04 2015 3:14:16"
neurodata = nwb.NWB(**settings)
neurodata.close()

#time.sleep(1)
settings = {}
settings["filename"] = fname
settings["overwrite"] = False
settings["modify"] = True
neurodata = nwb.NWB(**settings)
neurodata.close()

#time.sleep(1)
settings = {}
settings["filename"] = fname
settings["overwrite"] = False
settings["modify"] = True
neurodata = nwb.NWB(**settings)
neurodata.close()

f = h5py.File(fname)
dates = f["file_create_date"]
if len(dates) != 3:
    ut.error(__file__, "Expected 3 entries in file_create_date; found %d" % len(dates))

print("%s PASSED" % __file__)

Ejemplo n.º 30
0
def test_field(fname, name):
    val = ut.verify_present(fname, "general/", name.lower())
    if val != name and val != np.bytes_(name):
        ut.error("Checking metadata", "field value incorrect")
Ejemplo n.º 31
0
def test_general_extra():
    if __file__.startswith("./"):
        fname = "x" + __file__[3:-3] + ".nwb"
    else:
        fname = "x" + __file__[1:-3] + ".nwb"
    create_general_extra(fname)
    #
    val = ut.verify_present(fname, "general/extracellular_ephys", "electrode_map")
    if len(val) != 2 and len(val[0]) != 3:
        ut.error("Checking electrode map", "incorrect dimensions")
    #
    val = ut.verify_present(fname, "general/extracellular_ephys", "electrode_group")
    if len(val) != 2:
        ut.error("Checking electrode group", "incorrect dimensions")
    if val[0] != "p1" and val[0] != b"p1":
        ut.error("Checking electrode group p1", "incorrect values")
    if val[1] != "p2" and val[1] != b"p2":
        ut.error("Checking electrode group p2", "incorrect values")
    #
    val = ut.verify_present(fname, "general/extracellular_ephys", "impedance")
    if len(val) != 2:
        ut.error("Checking electrode impedance", "incorrect dimensions")
    #
    val = ut.verify_present(fname, "general/extracellular_ephys/", "filtering")
    if val != "EXTRA_FILTERING" and val != b"EXTRA_FILTERING":
        ut.error("Checking filtering", "Field value incorrect")
    #
    val = ut.verify_present(fname, "general/extracellular_ephys/", "EXTRA_CUSTOM")
    if val != "EXTRA_CUSTOM" and val != b"EXTRA_CUSTOM":
        ut.error("Checking custom", "Field value incorrect")
    #

    test_field(fname, "DESCRIPTION", "p1")
    test_field(fname, "LOCATION", "p1")
    test_field(fname, "DEVICE", "p1")
    test_field(fname, "EXTRA_SHANK_CUSTOM", "p1")
    test_field(fname, "DESCRIPTION", "p2")
    test_field(fname, "LOCATION", "p2")
    test_field(fname, "DEVICE", "p2")
    test_field(fname, "EXTRA_SHANK_CUSTOM", "p2")
Ejemplo n.º 32
0
def test_general_intra():
    if __file__.startswith("./"):
        fname = "s" + __file__[3:-3] + ".nwb"
    else:
        fname = "s" + __file__[1:-3] + ".nwb"
    create_general_intra(fname)
    #
    val = ut.verify_present(fname, "general/optophysiology/", "image_custom")
    if not ut.strcmp(val, "IMAGE_CUSTOM"):
    #if val != "IMAGE_CUSTOM" and val != b"IMAGE_CUSTOM":
        ut.error("Checking custom", "Field value incorrect")
    #

    test_field(fname, "DESCRIPTION", "p1")
    test_field(fname, "DEVICE", "p1")
    test_field(fname, "EXCITATION_LAMBDA", "p1")
    test_field(fname, "IMAGE_SITE_CUSTOM", "p1")
    test_field(fname, "IMAGING_RATE", "p1")
    test_field(fname, "INDICATOR", "p1")
    test_field(fname, "LOCATION", "p1")
    val = ut.verify_present(fname, "general/optophysiology/p1/", "manifold")
    if len(val) != 2 or len(val[0]) != 2 or len(val[0][0]) != 3:
        ut.error("Checking manifold", "Incorrect dimensions")
    val = ut.verify_present(fname, "general/optophysiology/p1/red/", "description")
    if not ut.strcmp(val, "DESCRIPTION"):
        ut.error("Checking metadata", "field value incorrect")
    val = ut.verify_present(fname, "general/optophysiology/p1/green/", "description")
    if not ut.strcmp(val, "DESCRIPTION"):
        ut.error("Checking metadata", "field value incorrect")
    val = ut.verify_present(fname, "general/optophysiology/p1/red/", "emission_lambda")
    if not ut.strcmp(val, "CHANNEL_LAMBDA"):
        ut.error("Checking metadata", "field value incorrect")
    val = ut.verify_present(fname, "general/optophysiology/p1/green/", "emission_lambda")
    if not ut.strcmp(val, "CHANNEL_LAMBDA"):
        ut.error("Checking metadata", "field value incorrect")
Ejemplo n.º 33
0
def test_ts_link():
    if __file__.startswith("./"):
        fname = "s" + __file__[3:-3] + ".nwb"
    else:
        fname = "s" + __file__[1:-3] + ".nwb"
    root = "root"
    create_linked_series(fname, root)
    ut.verify_timeseries(fname, root + "1", "stimulus/templates", "TimeSeries")
    ut.verify_timeseries(fname, root + "2", "stimulus/presentation",
                         "TimeSeries")
    ut.verify_timeseries(fname, root + "3", "acquisition/timeseries",
                         "TimeSeries")
    ##################################################
    # make sure data is present in ts using link
    val = ut.verify_present(fname, "stimulus/presentation/root2", "data")
    if val[0] != 1:
        ut.error("Checking link content", "Incorrect value")
    # make sure link is documented
    val = ut.verify_attribute_present(fname, "stimulus/presentation/root2",
                                      "data_link")
    if not ut.search_for_substring(val, "root1"):
        ut.error("Checking attribute data_link", "Name missing")
    if not ut.search_for_substring(val, "root2"):
        ut.error("Checking attribute data_link", "Name missing")
    val = ut.verify_attribute_present(fname, "stimulus/templates/root1",
                                      "data_link")
    if not ut.search_for_substring(val, "root1"):
        ut.error("Checking attribute data_link", "Name missing")
    if not ut.search_for_substring(val, "root2"):
        ut.error("Checking attribute data_link", "Name missing")
    ##################################################
    # make sure timestamps is present in ts using link
    val = ut.verify_present(fname, "acquisition/timeseries/root3",
                            "timestamps")
    if val[0] != 2:
        ut.error("Checking link content", "Incorrect value")
    # make sure link is documented
    val = ut.verify_attribute_present(fname, "stimulus/presentation/root2",
                                      "timestamp_link")
    if not ut.search_for_substring(val, "root2"):
        ut.error("Checking attribute timestamp_link", "Name missing")
    if not ut.search_for_substring(val, "root3"):
        ut.error("Checking attribute timestamp_link", "Name missing")
    val = ut.verify_attribute_present(fname, "acquisition/timeseries/root3",
                                      "timestamp_link")
    if not ut.search_for_substring(val, "root2"):
        ut.error("Checking attribute timestamp_link", "Name missing")
    if not ut.search_for_substring(val, "root3"):
        ut.error("Checking attribute timestamp_link", "Name missing")
Ejemplo n.º 34
0
def test_field(fname, name):
    val = ut.verify_present(fname, "general/", name.lower())
    if val != name and val != np.bytes_(name):
        ut.error("Checking metadata", "field value incorrect")