コード例 #1
0
def test_add_raw_running_data_to_nwbfile(nwbfile, raw_running_data, roundtripper, roundtrip):

    nwbfile = write_nwb.add_raw_running_data_to_nwbfile(nwbfile, raw_running_data)
    if roundtrip:
        api_obt = roundtripper(nwbfile, EcephysNwbSessionApi)
    else:
        api_obt = EcephysNwbSessionApi.from_nwbfile(nwbfile)

    obtained = api_obt.get_raw_running_data()

    expected = raw_running_data.rename(columns={"dx": "net_rotation", "vsig": "signal_voltage", "vin": "supply_voltage"})
    pd.testing.assert_frame_equal(expected, obtained, check_like=True)
コード例 #2
0
def test_add_probe_to_nwbfile(nwbfile, roundtripper, roundtrip, pid, name, srate, lfp_srate, has_lfp, expected):

    nwbfile, _, _ = write_nwb.add_probe_to_nwbfile(nwbfile, pid,
                                                   name=name,
                                                   sampling_rate=srate,
                                                   lfp_sampling_rate=lfp_srate,
                                                   has_lfp_data=has_lfp)
    if roundtrip:
        obt = roundtripper(nwbfile, EcephysNwbSessionApi)
    else:
        obt = EcephysNwbSessionApi.from_nwbfile(nwbfile)

    pd.testing.assert_frame_equal(expected, obt.get_probes(), check_like=True)
コード例 #3
0
def test_add_running_speed_to_nwbfile(nwbfile, running_speed, roundtripper, roundtrip, include_rotation):

    nwbfile = write_nwb.add_running_speed_to_nwbfile(nwbfile, running_speed)
    if roundtrip:
        api_obt = roundtripper(nwbfile, EcephysNwbSessionApi)
    else:
        api_obt = EcephysNwbSessionApi.from_nwbfile(nwbfile)

    obtained = api_obt.get_running_speed(include_rotation=include_rotation)

    expected = running_speed
    if not include_rotation:
        expected = expected.drop(columns="net_rotation")
    pd.testing.assert_frame_equal(expected, obtained, check_like=True)
コード例 #4
0
def test_add_eye_tracking_rig_geometry_data_to_nwbfile(nwbfile, roundtripper,
                                                       roundtrip,
                                                       eye_tracking_rig_geometry,
                                                       expected):

    nwbfile = write_nwb.add_eye_tracking_rig_geometry_data_to_nwbfile(nwbfile,
                                                                      eye_tracking_rig_geometry)
    if roundtrip:
        obt = roundtripper(nwbfile, EcephysNwbSessionApi)
    else:
        obt = EcephysNwbSessionApi.from_nwbfile(nwbfile)
    obtained_metadata = obt.get_rig_metadata()

    pd.testing.assert_frame_equal(obtained_metadata["geometry"], expected["geometry"], check_like=True)
    assert obtained_metadata["equipment"] == expected["equipment"]
コード例 #5
0
def test_add_probewise_data_to_nwbfile(monkeypatch, nwbfile, roundtripper,
                                       roundtrip, probes, parsed_probe_data,
                                       expected_units_table):
    def mock_parse_probes_data(probes):
        return parsed_probe_data

    monkeypatch.setattr(write_nwb, "parse_probes_data", mock_parse_probes_data)
    nwbfile = write_nwb.add_probewise_data_to_nwbfile(nwbfile, probes)

    if roundtrip:
        obt = roundtripper(nwbfile, EcephysNwbSessionApi)
    else:
        obt = EcephysNwbSessionApi.from_nwbfile(nwbfile)

    pd.testing.assert_frame_equal(obt.nwbfile.units.to_dataframe(),
                                  expected_units_table)
コード例 #6
0
def test_add_eye_tracking_data_to_nwbfile(nwbfile, roundtripper, roundtrip,
                                          eye_tracking_frame_times,
                                          eye_dlc_tracking_data,
                                          eye_gaze_data,
                                          expected_pupil_data, expected_gaze_data):
    nwbfile = write_nwb.add_eye_tracking_data_to_nwbfile(nwbfile,
                                                         eye_tracking_frame_times,
                                                         eye_dlc_tracking_data,
                                                         eye_gaze_data)

    if roundtrip:
        obt = roundtripper(nwbfile, EcephysNwbSessionApi)
    else:
        obt = EcephysNwbSessionApi.from_nwbfile(nwbfile)
    obtained_pupil_data = obt.get_pupil_data()
    obtained_screen_gaze_data = obt.get_screen_gaze_data(include_filtered_data=True)

    pd.testing.assert_frame_equal(obtained_pupil_data,
                                  expected_pupil_data, check_like=True)
    pd.testing.assert_frame_equal(obtained_screen_gaze_data,
                                  expected_gaze_data, check_like=True)