ContinuousSaver#

class ContinuousSaver(
save_path: Path,
chunk_duration__ms: Quantity__ms = 10000.0 * pq.ms,
populations: dict | None = None,
recording_config: dict | None = None,
)[source]#

Bases: object

Manages continuous saving of simulation data in chunks to prevent memory overflow.

Instead of accumulating all data in RAM, this class periodically saves chunks to disk and clears memory. Data can be loaded and combined afterward.

Parameters:
  • save_path (Path) – Directory where chunks will be saved

  • chunk_duration__ms (float) – Duration of each chunk in milliseconds (default: 10000 ms = 10 seconds)

  • populations (dict) – Dictionary of populations to record from

  • recording_config (dict) – Configuration like {“aMN”: [0, 10, 20, …]} for which cells to record

Methods

__init__

finalize

Save final chunk and spike data.

record_spike

Record a spike event.

record_step

Record data for current simulation timestep.

record_step(timestep__ms: float) None[source]#

Record data for current simulation timestep.

Call this from your step callback at each timestep.

Parameters:

timestep__ms (float) – Integration timestep in milliseconds

Return type:

None

record_spike(pop_name: str, cell_id: int, spike_time: float) None[source]#

Record a spike event.

Parameters:
  • pop_name (str) – Population name

  • cell_id (int) – Cell ID within population

  • spike_time (float) – Time of spike in milliseconds

Return type:

None

finalize(
timestep__ms: Quantity__ms,
spike_results=None,
) None[source]#

Save final chunk and spike data.

Call this after simulation completes.

Parameters:
  • timestep__ms (Quantity__ms) – Integration timestep in milliseconds

  • spike_results (NEO Block, optional) – NEO Block containing spike trains from SimulationRunner. If provided, spike data will be extracted and saved to chunks.

Return type:

None