LabJack Examples

First we need to create our NWB object, we’ll use this generic one

 1from simply_nwb import SimpleNWB
 2import pendulum
 3from pynwb.file import Subject
 4
 5
 6def nwb_gen():
 7    return SimpleNWB.create_nwb(
 8        # Required
 9        session_description="Mouse cookie eating session",
10        # Subtract 1 year so we don't run into the 'NWB start time is at a greater date than current' issue
11        session_start_time=pendulum.now().subtract(years=1),
12        experimenter=["Schmoe, Joe"],
13        lab="Felsen Lab",
14        experiment_description="Gave a mouse a cookie",
15
16        # Optional
17        identifier="cookie_0",
18        subject=Subject(**{
19            "subject_id": "1",
20            "age": "P90D",  # ISO-8601 for 90 days duration
21            "strain": "TypeOfMouseGoesHere",  # If no specific used, 'Wild Strain'
22            "description": "Mouse#2 idk",
23            "sex": "M",  # M - Male, F - Female, U - unknown, O - other
24            # NCBI Taxonomy link or Latin Binomial (e.g.'Rattus norvegicus')
25            "species": "http://purl.obolibrary.org/obo/NCBITaxon_10116",
26        }),
27        session_id="session0",
28        institution="CU Anschutz",
29        keywords=["mouse"],
30
31        # related_publications="DOI::LINK GOES HERE FOR RELATED PUBLICATIONS"
32    )

An example usage of the labjack functions is as follows

 1from gen_nwb import nwb_gen
 2from simply_nwb.transforms import labjack_load_file
 3from simply_nwb import SimpleNWB
 4
 5
 6def nwb_labjack():
 7    # Not a true .dat file, should be .txt but whatever
 8    r = labjack_load_file("../data/labjack_data.dat")
 9    r2 = labjack_load_file("../data/labjack_data2.dat")
10
11    nwbfile = nwb_gen()
12
13    SimpleNWB.labjack_file_as_behavioral_data(
14        nwbfile,
15        labjack_filename="../data/labjack_data.dat",
16        name="labjack_file_1",
17        measured_unit_list=["idk units"]*9,  # 9 columns for data collected
18        start_time=0.0,
19        sampling_rate=1.0,
20        description="Sampled at 1hz some data description here",
21        behavior_module=None,
22        behavior_module_name=None,
23        comments="Labjack behavioral data"
24    )
25    t = nwbfile.processing["behavior"]["labjack_file_1_behavioral_events"]["Time"].data[:]
26    t = nwbfile.processing["behavior"]["labjack_file_1_behavioral_events"]["v0"].data
27    t = nwbfile.processing["behavior"]["labjack_file_1_metadata"]
28    t = nwbfile.processing["behavior"]["labjack_file_1_metadata"]["CH+"]
29    return nwbfile, []
30
31def loading_labjack_testing():
32    from simply_nwb.transforms.labjack import labjack_concat_files
33    from pathlib import Path
34    dats = list(Path("../data/anna/labjack").glob("*.dat"))
35    d = labjack_concat_files(dats)
36    tw = 2
37
38
39# if __name__ == "__main__":
40#     loading_labjack_testing()