def test_init(self): ts = TimeSeries('test_ts', list(), 'unit', timestamps=list()) iS = IndexSeries('test_iS', list(), 'unit', ts, timestamps=list()) self.assertEqual(iS.name, 'test_iS') self.assertEqual(iS.unit, 'unit') self.assertEqual(iS.indexed_timeseries, ts)
def test_show_index_series(): data = np.array([12, 14, 16, 18, 20, 22, 24, 26]) indexed_timeseries = TimeSeries(name='Index Series time data', data=np.random.rand(800).reshape((8, 10, 10)), rate=1.) index_series = IndexSeries(name='Sample Index Series', data=data, indexed_timeseries=indexed_timeseries, rate=1.) assert isinstance(show_index_series(index_series, default_neurodata_vis_spec), widgets.Widget)
def add_stimulus_index(nwbfile, stimulus_index, nwb_template): image_index = IndexSeries(name=nwb_template.name, data=stimulus_index['image_index'].values, unit='None', indexed_timeseries=nwb_template, timestamps=stimulus_index['start_time'].values) nwbfile.add_stimulus(image_index)
def test_init(self): ts = TimeSeries(name='test_ts', data=[1, 2, 3], unit='unit', timestamps=[0.1, 0.2, 0.3]) iS = IndexSeries(name='test_iS', data=[1, 2, 3], unit='N/A', indexed_timeseries=ts, timestamps=[0.1, 0.2, 0.3]) self.assertEqual(iS.name, 'test_iS') self.assertEqual(iS.unit, 'N/A') self.assertIs(iS.indexed_timeseries, ts)
######################################## # 2) Next, we add stimuli templates (one for each type of stimulus), and a data series that indexes these templates to # describe what stimulus was being shown during the experiment. for stimulus in stimulus_list: visual_stimulus_images = ImageSeries( name=stimulus, source='NA', data=dataset.get_stimulus_template(stimulus), unit='NA', format='raw', timestamps=[0.0]) image_index = IndexSeries( name=stimulus, source='NA', data=dataset.get_stimulus_table(stimulus).frame.values, unit='NA', indexed_timeseries=visual_stimulus_images, timestamps=timestamps[dataset.get_stimulus_table( stimulus).start.values]) nwbfile.add_stimulus_template(visual_stimulus_images) nwbfile.add_stimulus(image_index) ######################################## # 3) Besides the two-photon calcium image stack, the running speed of the animal was also recordered in this experiment. # We can store this data as a TimeSeries, in the acquisition portion of the file. running_speed = TimeSeries(name='running_speed', source='Allen Brain Observatory: Visual Coding', data=running_data, timestamps=timestamps, unit='cm/s')