pynapple.core.interval_set.IntervalSet.save#

IntervalSet.save(filename)[source]#

Save IntervalSet object in npz format. The file will contain the starts and ends.

The main purpose of this function is to save small/medium sized IntervalSet objects. For example, you determined some epochs for one session that you want to save to avoid recomputing them.

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

Parameters:

filename (str) – The filename

Examples

>>> import pynapple as nap
>>> import numpy as np
>>> ep = nap.IntervalSet(start=[0, 10, 20], end=[5, 12, 33])
>>> ep.save("my_ep.npz")

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

>>> ep = nap.load_file("my_path/my_ep.npz")
>>> ep
   start   end
0    0.0   5.0
1   10.0  12.0
2   20.0  33.0
Raises:

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