Esempio n. 1
0
def create_general_top(fname):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("general top test")
    settings["overwrite"] = True
    settings["description"] = "test top-level elements in /general"
    neurodata = nwb.NWB(**settings)
    #
    neurodata.set_metadata(DATA_COLLECTION, "DATA_COLLECTION")
    neurodata.set_metadata(EXPERIMENT_DESCRIPTION, "EXPERIMENT_DESCRIPTION")
    neurodata.set_metadata(EXPERIMENTER, "EXPERIMENTER")
    neurodata.set_metadata(INSTITUTION, "INSTITUTION")
    neurodata.set_metadata(LAB, "LAB")
    neurodata.set_metadata(NOTES, "NOTES")
    neurodata.set_metadata(PROTOCOL, "PROTOCOL")
    neurodata.set_metadata(PHARMACOLOGY, "PHARMACOLOGY")
    neurodata.set_metadata(RELATED_PUBLICATIONS, "RELATED_PUBLICATIONS")
    neurodata.set_metadata(SESSION_ID, "SESSION_ID")
    neurodata.set_metadata(SLICES, "SLICES")
    neurodata.set_metadata(STIMULUS, "STIMULUS")
    neurodata.set_metadata(SURGERY, "SURGERY")
    neurodata.set_metadata(VIRUS, "VIRUS")
    #
    neurodata.set_metadata_from_file("source_script", __file__)
    #
    neurodata.close()
def create_general_extra(fname):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("general extracellular test")
    settings["overwrite"] = True
    settings["description"] = "test elements in /general/extracellular_ephys"
    neurodata = nwb.NWB(**settings)
    #
    neurodata.set_metadata(EXTRA_ELECTRODE_MAP, [[1,1,1], [1,2,3]])
    neurodata.set_metadata(EXTRA_ELECTRODE_GROUP, ["p1", "p2"])
    neurodata.set_metadata(EXTRA_IMPEDANCE, [1.0e6, 2.0e6])
    neurodata.set_metadata(EXTRA_FILTERING, "EXTRA_FILTERING")
    neurodata.set_metadata(EXTRA_CUSTOM("EXTRA_CUSTOM"), "EXTRA_CUSTOM")

    neurodata.set_metadata(EXTRA_SHANK_DESCRIPTION("p1"), "DESCRIPTION")
    neurodata.set_metadata(EXTRA_SHANK_LOCATION("p1"), "LOCATION")
    neurodata.set_metadata(EXTRA_SHANK_DEVICE("p1"), "DEVICE")
    neurodata.set_metadata(EXTRA_SHANK_CUSTOM("p1", "extra_shank_custom"), "EXTRA_SHANK_CUSTOM")
    #
    neurodata.set_metadata(EXTRA_SHANK_DESCRIPTION("p2"), "DESCRIPTION")
    neurodata.set_metadata(EXTRA_SHANK_LOCATION("p2"), "LOCATION")
    neurodata.set_metadata(EXTRA_SHANK_DEVICE("p2"), "DEVICE")
    neurodata.set_metadata(EXTRA_SHANK_CUSTOM("p2", "extra_shank_custom"), "EXTRA_SHANK_CUSTOM")
    #
    neurodata.close()
def create_general_intra(fname):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("general intracellular test")
    settings["overwrite"] = True
    settings["description"] = "test elements in /general/intracellular_ephys"
    neurodata = nwb.NWB(**settings)
    #
    neurodata.set_metadata(INTRA_CUSTOM("intra_custom"), "INTRA_CUSTOM")
    #
    neurodata.set_metadata(INTRA_ELECTRODE_DESCRIPTION("p1"), "DESCRIPTION")
    neurodata.set_metadata(INTRA_ELECTRODE_FILTERING("p1"), "FILTERING")
    neurodata.set_metadata(INTRA_ELECTRODE_DEVICE("p1"), "DEVICE")
    neurodata.set_metadata(INTRA_ELECTRODE_LOCATION("p1"), "LOCATION")
    neurodata.set_metadata(INTRA_ELECTRODE_RESISTANCE("p1"), "RESISTANCE")
    neurodata.set_metadata(INTRA_ELECTRODE_SEAL("p1"), "SEAL")
    neurodata.set_metadata(INTRA_ELECTRODE_SLICE("p1"), "SLICE")
    neurodata.set_metadata(INTRA_ELECTRODE_INIT_ACCESS_RESISTANCE("p1"), "INITIAL_ACCESS_RESISTANCE")
    neurodata.set_metadata(INTRA_ELECTRODE_CUSTOM("p1", "intra_electrode_custom"), "INTRA_ELECTRODE_CUSTOM")
    #
    neurodata.set_metadata(INTRA_ELECTRODE_DESCRIPTION("e2"), "DESCRIPTION")
    neurodata.set_metadata(INTRA_ELECTRODE_FILTERING("e2"), "FILTERING")
    neurodata.set_metadata(INTRA_ELECTRODE_DEVICE("e2"), "DEVICE")
    neurodata.set_metadata(INTRA_ELECTRODE_LOCATION("e2"), "LOCATION")
    neurodata.set_metadata(INTRA_ELECTRODE_RESISTANCE("e2"), "RESISTANCE")
    neurodata.set_metadata(INTRA_ELECTRODE_SEAL("e2"), "SEAL")
    neurodata.set_metadata(INTRA_ELECTRODE_SLICE("e2"), "SLICE")
    neurodata.set_metadata(INTRA_ELECTRODE_INIT_ACCESS_RESISTANCE("e2"), "INITIAL_ACCESS_RESISTANCE")
    neurodata.set_metadata(INTRA_ELECTRODE_CUSTOM("e2", "intra_electrode_custom"), "INTRA_ELECTRODE_CUSTOM")
    #
    neurodata.close()
Esempio n. 4
0
def create_annotation_series(fname, name, target):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("annotation example")
    settings["overwrite"] = True
    settings["start_time"] = "Sat Jul 04 2015 3:14:16"
    settings["description"] = "Test file with AnnotationSeries"
    neurodata = nwb.NWB(**settings)
    #
    annot = neurodata.create_timeseries("AnnotationSeries", name, target)
    annot.set_description("This is an AnnotationSeries with sample data")
    annot.set_comment("The comment and description fields can store arbitrary human-readable data")
    annot.set_source("Observation of Dr. J Doe")
    #
    annot.add_annotation("Rat in bed, beginning sleep 1", 15.0)
    annot.add_annotation("Rat placed in enclosure, start run 1", 933.0)
    annot.add_annotation("Rat taken out of enclosure, end run 1", 1456.0)
    annot.add_annotation("Rat in bed, start sleep 2", 1461.0)
    annot.add_annotation("Rat placed in enclosure, start run 2", 2401.0)
    annot.add_annotation("Rat taken out of enclosure, end run 2", 3210.0)
    annot.add_annotation("Rat in bed, start sleep 3", 3218.0)
    annot.add_annotation("End sleep 3", 4193.0)
    #
    annot.finalize()
    neurodata.close()
Esempio n. 5
0
def create_general_extra(fname):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier(
        "general extracellular test")
    settings["overwrite"] = True
    settings["description"] = "test elements in /general/extracellular_ephys"
    neurodata = nwb.NWB(**settings)
    #
    neurodata.set_metadata(EXTRA_ELECTRODE_MAP, [[1, 1, 1], [1, 2, 3]])
    neurodata.set_metadata(EXTRA_ELECTRODE_GROUP, ["p1", "p2"])
    neurodata.set_metadata(EXTRA_IMPEDANCE, [1.0e6, 2.0e6])
    neurodata.set_metadata(EXTRA_FILTERING, "EXTRA_FILTERING")
    neurodata.set_metadata(EXTRA_CUSTOM("EXTRA_CUSTOM"), "EXTRA_CUSTOM")

    neurodata.set_metadata(EXTRA_SHANK_DESCRIPTION("p1"), "DESCRIPTION")
    neurodata.set_metadata(EXTRA_SHANK_LOCATION("p1"), "LOCATION")
    neurodata.set_metadata(EXTRA_SHANK_DEVICE("p1"), "DEVICE")
    neurodata.set_metadata(EXTRA_SHANK_CUSTOM("p1", "extra_shank_custom"),
                           "EXTRA_SHANK_CUSTOM")
    #
    neurodata.set_metadata(EXTRA_SHANK_DESCRIPTION("p2"), "DESCRIPTION")
    neurodata.set_metadata(EXTRA_SHANK_LOCATION("p2"), "LOCATION")
    neurodata.set_metadata(EXTRA_SHANK_DEVICE("p2"), "DEVICE")
    neurodata.set_metadata(EXTRA_SHANK_CUSTOM("p2", "extra_shank_custom"),
                           "EXTRA_SHANK_CUSTOM")
    #
    neurodata.close()
Esempio n. 6
0
def create_iface_series(fname, newfile):
    settings = {}
    settings["filename"] = fname
    if newfile:
        settings["identifier"] = nwb.create_identifier(
            "interface timeseries example")
        settings["overwrite"] = True
        settings["start_time"] = "Sat Jul 04 2015 3:14:16"
        settings["description"] = "Test interface timeseries file"
    else:
        settings["modify"] = True
    neurodata = nwb.NWB(**settings)
    #
    mod = neurodata.create_module("test module")
    iface = mod.create_interface("BehavioralEvents")
    ts = neurodata.create_timeseries("TimeSeries", "Ones")
    ts.set_data(np.ones(10),
                unit="Event",
                conversion=1.0,
                resolution=float('nan'))
    ts.set_value("num_samples", 10)
    ts.set_time(np.arange(10))
    iface.add_timeseries(ts)
    iface.finalize()
    mod.finalize()
    #
    neurodata.close()
Esempio n. 7
0
def create_new_file(fname, identifier):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier(identifier)
    settings["overwrite"] = True
    settings["description"] = "softlink test"
    return nwb.NWB(**settings)
Esempio n. 8
0
def create_isi_iface(fname, name):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("reference image test")
    settings["overwrite"] = True
    settings["description"] = "reference image test"
    neurodata = nwb.NWB(**settings)
    module = neurodata.create_module(name)
    iface = module.create_interface("ImagingRetinotopy")
    iface.add_axis_1_phase_map([[1.0, 1.1, 1.2], [2.0, 2.1, 2.2]], "altitude",
                               .1, .1)
    iface.add_axis_2_phase_map([[3.0, 3.1, 3.2], [4.0, 4.1, 4.2]],
                               "azimuth",
                               .1,
                               .1,
                               unit="degrees")
    iface.add_axis_1_power_map([[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]], .1, .1)
    iface.add_sign_map([[-.1, .2, -.3], [.4, -.5, .6]])
    iface.add_vasculature_image([[1, 0, 129], [2, 144, 0]],
                                height=.22,
                                width=.35)
    iface.add_focal_depth_image([[1, 0, 129], [2, 144, 0]], bpp=8)
    iface.finalize()
    module.finalize()
    neurodata.close()
Esempio n. 9
0
def create_annotation_series(fname, name, target):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("annotation example")
    settings["overwrite"] = True
    settings["start_time"] = "Sat Jul 04 2015 3:14:16"
    settings["description"] = "Test file with AnnotationSeries"
    neurodata = nwb.NWB(**settings)
    #
    annot = neurodata.create_timeseries("AnnotationSeries", name, target)
    annot.set_description("This is an AnnotationSeries with sample data")
    annot.set_comment(
        "The comment and description fields can store arbitrary human-readable data"
    )
    annot.set_source("Observation of Dr. J Doe")
    #
    annot.add_annotation("Rat in bed, beginning sleep 1", 15.0)
    annot.add_annotation("Rat placed in enclosure, start run 1", 933.0)
    annot.add_annotation("Rat taken out of enclosure, end run 1", 1456.0)
    annot.add_annotation("Rat in bed, start sleep 2", 1461.0)
    annot.add_annotation("Rat placed in enclosure, start run 2", 2401.0)
    annot.add_annotation("Rat taken out of enclosure, end run 2", 3210.0)
    annot.add_annotation("Rat in bed, start sleep 3", 3218.0)
    annot.add_annotation("End sleep 3", 4193.0)
    #
    annot.finalize()
    neurodata.close()
Esempio n. 10
0
def create_linked_series(fname, root):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("link test")
    settings["overwrite"] = True
    settings["description"] = "time series link test"
    settings["start_time"] = "Sat Jul 04 2015 3:14:16"
    neurodata = nwb.NWB(**settings)
    #
    first = neurodata.create_timeseries("TimeSeries", root+"1", "template")
    first.ignore_time()
    first.set_value("num_samples", 1)
    first.set_data([1], unit="parsec", conversion=1, resolution=1e-12)
    first.finalize()
    #
    second = neurodata.create_timeseries("TimeSeries", root+"2", "stimulus")
    second.set_time([2])
    second.set_value("num_samples", 1)
    second.set_data_as_link(first)
    second.finalize()
    #
    third = neurodata.create_timeseries("TimeSeries", root+"3", "acquisition")
    third.set_time_as_link(second)
    third.set_value("num_samples", 1)
    third.set_data([3], unit="parsec", conversion=1, resolution=1e-9)
    third.finalize()
    #
    neurodata.close()
Esempio n. 11
0
def create_general_top(fname):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("general top test")
    settings["overwrite"] = True
    settings["description"] = "test top-level elements in /general"
    neurodata = nwb.NWB(**settings)
    #
    neurodata.set_metadata(DATA_COLLECTION, "DATA_COLLECTION")
    neurodata.set_metadata(EXPERIMENT_DESCRIPTION, "EXPERIMENT_DESCRIPTION")
    neurodata.set_metadata(EXPERIMENTER, "EXPERIMENTER")
    neurodata.set_metadata(INSTITUTION, "INSTITUTION")
    neurodata.set_metadata(LAB, "LAB")
    neurodata.set_metadata(NOTES, "NOTES")
    neurodata.set_metadata(PROTOCOL, "PROTOCOL")
    neurodata.set_metadata(PHARMACOLOGY, "PHARMACOLOGY")
    neurodata.set_metadata(RELATED_PUBLICATIONS, "RELATED_PUBLICATIONS")
    neurodata.set_metadata(SESSION_ID, "SESSION_ID")
    neurodata.set_metadata(SLICES, "SLICES")
    neurodata.set_metadata(STIMULUS, "STIMULUS")
    neurodata.set_metadata(SURGERY, "SURGERY")
    neurodata.set_metadata(VIRUS, "VIRUS")
    #
    neurodata.set_metadata_from_file("source_script", __file__)
    #
    neurodata.close()
Esempio n. 12
0
def create_general_intra(fname):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("general optophysiology test")
    settings["overwrite"] = True
    settings["description"] = "test elements in /general/optophysiology"
    neurodata = nwb.NWB(**settings)
    #
    neurodata.set_metadata(IMAGE_CUSTOM("image_custom"), "IMAGE_CUSTOM")
    #
    neurodata.set_metadata(IMAGE_SITE_DESCRIPTION("p1"), "DESCRIPTION")
    # MANUAL CHECK
    # try storing string - -type system should balk
    #neurodata.set_metadata(IMAGE_SITE_MANIFOLD("p1"), "MANIFOLD")
    neurodata.set_metadata(IMAGE_SITE_MANIFOLD("p1"), [[[1,2,3],[2,3,4]],[[3,4,5],[4,5,6]]])
    neurodata.set_metadata(IMAGE_SITE_INDICATOR("p1"), "INDICATOR")
    neurodata.set_metadata(IMAGE_SITE_EXCITATION_LAMBDA("p1"), "EXCITATION_LAMBDA")
    neurodata.set_metadata(IMAGE_SITE_CHANNEL_LAMBDA("p1", "red"), "CHANNEL_LAMBDA")
    neurodata.set_metadata(IMAGE_SITE_CHANNEL_DESCRIPTION("p1", "red"), "DESCRIPTION")
    neurodata.set_metadata(IMAGE_SITE_CHANNEL_LAMBDA("p1", "green"), "CHANNEL_LAMBDA")
    neurodata.set_metadata(IMAGE_SITE_CHANNEL_DESCRIPTION("p1", "green"), "DESCRIPTION")
    neurodata.set_metadata(IMAGE_SITE_IMAGING_RATE("p1"), "IMAGING_RATE")
    neurodata.set_metadata(IMAGE_SITE_LOCATION("p1"), "LOCATION")
    neurodata.set_metadata(IMAGE_SITE_DEVICE("p1"), "DEVICE")
    neurodata.set_metadata(IMAGE_SITE_CUSTOM("p1", "image_site_custom"), "IMAGE_SITE_CUSTOM")
    #
    neurodata.close()
Esempio n. 13
0
def create_empty_file(fname):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("UnitTimes example")
    settings["overwrite"] = True
    settings["start_time"] = "Sat Jul 04 2015 3:14:16"
    settings["description"] = "Test file with spike times in processing module"
    neurodata = nwb.NWB(**settings)
    return neurodata
Esempio n. 14
0
def create_empty_file(fname):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("UnitTimes example")
    settings["overwrite"] = True
    settings["start_time"] = "Sat Jul 04 2015 3:14:16"
    settings["description"] = "Test file with spike times in processing module"
    neurodata = nwb.NWB(**settings)
    return neurodata
Esempio n. 15
0
def create_refimage(fname, name):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("reference image test")
    settings["overwrite"] = True
    settings["description"] = "reference image test"
    neurodata = nwb.NWB(**settings)
    neurodata.create_reference_image([1, 2, 3, 4, 5], name, "raw", "test")
    neurodata.close()
Esempio n. 16
0
def create_refimage(fname, name):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("reference image test")
    settings["overwrite"] = True
    settings["description"] = "reference image test"
    neurodata = nwb.NWB(**settings)
    neurodata.create_reference_image([1,2,3,4,5], name, "raw", "test")
    neurodata.close()
Esempio n. 17
0
def create_softlink_reader(fname, name, src_fname, src_name, target):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("softlink reader")
    settings["overwrite"] = True
    settings["description"] = "softlink test"
    neurodata = nwb.NWB(**settings)
    source = neurodata.create_timeseries("TimeSeries", name, target)
    source.set_data_as_remote_link(src_fname, "acquisition/timeseries/"+src_name+"/data")
    source.set_time([345])
    source.finalize()
    neurodata.close()
Esempio n. 18
0
def create_softlink_reader(fname, name, src_fname, src_name, target):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("softlink reader")
    settings["overwrite"] = True
    settings["description"] = "softlink test"
    neurodata = nwb.NWB(**settings)
    source = neurodata.create_timeseries("TimeSeries", name, target)
    source.set_data_as_remote_link(
        src_fname, "acquisition/timeseries/" + src_name + "/data")
    source.set_time([345])
    source.finalize()
    neurodata.close()
Esempio n. 19
0
def create_softlink_source(fname, name, target):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("softlink source")
    settings["overwrite"] = True
    settings["description"] = "time series no data test"
    settings["start_time"] = "Sat Jul 04 2015 3:14:16"
    neurodata = nwb.NWB(**settings)
    source = neurodata.create_timeseries("TimeSeries", name, target)
    source.set_data([234], unit="parsec", conversion=1, resolution=1e-3)
    source.set_time([123])
    source.finalize()
    neurodata.close()
Esempio n. 20
0
def create_softlink_source(fname, name, target):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("softlink source")
    settings["overwrite"] = True
    settings["description"] = "time series no data test"
    settings["start_time"] = "Sat Jul 04 2015 3:14:16"
    neurodata = nwb.NWB(**settings)
    source = neurodata.create_timeseries("TimeSeries", name, target)
    source.set_data([234], unit="parsec", conversion=1, resolution=1e-3)
    source.set_time([123])
    source.finalize()
    neurodata.close()
Esempio n. 21
0
def create_notime_series(fname, name, target):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("notime example")
    settings["overwrite"] = True
    settings["start_time"] = "Sat Jul 04 2015 3:14:16"
    settings["description"] = "Test no time"
    neurodata = nwb.NWB(**settings)
    #
    notime = neurodata.create_timeseries("TimeSeries", name, target)
    notime.ignore_time()
    notime.set_data([0], unit="n/a", conversion=1, resolution=1)
    #
    notime.finalize()
    neurodata.close()
Esempio n. 22
0
def create_notime_series(fname, name, target):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("notime example")
    settings["overwrite"] = True
    settings["start_time"] = "Sat Jul 04 2015 3:14:16"
    settings["description"] = "Test no time"
    neurodata = nwb.NWB(**settings)
    #
    notime = neurodata.create_timeseries("TimeSeries", name, target)
    notime.ignore_time()
    notime.set_data([0], unit="n/a", conversion=1, resolution=1)
    #
    notime.finalize()
    neurodata.close()
Esempio n. 23
0
def create_nodata_series(fname, name, target):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("nodata example")
    settings["overwrite"] = True
    settings["description"] = "time series no data test"
    settings["start_time"] = "Sat Jul 04 2015 3:14:16"
    neurodata = nwb.NWB(**settings)
    #
    nodata = neurodata.create_timeseries("TimeSeries", name, target)
    nodata.ignore_data()
    nodata.set_time([0])
    #
    nodata.finalize()
    neurodata.close()
def create_startingtime_series(fname, name, target):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("starting time test")
    settings["overwrite"] = True
    settings["description"] = "time series starting time test"
    settings["start_time"] = "Sat Jul 04 2015 3:14:16"
    neurodata = nwb.NWB(**settings)
    #
    stime = neurodata.create_timeseries("TimeSeries", name, target)
    stime.set_data([0, 1, 2, 3], unit="n/a", conversion=1, resolution=1)
    stime.set_value("num_samples", 4)
    stime.set_time_by_rate(0.125, 2)
    #
    stime.finalize()
    neurodata.close()
Esempio n. 25
0
def create_startingtime_series(fname, name, target):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("starting time test")
    settings["overwrite"] = True
    settings["description"] = "time series starting time test"
    settings["start_time"] = "Sat Jul 04 2015 3:14:16"
    neurodata = nwb.NWB(**settings)
    #
    stime = neurodata.create_timeseries("TimeSeries", name, target)
    stime.set_data([0, 1, 2, 3], unit="n/a", conversion=1, resolution=1)
    stime.set_value("num_samples", 4)
    stime.set_time_by_rate(0.125, 2)
    #
    stime.finalize()
    neurodata.close()
def create_general_subject(fname):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("general top test")
    settings["overwrite"] = True
    settings["description"] = "test top-level elements in /general"
    neurodata = nwb.NWB(**settings)
    #
    neurodata.set_metadata(SUBJECT, "SUBJECT")
    neurodata.set_metadata(SUBJECT_ID, "SUBJECT_ID")
    neurodata.set_metadata(SPECIES, "SPECIES")
    neurodata.set_metadata(GENOTYPE, "GENOTYPE")
    neurodata.set_metadata(SEX, "SEX")
    neurodata.set_metadata(AGE, "AGE")
    neurodata.set_metadata(WEIGHT, "WEIGHT")
    #
    neurodata.close()
Esempio n. 27
0
def create_general_optogen(fname):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("metadata optogenetic test")
    settings["overwrite"] = True
    settings["description"] = "test elements in /general/optogentics"
    neurodata = nwb.NWB(**settings)
    #
    neurodata.set_metadata(OPTOGEN_CUSTOM("optogen_custom"), "OPTOGEN_CUSTOM")
    #
    neurodata.set_metadata(OPTOGEN_SITE_DESCRIPTION("p1"), "DESCRIPTION")
    neurodata.set_metadata(OPTOGEN_SITE_DEVICE("p1"), "DEVICE")
    neurodata.set_metadata(OPTOGEN_SITE_LAMBDA("p1"), "LAMBDA")
    neurodata.set_metadata(OPTOGEN_SITE_LOCATION("p1"), "LOCATION")
    neurodata.set_metadata(OPTOGEN_SITE_CUSTOM("p1", "optogen_site_custom"), "OPTOGEN_SITE_CUSTOM")
    #
    neurodata.close()
Esempio n. 28
0
def create_general_subject(fname):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("general top test")
    settings["overwrite"] = True
    settings["description"] = "test top-level elements in /general"
    neurodata = nwb.NWB(**settings)
    #
    neurodata.set_metadata(SUBJECT, "SUBJECT")
    neurodata.set_metadata(SUBJECT_ID, "SUBJECT_ID")
    neurodata.set_metadata(SPECIES, "SPECIES")
    neurodata.set_metadata(GENOTYPE, "GENOTYPE")
    neurodata.set_metadata(SEX, "SEX")
    neurodata.set_metadata(AGE, "AGE")
    neurodata.set_metadata(WEIGHT, "WEIGHT")
    #
    neurodata.close()
Esempio n. 29
0
def create_isi_iface(fname, name):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("reference image test")
    settings["overwrite"] = True
    settings["description"] = "reference image test"
    neurodata = nwb.NWB(**settings)
    module = neurodata.create_module(name)
    iface = module.create_interface("ImagingRetinotopy")
    iface.add_axis_1_phase_map([[1.0, 1.1, 1.2],[2.0,2.1,2.2]], "altitude", .1, .1)
    iface.add_axis_2_phase_map([[3.0, 3.1, 3.2],[4.0,4.1,4.2]], "azimuth", .1, .1, unit="degrees")
    iface.add_axis_1_power_map([[0.1, 0.2, 0.3],[0.4, 0.5, 0.6]], .1, .1)
    iface.add_sign_map([[-.1, .2, -.3],[.4,-.5,.6]])
    iface.add_vasculature_image([[1,0,129],[2,144,0]], height=.22, width=.35)
    iface.add_focal_depth_image([[1,0,129],[2,144,0]], bpp=8)
    iface.finalize()
    module.finalize()
    neurodata.close()
Esempio n. 30
0
def create_general_optogen(fname):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier("metadata optogenetic test")
    settings["overwrite"] = True
    settings["description"] = "test elements in /general/optogentics"
    neurodata = nwb.NWB(**settings)
    #
    neurodata.set_metadata(OPTOGEN_CUSTOM("optogen_custom"), "OPTOGEN_CUSTOM")
    #
    neurodata.set_metadata(OPTOGEN_SITE_DESCRIPTION("p1"), "DESCRIPTION")
    neurodata.set_metadata(OPTOGEN_SITE_DEVICE("p1"), "DEVICE")
    neurodata.set_metadata(OPTOGEN_SITE_LAMBDA("p1"), "LAMBDA")
    neurodata.set_metadata(OPTOGEN_SITE_LOCATION("p1"), "LOCATION")
    neurodata.set_metadata(OPTOGEN_SITE_CUSTOM("p1", "optogen_site_custom"),
                           "OPTOGEN_SITE_CUSTOM")
    #
    neurodata.close()
Esempio n. 31
0
def create_general_intra(fname):
    settings = {}
    settings["filename"] = fname
    settings["identifier"] = nwb.create_identifier(
        "general intracellular test")
    settings["overwrite"] = True
    settings["description"] = "test elements in /general/intracellular_ephys"
    neurodata = nwb.NWB(**settings)
    #
    neurodata.set_metadata(INTRA_CUSTOM("intra_custom"), "INTRA_CUSTOM")
    #
    neurodata.set_metadata(INTRA_ELECTRODE_DESCRIPTION("p1"), "DESCRIPTION")
    neurodata.set_metadata(INTRA_ELECTRODE_FILTERING("p1"), "FILTERING")
    neurodata.set_metadata(INTRA_ELECTRODE_DEVICE("p1"), "DEVICE")
    neurodata.set_metadata(INTRA_ELECTRODE_LOCATION("p1"), "LOCATION")
    neurodata.set_metadata(INTRA_ELECTRODE_RESISTANCE("p1"), "RESISTANCE")
    neurodata.set_metadata(INTRA_ELECTRODE_SEAL("p1"), "SEAL")
    neurodata.set_metadata(INTRA_ELECTRODE_SLICE("p1"), "SLICE")
    neurodata.set_metadata(INTRA_ELECTRODE_INIT_ACCESS_RESISTANCE("p1"),
                           "INITIAL_ACCESS_RESISTANCE")
    neurodata.set_metadata(
        INTRA_ELECTRODE_CUSTOM("p1", "intra_electrode_custom"),
        "INTRA_ELECTRODE_CUSTOM")
    #
    neurodata.set_metadata(INTRA_ELECTRODE_DESCRIPTION("e2"), "DESCRIPTION")
    neurodata.set_metadata(INTRA_ELECTRODE_FILTERING("e2"), "FILTERING")
    neurodata.set_metadata(INTRA_ELECTRODE_DEVICE("e2"), "DEVICE")
    neurodata.set_metadata(INTRA_ELECTRODE_LOCATION("e2"), "LOCATION")
    neurodata.set_metadata(INTRA_ELECTRODE_RESISTANCE("e2"), "RESISTANCE")
    neurodata.set_metadata(INTRA_ELECTRODE_SEAL("e2"), "SEAL")
    neurodata.set_metadata(INTRA_ELECTRODE_SLICE("e2"), "SLICE")
    neurodata.set_metadata(INTRA_ELECTRODE_INIT_ACCESS_RESISTANCE("e2"),
                           "INITIAL_ACCESS_RESISTANCE")
    neurodata.set_metadata(
        INTRA_ELECTRODE_CUSTOM("e2", "intra_electrode_custom"),
        "INTRA_ELECTRODE_CUSTOM")
    #
    neurodata.close()
Esempio n. 32
0
def create_iface_series(fname, newfile):
    settings = {}
    settings["filename"] = fname
    if newfile:
        settings["identifier"] = nwb.create_identifier("interface timeseries example")
        settings["overwrite"] = True
        settings["start_time"] = "Sat Jul 04 2015 3:14:16"
        settings["description"] = "Test interface timeseries file"
    else:
        settings["modify"] = True
    neurodata = nwb.NWB(**settings)
    #
    mod = neurodata.create_module("test module")
    iface = mod.create_interface("BehavioralEvents")
    ts = neurodata.create_timeseries("TimeSeries", "Ones")
    ts.set_data(np.ones(10), unit="Event", conversion=1.0, resolution=float('nan'))
    ts.set_value("num_samples", 10)
    ts.set_time(np.arange(10))
    iface.add_timeseries(ts)
    iface.finalize()
    mod.finalize()
    #
    neurodata.close()
Esempio n. 33
0
for analysis using drifting gratings, not necessarily the stack of all 
frames displayed by the graphics card.
"""

########################################################################
# create a new NWB file
# several settings are specified when doing so. these can be supplied within
#   the NWB constructor or defined in a dict, as in in this example
settings = {}
settings["filename"] = "sample_abstract_features.nwb"

# each file should have a descriptive globally unique identifier 
#   that specifies the lab and this experiment session
# the function nwb.create_identifier() is recommended to use as it takes
#   the string and appends the present date and time
settings["identifier"] = nwb.create_identifier("abstract-feature example")

# indicate that it's OK to overwrite exting file
settings["overwrite"] = True

# specify the start time of the experiment. all times in the NWB file
#   are relative to experiment start time
# if the start time is not specified the present time will be used
settings["start_time"] = "Sat Jul 04 2015 3:14:16"

# provide one or two sentences that describe the experiment and what
#   data is in the file
settings["description"] = "Test file demonstrating use of the AbstractFeatureSeries"

# create the NWB object. this manages the file
print("Creating " + settings["filename"])
Esempio n. 34
0
experiment, for example "rat placed in enclosure" or "observed
start of seizure activity".
"""

########################################################################
# create a new NWB file
# several settings are specified when doing so. these can be supplied within
#   the NWB constructor or defined in a dict, as in in this example
settings = {}
settings["filename"] = "sample_annotations.nwb"

# each file should have a descriptive globally unique identifier
#   that specifies the lab and this experiment session
# the function nwb.create_identifier() is recommended to use as it takes
#   the string and appends the present date and time
settings["identifier"] = nwb.create_identifier("annotation example")

# indicate that it's OK to overwrite exting file
settings["overwrite"] = True

# specify the start time of the experiment. all times in the NWB file
#   are relative to experiment start time
# if the start time is not specified the present time will be used

settings["start_time"] = "Sat Jul 04 2015 3:14:16"
# provide one or two sentences that describe the experiment and what
#   data is in the file

settings[
    "description"] = "Test file demonstrating use of the AbstractFeatureSeries"
Esempio n. 35
0
Store extracellular ephys data

"""

########################################################################
# create a new NWB file
# several settings are specified when doing so. these can be supplied within
#   the NWB constructor or defined in a dict, as in in this example
settings = {}
settings["filename"] = "sample_extracellular_ephys.nwb"

# each file should have a descriptive globally unique identifier 
#   that specifies the lab and this experiment session
# the function nwb.create_identifier() is recommended to use as it takes
#   the string and appends the present date and time
settings["identifier"] = nwb.create_identifier("extracellular ephys example")

# indicate that it's OK to overwrite exting file
settings["overwrite"] = True

# specify the start time of the experiment. all times in the NWB file
#   are relative to experiment start time
# if the start time is not specified the present time will be used
settings["start_time"] = "Sat Jul 04 2015 3:14:16"

# provide one or two sentences that describe the experiment and what
#   data is in the file
settings["description"] = "Test file demonstrating a simple extracellular ephys recording"

# create the NWB object. this manages the file
print("Creating " + settings["filename"])
Esempio n. 36
0
experiment, for example "rat placed in enclosure" or "observed
start of seizure activity".
"""

########################################################################
# create a new NWB file
# several settings are specified when doing so. these can be supplied within
#   the NWB constructor or defined in a dict, as in in this example
settings = {}
settings["filename"] = "sample_annotations.nwb"

# each file should have a descriptive globally unique identifier 
#   that specifies the lab and this experiment session
# the function nwb.create_identifier() is recommended to use as it takes
#   the string and appends the present date and time
settings["identifier"] = nwb.create_identifier("annotation example")

# indicate that it's OK to overwrite exting file
settings["overwrite"] = True

# specify the start time of the experiment. all times in the NWB file
#   are relative to experiment start time
# if the start time is not specified the present time will be used

settings["start_time"] = "Sat Jul 04 2015 3:14:16"
# provide one or two sentences that describe the experiment and what
#   data is in the file

settings["description"] = "Test file demonstrating use of the AbstractFeatureSeries"

# create the NWB object. this manages the file
Esempio n. 37
0
this behavior is only determinable by post-processing of acquired
data.
"""

########################################################################
# create a new NWB file
# several settings are specified when doing so. these can be supplied within
#   the NWB constructor or defined in a dict, as in in this example
settings = {}
settings["filename"] = "sample_behavior.nwb"

# each file should have a descriptive globally unique identifier 
#   that specifies the lab and this experiment session
# the function nwb.create_identifier() is recommended to use as it takes
#   the string and appends the present date and time
settings["identifier"] = nwb.create_identifier("behavioral interval example")

# indicate that it's OK to overwrite exting file
settings["overwrite"] = True

# specify the start time of the experiment. all times in the NWB file
#   are relative to experiment start time
# if the start time is not specified the present time will be used
settings["start_time"] = "Sat Jul 04 2015 3:14:16"

# provide one or two sentences that describe the experiment and what
#   data is in the file
settings["description"] = "Test file demonstrating use of the BehavioralEpochs module interface"

# create the NWB object. this manages the file
print("Creating " + settings["filename"])
the XY delta for each imaging frame necessary to correct for motion.
A third time series is created pointing to the corrected image.
"""

########################################################################
# create a new NWB file
# several settings are specified when doing so. these can be supplied within
#   the NWB constructor or defined in a dict, as in in this example
settings = {}
settings["filename"] = "sample_motion_correction_2.nwb"

# each file should have a descriptive globally unique identifier 
#   that specifies the lab and this experiment session
# the function nwb.create_identifier() is recommended to use as it takes
#   the string and appends the present date and time
settings["identifier"] = nwb.create_identifier("motion correction example 2")

# indicate that it's OK to overwrite exting file
settings["overwrite"] = True

# specify the start time of the experiment. all times in the NWB file
#   are relative to experiment start time
# if the start time is not specified the present time will be used
settings["start_time"] = "Sat Jul 04 2015 3:14:16"

# provide one or two sentences that describe the experiment and what
#   data is in the file
settings["description"] = "Test file demonstrating use of the MotionCorrection interface with two cameras"

# create the NWB object. this manages the file
print("Creating " + settings["filename"])
import h5py
import sys
import nwb
import test_utils as ut
import time

# creates file and modifies it multiple times

if __file__.startswith("./"):
    fname = "x" + __file__[3:-3] + ".nwb"
else:
    fname = "x" + __file__[1:-3] + ".nwb"

settings = {}
settings["filename"] = fname
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)
Esempio n. 40
0
the XY delta for each imaging frame necessary to correct for motion.
A third time series is created pointing to the corrected image.
"""

########################################################################
# create a new NWB file
# several settings are specified when doing so. these can be supplied within
#   the NWB constructor or defined in a dict, as in in this example
settings = {}
settings["filename"] = "sample_motion_correction.nwb"

# each file should have a descriptive globally unique identifier
#   that specifies the lab and this experiment session
# the function nwb.create_identifier() is recommended to use as it takes
#   the string and appends the present date and time
settings["identifier"] = nwb.create_identifier("motion correction example")

# indicate that it's OK to overwrite exting file
settings["overwrite"] = True

# specify the start time of the experiment. all times in the NWB file
#   are relative to experiment start time
# if the start time is not specified the present time will be used
settings["start_time"] = "Sat Jul 04 2015 3:14:16"

# provide one or two sentences that describe the experiment and what
#   data is in the file
settings[
    "description"] = "Test file demonstrating use of the MotionCorrection interface"

# create the NWB object. this manages the file
Esempio n. 41
0
import sys
import nwb
from nwb.nwbco import *
import test_utils as ut
import time

# creates file and modifies it multiple times

if __file__.startswith("./"):
    fname = "x" + __file__[3:-3] + ".nwb"
else:
    fname = "x" + __file__[1:-3] + ".nwb"

settings = {}
settings["filename"] = fname
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.set_metadata(INSTITUTION, "Allen Institute for Brain Science")
neurodata.close()