def get_running_speed(self) -> RunningSpeed: values = self.nwbfile.modules['running'].get_data_interface( 'speed').data[:] timestamps = self.nwbfile.modules['running'].get_data_interface( 'speed').timestamps[:] return RunningSpeed( timestamps=timestamps, values=values, )
def add_running_data_df_to_nwbfile(nwbfile, running_data_df, unit_dict, index_key='timestamps'): ''' Adds running speed data to an NWBFile as timeseries in acquisition and processing Parameters ---------- nwbfile : pynwb.NWBFile File to which runnign speeds will be written running_speed : pandas.DataFrame Contains 'speed' and 'times', 'v_in', 'vsig', 'dx' unit : str, optional SI units of running speed values Returns ------- nwbfile : pynwb.NWBFile ''' assert running_data_df.index.name == index_key running_speed = RunningSpeed(timestamps=running_data_df.index.values, values=running_data_df['speed'].values) add_running_speed_to_nwbfile(nwbfile, running_speed, name='speed', unit=unit_dict['speed']) running_mod = nwbfile.modules['running'] timestamps_ts = running_mod.get_data_interface('speed').timestamps running_dx_series = TimeSeries( name='dx', data=running_data_df['dx'].values, timestamps=timestamps_ts, unit=unit_dict['dx'] ) v_sig = TimeSeries( name='v_sig', data=running_data_df['v_sig'].values, timestamps=timestamps_ts, unit=unit_dict['v_sig'] ) v_in = TimeSeries( name='v_in', data=running_data_df['v_in'].values, timestamps=timestamps_ts, unit=unit_dict['v_in'] ) running_mod.add_data_interface(running_dx_series) nwbfile.add_acquisition(v_sig) nwbfile.add_acquisition(v_in) return nwbfile
def get_running_speed(self) -> RunningSpeed: """Get running speed using timestamps from self.get_stimulus_timestamps. NOTE: Do not correct for monitor delay. :returns: RunningSpeed -- a NamedTuple containing the subject's timestamps and running speeds (in cm/s) """ running_data_df = self.get_running_data_df() if running_data_df.index.name != "timestamps": raise DataFrameIndexError( f"Expected index to be named 'timestamps' but got " "'{running_data_df.index.name}'.") return RunningSpeed(timestamps=running_data_df.index.values, values=running_data_df.speed.values)
def get_running_speed(self, lowpass=True) -> RunningSpeed: """ Gets the running speed Parameters ---------- lowpass: bool Whether to return the running speed with lowpass filter applied or without Returns ------- RunningSpeed: The running speed """ interface_name = 'speed' if lowpass else 'speed_unfiltered' values = self.nwbfile.modules['running'].get_data_interface( interface_name).data[:] timestamps = self.nwbfile.modules['running'].get_data_interface( interface_name).timestamps[:] return RunningSpeed( timestamps=timestamps, values=values, )
def test_get_running_speed(MockBehaviorDataLimsApi): expected = RunningSpeed(timestamps=[0.0, 0.1, 0.2], values=[8.0, 15.0, 16.0]) api = MockBehaviorDataLimsApi actual = api.get_running_speed() assert expected == actual
def get_running_speed(self): running_data_df = self.get_running_data_df() assert running_data_df.index.name == 'timestamps' return RunningSpeed(timestamps=running_data_df.index.values, values=running_data_df.speed.values)
def running_speed(): from allensdk.brain_observatory.running_speed import RunningSpeed return RunningSpeed(timestamps=[1., 2., 3.], values=[4, 5, 6])