pynapple.core.time_series.Tsd.save#

Tsd.save(filename)[source]#

Save Tsd object in npz format. The file will contain the timestamps, the data and the time support.

The main purpose of this function is to save small/medium sized time series objects. For example, you extracted one channel from your recording and filtered it. You can save the filtered channel as a npz to avoid reprocessing it.

You can load the object with nap.load_file. Keys are ‘t’, ‘d’, ‘start’, ‘end’ and ‘type’. See the example below.

Parameters:

filename (str) – The filename

Examples

>>> import pynapple as nap
>>> import numpy as np
>>> tsd = nap.Tsd(t=np.array([0., 1.]), d = np.array([2, 3]))
>>> tsd.save("my_path/my_tsd.npz")

To load you file, you can use the nap.load_file function :

>>> tsd = nap.load_file("my_path/my_tsd.npz")
>>> tsd
Time (s)
0.0    2
1.0    3
dtype: int64
Raises:

RuntimeError – If filename is not str, path does not exist or filename is a directory.