From faa88847bdd867cec0e313afc89bc1d7a9ff4fc7 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Sun, 31 Mar 2024 12:07:07 -0400 Subject: [PATCH] add docstrings for get_timestamps and get_data_in_units (#1878) --- src/pynwb/base.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/pynwb/base.py b/src/pynwb/base.py index 980d20d9a..4417c371f 100644 --- a/src/pynwb/base.py +++ b/src/pynwb/base.py @@ -328,12 +328,31 @@ def time_unit(self): return self.__time_unit def get_timestamps(self): + """ + Get the timestamps of this TimeSeries. If timestamps are not stored in this TimeSeries, generate timestamps. + """ if self.fields.get('timestamps'): return self.timestamps else: return np.arange(len(self.data)) / self.rate + self.starting_time def get_data_in_units(self): + """ + Get the data of this TimeSeries in the specified unit of measurement, applying the conversion factor and offset: + + .. math:: + out = data * conversion + offset + + If the field 'channel_conversion' is present, the conversion factor is applied to each channel separately: + + .. math:: + out_{channel} = data * conversion_{channel} + offset + + Returns + ------- + np.ndarray + + """ if "channel_conversion" in self.fields: scale_factor = self.conversion * self.channel_conversion[:, np.newaxis] else: