Skip to main content

Spike2PythonFormatLoader

Spike2PythonFormatLoader

Optional format loader for Spike2 files via Python SonPy. More…

#include <Spike2PythonFormatLoader.hpp>

Inherits from IFormatLoader

Public Functions

Name
Spike2PythonFormatLoader(PythonEngine & engine)
~Spike2PythonFormatLoader() override =default
virtual LoadResult load(std::string const & filepath, DM_DataType dataType, nlohmann::json const & config) const override
Load a single data object from file.
virtual bool supportsBatchLoading(std::string const & format, DM_DataType dataType) const override
Check if this loader supports batch loading for the given format/type.
virtual BatchLoadResult loadBatch(std::string const & filepath, DM_DataType dataType, nlohmann::json const & config) const override
Load multiple data objects from a single file.
virtual bool supportsFormat(std::string const & format, DM_DataType dataType) const override
Check if this loader supports the given format and data type.
virtual std::string getLoaderName() const override
Get the name of this loader (for logging/debugging).
virtual std::vector< LoaderInfo > getLoaderInfo() const override
Return metadata for all load operations this loader supports.

Additional inherited members

Public Functions inherited from IFormatLoader

Name
virtual ~IFormatLoader() =default
virtual LoadResult save(std::string const & , DM_DataType , nlohmann::json const & , void const * ) const
Save data to file (optional - not all loaders support saving).
virtual std::vector< SaverInfo > getSaverInfo() const
Return metadata for all save operations this loader supports.

Detailed Description

class Spike2PythonFormatLoader;

Optional format loader for Spike2 files via Python SonPy.

Phase 2 is a registration and dependency skeleton: it supports discovery, batch loading metadata, and clear errors when SonPy or the extraction helper is unavailable. Actual .smr/.smrx extraction is implemented in later phases.

Public Functions Documentation

function Spike2PythonFormatLoader

explicit Spike2PythonFormatLoader(
    PythonEngine & engine
)

function ~Spike2PythonFormatLoader

~Spike2PythonFormatLoader() override =default

function load

virtual LoadResult load(
    std::string const & filepath,
    DM_DataType dataType,
    nlohmann::json const & config
) const override

Load a single data object from file.

Parameters:

  • filepath Path to the file to load
  • dataType Type of data being loaded
  • config JSON configuration for loading

Return: LoadResult containing loaded data or error

Reimplements: IFormatLoader::load

For files containing multiple data objects (e.g., multi-channel binary), this method returns only the first object. Use loadBatch() for full multi-object support.

function supportsBatchLoading

virtual bool supportsBatchLoading(
    std::string const & format,
    DM_DataType dataType
) const override

Check if this loader supports batch loading for the given format/type.

Parameters:

  • format Format string (e.g., “binary”, “csv”)
  • dataType Type of data (e.g., DM_DataType::Analog)

Return: true if loadBatch() can return multiple objects for this combination

Reimplements: IFormatLoader::supportsBatchLoading

Batch loading allows a single file to produce multiple data objects. Examples: multi-channel binary files, multi-series CSV files, DLC files with multiple bodyparts.

function loadBatch

virtual BatchLoadResult loadBatch(
    std::string const & filepath,
    DM_DataType dataType,
    nlohmann::json const & config
) const override

Load multiple data objects from a single file.

Parameters:

  • filepath Path to the file to load
  • dataType Type of data being loaded
  • config JSON configuration for loading

Return: BatchLoadResult containing all loaded data objects

Reimplements: IFormatLoader::loadBatch

This method is used for files that contain multiple data objects, such as multi-channel binary recordings or CSV files with multiple series.

The default implementation wraps load() in a BatchLoadResult. Loaders that support multi-object files should override this method and return all objects in the file.

function supportsFormat

virtual bool supportsFormat(
    std::string const & format,
    DM_DataType dataType
) const override

Check if this loader supports the given format and data type.

Parameters:

Return: true if this loader can handle the format/dataType combination

Reimplements: IFormatLoader::supportsFormat

function getLoaderName

virtual std::string getLoaderName() const override

Get the name of this loader (for logging/debugging).

Reimplements: IFormatLoader::getLoaderName

function getLoaderInfo

virtual std::vector< LoaderInfo > getLoaderInfo() const override

Return metadata for all load operations this loader supports.

Return: Vector of LoaderInfo (one per supported format/dataType load combination). Empty by default.

Reimplements: IFormatLoader::getLoaderInfo

Subclasses should override this to advertise their loading capabilities with typed parameter schemas, enabling automatic UI generation via AutoParamWidget.


Updated on 2026-11-13 at 20:25:39 +0000