pynapple.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_ep.npz")
>>> ep
  index    start    end
      0        0      5
      1       10     12
      2       20     33
shape: (3, 2), time unit: sec.
Raises:

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