rtcog.processor package

Submodules

rtcog.processor.basic_processor module

class rtcog.processor.basic_processor.BasicProcessor(options, sync, **kwargs)[source]

Bases: object

Class representing a real-time fMRI processor.

This class handles the setup of the data processing stream, initialization of the preprocessing pipeline, and the management of incoming data from the scanner.

Parameters:
  • options (Options) – Configuration object containing experiment parameters (e.g., TR, number of volumes, paths).

  • sync (SyncEvents) – Container for multiprocessing synchronization primitives used in experiment.

compute_TR_data(motion, extra)[source]

Public wrapper for TR processing with logging.

Parameters:
  • motion (list of list[float]) – 6 motion parameters per TR.

  • extra (list of list[float]) – Voxel-wise time series.

Returns:

Always returns 1 (for compatibility with callback interface).

Return type:

int

end_run(save=True)[source]

Finalize experiment and optionally save outputs.

Parameters:

save (bool) – Whether to save final outputs (default: True).

rtcog.processor.esam_processor module

class rtcog.processor.esam_processor.ESAMProcessor(options, sync, minimal=False)[source]

Bases: BasicProcessor

Real-time fMRI processor class supporting experience sampling (ESAM) mode.

Extends Processor with template matching, hit detection, action state tracking, and dynamic Panel-based GUI streaming.

Parameters:
  • options (Options) – Experiment configuration options.

  • sync (SyncEvents) – Multiprocessing event signals for synchronization.

  • minimal (bool, optional) – If True, generate a static score report at the end.

lastaction_endTR

Most recent action offset TR.

Type:

int

matcher

Template matcher instance.

Type:

Matcher

shared_tr_data

Shared memory array for matched volumes.

Type:

np.ndarray

shared_action_onsets

Shared list of action onsets.

Type:

ListProxy

shared_action_offsets

Shared list of action offsets.

Type:

ListProxy

hits

Hit detection matrix [template x TR].

Type:

np.ndarray

compute_TR_data(motion, extra)[source]

Process one TR in ESAM mode with template matching and hit detection.

Parameters:
  • motion (list of list[float]) – 6 motion parameters per TR.

  • extra (list of list[float]) – Voxel-wise time series.

Returns:

Always returns 1.

Return type:

int

end_run(save=True)[source]

Finalize the experiment, including file output and memory cleanup.

Parameters:

save (bool) – Whether to save final output files (default: True).

get_enabled_step_config(step_name)[source]

Return config dict for enabled pipeline step by name.

Parameters:

step_name (str) – Name of the step (e.g., “windowing”).

Returns:

Step config dictionary if enabled, otherwise None.

Return type:

dict or None

start_streaming(shared_responses)[source]

Launch background Panel streaming server for real-time visualization.

Parameters:

shared_responses (DictProxy) – Shared-memory dictionary for real-time participant responses.

write_action()[source]

Save action onsets and offsets to plain-text files.

write_hit_arrays()[source]

Save match scores and hit arrays

write_hit_maps()[source]

Write out the maps associated with the hits

write_report()[source]

Module contents

Classes for orchestrating the flow of data processing.