Ejemplo n.º 1
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.º 2
0
def test_append():
    if __file__.startswith("./"):
        fname = "x" + __file__[3:-3] + ".nwb"
    else:
        fname = "x" + __file__[1:-3] + ".nwb"
    name1 = "annot1"
    name2 = "annot2"
    create_annotation_series(fname, name1, "acquisition", True)
    create_annotation_series(fname, name2, "acquisition", False)
    ut.verify_timeseries(fname, name1, "acquisition/timeseries", "TimeSeries")
    ut.verify_timeseries(fname, name1, "acquisition/timeseries", "AnnotationSeries")
    ut.verify_timeseries(fname, name2, "acquisition/timeseries", "TimeSeries")
    ut.verify_timeseries(fname, name2, "acquisition/timeseries", "AnnotationSeries")
    ut.verify_attribute_present(fname, "file_create_date", "modification_time")
Ejemplo n.º 3
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.º 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_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.º 6
0
def test_append():
    if __file__.startswith("./"):
        fname = "x" + __file__[3:-3] + ".nwb"
    else:
        fname = "x" + __file__[1:-3] + ".nwb"
    name1 = "annot1"
    name2 = "annot2"
    create_annotation_series(fname, name1, "acquisition", True)
    create_annotation_series(fname, name2, "acquisition", False)
    ut.verify_timeseries(fname, name1, "acquisition/timeseries", "TimeSeries")
    ut.verify_timeseries(fname, name1, "acquisition/timeseries",
                         "AnnotationSeries")
    ut.verify_timeseries(fname, name2, "acquisition/timeseries", "TimeSeries")
    ut.verify_timeseries(fname, name2, "acquisition/timeseries",
                         "AnnotationSeries")
    ut.verify_attribute_present(fname, "file_create_date", "modification_time")
Ejemplo n.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
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.º 13
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.º 14
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.º 15
0
    fname = "x" + __file__[1:-3] + ".nwb"
borg = ut.create_new_file(fname, "Epoch tags")

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")