skneuromsi.core.dresult.result module

Utilities to represents a multisensory integration result as a multidimensional array.

skneuromsi.core.ndresult.result.modes_to_data_array(modes_dict, dtype)[source]

Convert a dictionary of modes to an xarray.DataArray.

Parameters:
  • modes_dict (dict) – A dictionary of modes and their corresponding coordinates.

  • dtype (numpy.dtype, optional) – The data type of the resulting xarray.DataArray.

Returns:

The modes as an xarray.DataArray.

Return type:

xarray.DataArray

class skneuromsi.core.ndresult.result.NDResult(*, mname, mtype, output_mode, nmap, nddata, time_range, position_range, time_res, position_res, causes, run_parameters, extra, ensure_dtype=None)[source]

Bases: object

Represents a multisensory integration result.

Parameters:
  • mname (str) – The name of the model.

  • mtype (str) – The type of the model.

  • output_mode (str) – The output mode of the model.

  • nmap (dict) – A dictionary mapping modes to their corresponding values.

  • nddata (xarray.DataArray or dict) – The multidimensional data as an xarray.DataArray.

  • time_range (tuple) – The range of time values.

  • position_range (tuple) – The range of position values.

  • time_res (float) – The resolution of time values.

  • position_res (float) – The resolution of position values.

  • causes (int, float or None) – The number of causes in the result.

  • run_parameters (dict) – The parameters used for running the model.

  • extra (dict) – Extra information associated with the result.

  • ensure_dtypes (numpy.dtype, optional (default=infer)) – Force all data types to be assigned to this type. This only applies to parameters that accept the dtype message If None, the data types are inferred.

classmethod from_modes_dict(*, modes_dict, ensure_dtype=None, **kwargs)[source]

Create an NDResult object from a dictionary of modes.

Parameters:
  • modes_dict (dict) – A dictionary mapping modes to their corresponding values.

  • ensure_dtype (numpy.dtype, optional) – Force all data types to be assigned to this type. This only applies to parameters that accept the dtype message If None, the data types are inferred.

  • **kwargs – Additional keyword arguments to pass to the NDResult constructor.

Returns:

The NDResult object.

Return type:

NDResult

property mname

The name of the model.

Type:

str

property mtype

The type of the model.

Type:

str

property output_mode

The output mode of the model.

Type:

str

property dims

The dimensions of the result data.

Type:

list

property nmap_

A copy of the nmap dictionary.

Type:

dict

property time_range

The range of time values.

Type:

tuple

property position_range

The range of position values.

Type:

tuple

property time_res

The resolution of time values.

Type:

float

property position_res

The resolution of position values.

Type:

float

property run_parameters

The parameters used for running the model.

Type:

Bunch

property rp

The parameters used for running the model.

Type:

Bunch

property extra_

Extra information associated with the result.

Type:

Bunch

property e_

Extra information associated with the result.

Type:

Bunch

property causes_

The number of causes in the result.

Type:

int

property modes_

The modes of the result data.

Type:

numpy.ndarray

property times_

The time values of the result data.

Type:

numpy.ndarray

property positions_

The position values of the result data.

Type:

numpy.ndarray

property positions_coordinates_

The position coordinates of the result data.

Type:

numpy.ndarray

property pcoords_

The position coordinates of the result data.

Type:

numpy.ndarray

property plot

Plot accessor for the NDResult object.

Type:

ResultPlotter

property stats

Stats accessor for the NDResult object.

Type:

ResultStatsAccessor

get_modes(*, include=None)[source]

Get the modes of the result data as a DataFrame.

Parameters:

include (str, int, float, numpy.number, Iterable, or None, optional) – The modes to include in the DataFrame. If None, all modes are included.

Returns:

The modes as a DataFrame.

Return type:

pandas.DataFrame

get_times(*, include=None)[source]

Get the time values of the result data as a DataFrame.

Parameters:

include (str, int, float, numpy.number, Iterable, or None, optional) – The time values to include in the DataFrame. If None, all time values are included.

Returns:

The time values as a DataFrame.

Return type:

pandas.DataFrame

get_positions(*, include=None)[source]

Get the position values of the result data as a DataFrame.

Parameters:

include (str, int, float, numpy.number, Iterable, or None, optional) – The position values to include in the DataFrame. If None, all position values are included.

Returns:

The position values as a DataFrame.

Return type:

pandas.DataFrame

get_positions_coordinates(*, include=None)[source]

Get the position coordinates of the result data as a DataFrame.

Parameters:

include (str, int, float, numpy.number, Iterable, or None, optional) – The position coordinates to include in the DataFrame. If None, all position coordinates are included.

Returns:

The position coordinates as a DataFrame.

Return type:

pandas.DataFrame

get_pcoords(*, include=None)

Get the position coordinates of the result data as a DataFrame.

Parameters:

include (str, int, float, numpy.number, Iterable, or None, optional) – The position coordinates to include in the DataFrame. If None, all position coordinates are included.

Returns:

The position coordinates as a DataFrame.

Return type:

pandas.DataFrame

to_xarray()[source]

Return a copy of the result data as an xarray.DataArray.

to_dict()[source]

Convert the NDResult object to a dictionary.

Returns:

The NDResult object as a dictionary.

Return type:

dict

to_ndr(path_or_stream, metadata=None, **kwargs)[source]

Store the NDResult object in NMSI Result (NDR) format.

Parameters:
  • path_or_stream (str or file-like object) – The path or file-like object to store the NDR data.

  • metadata (dict, optional) – Additional metadata to include in the NDR data.

  • **kwargs – Additional keyword arguments to pass to the NDR storage function.

astype(dtype, *, attributes=None)[source]

Return a copy of the NDResult object with the specified data type.

Parameters:
  • dtype (data type) – The data type to convert the NDResult object to.

  • attributes (list of str, optional) – The names of the attributes to convert. If None, all attributes

Returns:

The NDResult object with the specified data type.

Return type:

NDResult

deep_dtypes(*, max_deep=2, memory_usage=False)[source]

Returns the deep data types of the object.

Parameters:
  • max_deep (int, optional) – The maximum depth to traverse the object. Defaults to 2.

  • memory_usage (bool, optional) – If True, return the memory usage of the object. Defaults to False.

Returns:

The deep data types of the object.

Return type:

dict

dtypes(*, memory_usage=False)[source]

pd.DataFrame containing the data types of each attribute in the NDResult object.