def test_nwb_end_to_end(tmpdir_factory):
    oeid = 789359614
    nwb_filepath = os.path.join(str(tmpdir_factory.mktemp('test_nwb_end_to_end')), 'nwbfile.nwb')

    d1 = BehaviorOphysSession.from_lims(oeid)
    BehaviorOphysNwbApi(nwb_filepath).save(d1)

    d2 = BehaviorOphysSession(api=BehaviorOphysNwbApi(nwb_filepath))
    equals(d1, d2, reraise=True)
Beispiel #2
0
def write_behavior_ophys_nwb(session_data, nwb_filepath):

    nwb_filepath_inprogress = nwb_filepath + '.inprogress'
    nwb_filepath_error = nwb_filepath + '.error'

    # Clean out files from previous runs:
    for filename in [
            nwb_filepath_inprogress, nwb_filepath_error, nwb_filepath
    ]:
        if os.path.exists(filename):
            os.remove(filename)

    try:
        session = BehaviorOphysSession(api=BehaviorOphysJsonApi(session_data))
        BehaviorOphysNwbApi(nwb_filepath_inprogress).save(session)
        assert equals(
            session,
            BehaviorOphysSession(
                api=BehaviorOphysNwbApi(nwb_filepath_inprogress)))
        os.rename(nwb_filepath_inprogress, nwb_filepath)
        return {'output_path': nwb_filepath}
    except Exception as e:
        os.rename(nwb_filepath_inprogress, nwb_filepath_error)
        raise e
def test_equal(oeid1, oeid2, expected):
    d1 = BehaviorOphysSession.from_lims(oeid1)
    d2 = BehaviorOphysSession.from_lims(oeid2)

    assert equals(d1, d2) == expected