Skip to content

apps.open_ephys

OpenEphysAppSettings

Bases: ServiceSettings

Settings for Open Ephys App.

settings_customise_sources classmethod

settings_customise_sources(
    settings_cls: Type[BaseSettings],
    init_settings: PydanticBaseSettingsSource,
    env_settings: PydanticBaseSettingsSource,
    dotenv_settings: PydanticBaseSettingsSource,
    file_secret_settings: PydanticBaseSettingsSource,
) -> Tuple[PydanticBaseSettingsSource, ...]

Customizes the settings sources to include the safe YAML settings source.

Parameters:

Name Type Description Default
settings_cls Type[BaseSettings]

The settings class

required
init_settings PydanticBaseSettingsSource

The initial settings source

required
env_settings PydanticBaseSettingsSource

The environment settings source

required
dotenv_settings PydanticBaseSettingsSource

The dotenv settings source

required
file_secret_settings PydanticBaseSettingsSource

The file secret settings source

required

Returns:

Type Description
Tuple[PydanticBaseSettingsSource, ...]

Tuple[PydanticBaseSettingsSource, ...]: A tuple of settings sources

Source code in src/clabe/services.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
@classmethod
def settings_customise_sources(
    cls,
    settings_cls: t.Type[ps.BaseSettings],
    init_settings: ps.PydanticBaseSettingsSource,
    env_settings: ps.PydanticBaseSettingsSource,
    dotenv_settings: ps.PydanticBaseSettingsSource,
    file_secret_settings: ps.PydanticBaseSettingsSource,
) -> t.Tuple[ps.PydanticBaseSettingsSource, ...]:
    """
    Customizes the settings sources to include the safe YAML settings source.

    Args:
        settings_cls: The settings class
        init_settings: The initial settings source
        env_settings: The environment settings source
        dotenv_settings: The dotenv settings source
        file_secret_settings: The file secret settings source

    Returns:
        Tuple[PydanticBaseSettingsSource, ...]: A tuple of settings sources
    """
    return (
        init_settings,
        *(
            _SafeYamlSettingsSource(settings_cls, yaml_file=p, yaml_config_section=cls.__yml_section__)
            for p in KNOWN_CONFIG_FILES
        ),
        env_settings,
        dotenv_settings,
        file_secret_settings,
    )

OpenEphysApp

OpenEphysApp(
    settings: OpenEphysAppSettings,
    skip_validation: bool = False,
)

Bases: ExecutableApp, _DefaultExecutorMixin

A class to manage the execution of Open Ephys GUI.

Handles Open Ephys GUI execution, configuration management, and process monitoring for ephys experiments.

Methods:

Name Description
run

Executes the Open Ephys GUI

get_result

Retrieves the result of the Open Ephys execution

add_app_settings

Adds or updates application settings

validate

Validates the Open Ephys application configuration

Initializes the OpenEphysApp instance.

Parameters:

Name Type Description Default
settings OpenEphysAppSettings

Settings for the Open Ephys App

required
ui_helper

UI helper instance. Defaults to DefaultUIHelper

required
client

Optional Open Ephys GUI client

required
**kwargs

Additional keyword arguments

required
Example
# Create and run a Open Ephys app
app = OpenEphysApp(settings=OpenEphysAppSettings(signal_chain="signal_chain.xml"))
app.run()
Source code in src/clabe/apps/open_ephys.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def __init__(
    self,
    settings: OpenEphysAppSettings,
    skip_validation: bool = False,
) -> None:
    """
    Initializes the OpenEphysApp instance.

    Args:
        settings: Settings for the Open Ephys App
        ui_helper: UI helper instance. Defaults to DefaultUIHelper
        client: Optional Open Ephys GUI client
        **kwargs: Additional keyword arguments

    Example:
        ```python
        # Create and run a Open Ephys app
        app = OpenEphysApp(settings=OpenEphysAppSettings(signal_chain="signal_chain.xml"))
        app.run()
        ```
    """
    self.settings = settings
    self.signal_chain = Path(self.settings.signal_chain).resolve()
    self.executable = Path(self.settings.executable).resolve()
    self._client = _OpenEphysGuiClient(host=self.settings.address, port=self.settings.port)

    if not skip_validation:
        self.validate()

    self._command = Command[CommandResult](
        cmd=[str(self.executable), str(self.signal_chain)], output_parser=identity_parser
    )

command property

Get the command to execute.

client property

client: _OpenEphysGuiClient

Get the Open Ephys GUI client.

validate

validate()

Validates the existence of required files and directories.

Raises:

Type Description
FileNotFoundError

If any required file or directory is missing

Source code in src/clabe/apps/open_ephys.py
75
76
77
78
79
80
81
82
83
84
85
def validate(self):
    """
    Validates the existence of required files and directories.

    Raises:
        FileNotFoundError: If any required file or directory is missing
    """
    if not Path(self.executable).exists():
        raise FileNotFoundError(f"Executable not found: {self.executable}")
    if not Path(self.signal_chain).exists():
        raise FileNotFoundError(f"Signal chain file not found: {self.signal_chain}")

run

run(
    executor_kwargs: Optional[dict[str, Any]] = None,
) -> CommandResult

Execute the command using a local executor and return the result.

Source code in src/clabe/apps/_executors.py
280
281
282
283
def run(self: ExecutableApp, executor_kwargs: Optional[dict[str, Any]] = None) -> CommandResult:
    """Execute the command using a local executor and return the result."""
    executor = LocalExecutor(**(executor_kwargs or {}))
    return self.command.execute(executor)

run_async async

run_async(
    executor_kwargs: Optional[dict[str, Any]] = None,
) -> CommandResult

Execute the command asynchronously using a local executor and return the result.

Source code in src/clabe/apps/_executors.py
285
286
287
288
async def run_async(self: ExecutableApp, executor_kwargs: Optional[dict[str, Any]] = None) -> CommandResult:
    """Execute the command asynchronously using a local executor and return the result."""
    executor = AsyncLocalExecutor(**(executor_kwargs or {}))
    return await self.command.execute_async(executor)

Status

Bases: str, Enum

GUI acquisition/recording mode.

StatusResponse

Bases: BaseModel

Response from /api/status endpoint.

StatusRequest

Bases: BaseModel

Request to set GUI acquisition/recording mode.

RecordNode

Bases: BaseModel

Information about a Record Node.

RecordingResponse

Bases: BaseModel

Response from /api/recording endpoint.

RecordingRequest

Bases: BaseModel

Request to update recording configuration.

RecordNodeRequest

Bases: BaseModel

Request to update a specific Record Node.

Stream

Bases: BaseModel

Data stream information.

Processor

Bases: BaseModel

Processor/plugin information.

ProcessorsResponse

Bases: BaseModel

Response from /api/processors endpoint.

ConfigRequest

Bases: BaseModel

Request to send configuration message to a processor.

MessageRequest

Bases: BaseModel

Request to broadcast a message to all processors.

WindowRequest

Bases: BaseModel

Request to control GUI window.