def from_nwb(cls, nwbfile: NWBFile, **kwargs) -> "BehaviorSession": behavior_session_id = BehaviorSessionId.from_nwb(nwbfile) stimulus_timestamps = StimulusTimestamps.from_nwb(nwbfile) running_acquisition = RunningAcquisition.from_nwb(nwbfile) raw_running_speed = RunningSpeed.from_nwb(nwbfile, filtered=False) running_speed = RunningSpeed.from_nwb(nwbfile) metadata = BehaviorMetadata.from_nwb(nwbfile) licks = Licks.from_nwb(nwbfile=nwbfile) rewards = Rewards.from_nwb(nwbfile=nwbfile) stimuli = Stimuli.from_nwb(nwbfile=nwbfile) task_parameters = TaskParameters.from_nwb(nwbfile=nwbfile) trials = TrialTable.from_nwb(nwbfile=nwbfile) date_of_acquisition = DateOfAcquisition.from_nwb(nwbfile=nwbfile) return BehaviorSession(behavior_session_id=behavior_session_id, stimulus_timestamps=stimulus_timestamps, running_acquisition=running_acquisition, raw_running_speed=raw_running_speed, running_speed=running_speed, metadata=metadata, licks=licks, rewards=rewards, stimuli=stimuli, task_parameters=task_parameters, trials=trials, date_of_acquisition=date_of_acquisition)
def test_stimulus_timestamps_nwb_roundtrip( nwbfile, data_object_roundtrip_fixture, roundtrip, stimulus_timestamps_data ): stimulus_timestamps = StimulusTimestamps( timestamps=stimulus_timestamps_data ) nwbfile = stimulus_timestamps.to_nwb(nwbfile) if roundtrip: obt = data_object_roundtrip_fixture(nwbfile, StimulusTimestamps) else: obt = StimulusTimestamps.from_nwb(nwbfile) assert np.allclose(obt.value, stimulus_timestamps_data)