def launch(self, matfile): mat = scipy.io.loadmat(matfile) hdr = mat['hdr'] fs, ns = [hdr[key][0, 0][0, 0] for key in ['Fs', 'nSamples']] # the entities to populate #ch = Sensors(storage_path=self.storage_path) ts = TimeSeries(storage_path=self.storage_path) # (nchan x ntime) -> (t, sv, ch, mo) dat = mat['dat'].T[:, numpy.newaxis, :, numpy.newaxis] # write data ts.write_data_slice(dat) # fill in header info ts.length_1d, ts.length_2d, ts.length_3d, ts.length_4d = dat.shape ts.labels_ordering = 'Time 1 Channel 1'.split() ts.write_time_slice(numpy.r_[:ns] * 1.0 / fs) ts.start_time = 0.0 ts.sample_period_unit = 's' ts.sample_period = 1.0 / float(fs) ts.close_file() # setup sensors information # ch.labels = numpy.array( # [str(l[0]) for l in hdr['label'][0, 0][:, 0]]) # ch.number_of_sensors = ch.labels.size return ts #, ch
def launch(self, matfile): mat = scipy.io.loadmat(matfile) hdr = mat['hdr'] fs, ns = [hdr[key][0, 0][0, 0] for key in ['Fs', 'nSamples']] # the entities to populate #ch = Sensors(storage_path=self.storage_path) ts = TimeSeries(storage_path=self.storage_path) # (nchan x ntime) -> (t, sv, ch, mo) dat = mat['dat'].T[:, numpy.newaxis, :, numpy.newaxis] # write data ts.write_data_slice(dat) # fill in header info ts.length_1d, ts.length_2d, ts.length_3d, ts.length_4d = dat.shape ts.labels_ordering = 'Time 1 Channel 1'.split() ts.write_time_slice(numpy.r_[:ns] * 1.0 / fs) ts.start_time = 0.0 ts.sample_period_unit = 's' ts.sample_period = 1.0 / float(fs) ts.close_file() # setup sensors information # ch.labels = numpy.array( # [str(l[0]) for l in hdr['label'][0, 0][:, 0]]) # ch.number_of_sensors = ch.labels.size return ts #, ch
def _create_timeseries(self): """Launch adapter to persist a TimeSeries entity""" storage_path = FilesHelper().get_project_folder(self.test_project, str(self.operation.id)) time_series = TimeSeries() time_series.sample_period = 10.0 time_series.start_time = 0.0 time_series.storage_path = storage_path time_series.write_data_slice(numpy.array([1.0, 2.0, 3.0])) time_series.close_file() time_series.sample_period_unit = 'ms' self._store_entity(time_series, "TimeSeries", "tvb.datatypes.time_series") count_ts = self.count_all_entities(TimeSeries) self.assertEqual(1, count_ts, "Should be only one TimeSeries")
def _create_timeseries(self): """Launch adapter to persist a TimeSeries entity""" storage_path = FilesHelper().get_project_folder(self.test_project, str(self.operation.id)) time_series = TimeSeries() time_series.sample_period = 10.0 time_series.start_time = 0.0 time_series.storage_path = storage_path time_series.write_data_slice(numpy.array([1.0, 2.0, 3.0])) time_series.close_file() time_series.sample_period_unit = 'ms' self._store_entity(time_series, "TimeSeries", "tvb.datatypes.time_series") count_ts = self.count_all_entities(TimeSeries) self.assertEqual(1, count_ts, "Should be only one TimeSeries")