MP4 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 mp4 functions is as follows

 1from simply_nwb import SimpleNWB
 2from simply_nwb.transforms import mp4_read_data
 3from gen_nwb import nwb_gen
 4
 5
 6def nwb_mp4_test():
 7    data, frames = mp4_read_data("../data/smallmp4.mp4")
 8    nwb = nwb_gen()
 9    SimpleNWB.mp4_add_as_acquisition(
10        nwb,
11        name="TestMovie",
12        numpy_data=data,
13        frame_count=frames,
14        sampling_rate=30.0,  # Frames per second
15        description="asdf description here"
16    )
17    SimpleNWB.mp4_add_as_acquisition(
18        nwb,
19        name="TestMovie2",
20        numpy_data=data,
21        frame_count=frames,
22        sampling_rate=30.0,  # Frames per second
23        description="asdf description here"
24    )
25    tw = 2
26
27    data = nwb.acquisition["TestMovie"].data
28    data = nwb.acquisition["TestMovie2"].data[:]  # To Numpy array
29    return nwb, []