def test_add_interval(self): data = [1.0, -1.0, 1.0, -1.0] timestamps = [0.0, 1.0, 2.0, 3.0] iS = IntervalSeries('test_iS', 'a hypothetical source', data=data, timestamps=timestamps) iS.add_interval(4.0, 5.0) data.append(1.0) data.append(-1.0) timestamps.append(4.0) timestamps.append(5.0) self.assertEqual(iS.data, data) self.assertEqual(iS.timestamps, timestamps)
def test_init(self): data = [1.0, -1.0, 1.0, -1.0] timestamps = [0.0, 1.0, 2.0, 3.0] iS = IntervalSeries('test_iS', data=data, timestamps=timestamps) self.assertEqual(iS.name, 'test_iS') self.assertEqual(iS.data, data) self.assertEqual(iS.timestamps, timestamps)
def test_init(self): data = [0, 1, 0, 1] iS = IntervalSeries('test_iS', 'a hypothetical source', data, timestamps=list()) bE = BehavioralEpochs('test_bE', iS) self.assertEqual(bE.source, 'test_bE') self.assertEqual(bE.interval_series, [iS])
def test_init(self): data = [0, 1, 0, 1] iS = IntervalSeries('test_iS', data, timestamps=[1., 2., 3.]) bE = BehavioralEpochs(iS) self.assertEqual(bE.interval_series['test_iS'], iS)
# Create the onset/offset data matrix stim_events_data = np.zeros(stim_events_time.shape, dtype=int) stim_events_data[:, 0] = 1 stim_events_data[:, 1] = -1 # Flatten both time and data stim_events_time = stim_events_time.flatten() stim_events_data = stim_events_data.flatten() # Create interval series print("\tCreating interval time series...") cur_stim_series = IntervalSeries( name=cur_stim_info['name'], description= 'Epochs of when stimulus %s was on screen. This is extracted from trial information.' % (cur_stim_info['name']), data=stim_events_data, timestamps=stim_events_time) # Add to interface print("\tAdding signal to interface...") stim_epoch_interface.add_interval_series(cur_stim_series) # Add interface to the NWB file print("Adding stimulus epochs to behavior module.") nwb_file.processing['behavior'].add(stim_epoch_interface) # Write to file and close print("Writing NWB file and closing.") NWBHelperFunctions.CloseNWBFile(nwb_file, nwb_io)