Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add docstrings for get_timestamps and get_data_in_units #1878

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/pynwb/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading