Docstring Reference¶
This is the auto-generated docstring reference for the ct-neat-python package.
The ctneat.ctrnn Continuous-Time Recurrent Neural Network Module¶
This module implements Continuous-Time Recurrent Neural Networks (CTRNNs).
- class ctneat.ctrnn.CTRNN(inputs: List[int], outputs: List[int], node_evals: Dict[int, CTRNNNodeEval], custom_advance: Callable | None = None)[source]¶
Sets up the ctrnn network itself.
- __init__(inputs: List[int], outputs: List[int], node_evals: Dict[int, CTRNNNodeEval], custom_advance: Callable | None = None)[source]¶
Initialize the CTRNN with the given input and output nodes, and node evaluations. :param inputs: The input node IDs. :param outputs: The output node IDs. :param node_evals: A dictionary mapping node IDs to their evaluations (CTRNNNodeEval objects). :param custom_advance: An optional custom advance function.
- advance(inputs: List[float], advance_time: float, time_step: float | None = None)[source]¶
Advance the simulation by the given amount of time, assuming that inputs are constant at the given values during the simulated time. :param inputs: The input values to the network. :param advance_time: The amount of time to advance the simulation. :param time_step: The time step to use for the simulation.
- Returns:
The output values of the network after the simulation.
- static create(genome, config, time_constant)[source]¶
Receives a genome and returns its phenotype (a CTRNN). :param genome: The genome to create the CTRNN from. :param config: The configuration object. :param time_constant: The time constant to use for all nodes.
- class ctneat.ctrnn.CTRNNNodeEval(time_constant: float, activation: Callable, aggregation: Callable, bias: float, response: float, links: List[Tuple[int, float]])[source]¶
- __init__(time_constant: float, activation: Callable, aggregation: Callable, bias: float, response: float, links: List[Tuple[int, float]])[source]¶
Initialize a CTRNN node evaluation. :param time_constant: The time constant of the node. :param activation: The activation function of the node. :param aggregation: The aggregation function of the node. :param bias: The bias term of the node. :param response: The response term of the node. :param links: The links from other nodes (incoming connections).
The ctneat.ctrnn.ctrnn_visualize CTRNN Visualization Module¶
This module provides functions to visualize the dynamics and trajectories of CTRNNs.
This file contains functions used to visualize the CTRNN model.
- ctneat.ctrnn.ctrnn_visualize.draw_ctrnn_dynamics(states: ndarray, uniform_time: bool = True, times: ndarray | list | None = None, iznn: bool | None = False, save: bool = False, show: bool = True, dir_name: str | None = 'ctneat_outputs', file_name: str | None = None) None[source]¶
This function draws the dynamics of the CTRNN over time.
- Parameters:
states – A 2D numpy array where each row corresponds to the state of the network at a given time step, and each column corresponds to a specific node’s state.
uniform_time – Whether the time steps are uniform. If True, the function generates a uniform time array.
times – If uniform_time is False, a list or numpy array of time points corresponding to each row in states. If uniform_time is True, this parameter is ignored.
iznn – Whether the network is an Izhikevich spiking neural network (IZNN). If True, the function gives correct labels.
save – Whether to save the plot as a file. If False, the plot is shown interactively.
show – Whether to display the plot interactively. If False, the plot is only saved to a file if ‘save’ is True.
dir_name – Optional directory name to save the output file. If None, saves in the current directory.
file_name – Optional file name to save the output file. If None, defaults to ‘ctrnn_dynamics’.
- Returns:
None
- ctneat.ctrnn.ctrnn_visualize.draw_ctrnn_net(node_list: list, node_inputs: dict, iznn: bool | None = False, dir_name: str | None = 'ctneat_outputs', file_name: str | None = None) None[source]¶
This function draws the CTRNN network structure.
- Parameters:
node_list – A list of node IDs in the network.
node_inputs – A dictionary where keys are node IDs and values are lists of input connections for each node. (I.e. each list contains tuples of (input_node_id, weight) for the node with the corresponding ID)
iznn – Whether the network is an Izhikevich spiking neural network (IZNN). If True, the function gives correct labels.
dir_name – Optional directory name to save the output file. If None, saves in the current directory.
file_name – Optional file name to save the output file. If None, defaults to ‘ctrnn_network’.
- Returns:
None
- ctneat.ctrnn.ctrnn_visualize.draw_ctrnn_trajectory(states: ndarray, n_components: int = 2, iznn: bool | None = False, save: bool = False, show: bool = True, dir_name: str | None = 'ctneat_outputs', file_name: str | None = None) None[source]¶
This function draws a trajectory of the CTRNN’s state space. If there are more than ‘n_components’ nodes, the PCA is used to reduce the dimensionality to ‘n_components’.
- Parameters:
states – A 2D numpy array where each row corresponds to the state of the network at a given time step,
state. (and each column corresponds to a specific node's)
n_components – The number of components to reduce to (default is 2, max is 3). Note that if n_components is equal to 1 and the number of nodes is also 1, this function is equivalent to draw_ctrnn_dynamics.
iznn – Whether the network is an Izhikevich spiking neural network (IZNN). If True, the function gives correct labels.
save – Whether to save the plot as a file. If False, the plot is shown interactively.
show – Whether to display the plot interactively. If False, the plot is only saved to a file if ‘save’ is True.
dir_name – Optional directory name to save the output file. If None, saves in the current directory.
file_name – Optional file name to save the output file. If None, defaults to ‘ctrnn_face_portrait’.
- Returns:
None
- Raises:
ValueError – If n_components is not 1, 2, or 3.
The ctneat.iznn Spiking Neuron Module¶
This module implements the Izhikevich neuron model and network.
- class ctneat.iznn.IZNN(neurons: Dict[int, IZNeuron], inputs: List[int], outputs: List[int], event_driven: bool = False)[source]¶
Basic iznn network object.
- __init__(neurons: Dict[int, IZNeuron], inputs: List[int], outputs: List[int], event_driven: bool = False)[source]¶
Initializes the IZNN with the given neurons, inputs, and outputs.
- advance(dt: float, method: str | None = 'LSODA', events: bool = False, ret: List[str] | str | None = None) List[float] | List[List[float]][source]¶
Advances the simulation by the given time step in milliseconds.
- Parameters:
dt_msec (float) – The time step in milliseconds.
method (str) –
The integration method to use. If None, uses manually written RK4, otherwise defaults to SciPy’s LSODA. If specified, uses SciPy’s solve_ivp with the given method. Valid methods are listed in the SciPy documentation for solve_ivp (https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html). And here is a summary of available methods:
’RK45’ (Default): An adaptive Runge-Kutta method of order 5(4). It’s a great general-purpose choice and a good starting point.
’RK23’: A lower-order adaptive Runge-Kutta method. Faster but less accurate than RK45.
’DOP853’: A high-order (8th) adaptive Runge-Kutta method for when you need very high precision.
- ’LSODA’: This is a particularly important one for spiking neurons. It’s a solver that automatically
switches between methods for non-stiff and stiff problems. A “stiff” ODE is one where some parts of the solution change very rapidly while others change slowly (like the membrane potential during a spike!). LSODA is often very efficient and stable for these kinds of systems.
’BDF’ and ‘Radau’: Other excellent methods for stiff problems.
events (bool) – Whether to use event detection for spikes. Only applicable if ‘method’ is specified.
ret (list(str) or str or None) –
Specifies what to return. If a list of strings, returns a list of lists, where each inner list corresponds to the requested attribute for all output neurons. If a single string, returns a list corresponding to the requested attribute for all output neurons. If None, returns a list of firing states for all output neurons. Valid strings are:
’fired’ - returns the firing states (1.0 if fired, 0.0 otherwise) ‘voltages’ - returns the membrane potentials (in millivolts) ‘recovery’ - returns the recovery variables ‘all’ - returns a list of lists: [fired states, voltages, recovery variables]
- Returns:
A list or a list of lists as specified by the ‘ret’ parameter.
- Raises:
ValueError – If an invalid integration method is specified.
- advance_event_driven(dt_msec: float, method: str = 'LSODA', ret: List[str] | str | None = None) List[float] | List[List[float]][source]¶
Advances the simulation by at most dt_msec using a true event-driven approach.
The simulation advances to the time of the earliest spike event in the network, or by the full dt_msec if no spikes occur in that interval. This ensures that spike timing is captured with high precision.
- Parameters:
dt_msec (float) – The maximum time step to advance in milliseconds.
method (str) –
The integration method to use. If None, uses manually written RK4, otherwise defaults to SciPy’s LSODA. If specified, uses SciPy’s solve_ivp with the given method. Valid methods are listed in the SciPy documentation for solve_ivp (https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html). And here is a summary of available methods:
’RK45’ (Default): An adaptive Runge-Kutta method of order 5(4). It’s a great general-purpose choice and a good starting point.
’RK23’: A lower-order adaptive Runge-Kutta method. Faster but less accurate than RK45.
’DOP853’: A high-order (8th) adaptive Runge-Kutta method for when you need very high precision.
’LSODA’: This is a particularly important one for spiking neurons. It’s a solver that automatically switches between methods for non-stiff and stiff problems. A “stiff” ODE is one where some parts of the solution change very rapidly while others change slowly (like the membrane potential during a spike!). LSODA is often very efficient and stable for these kinds of systems.
’BDF’ and ‘Radau’: Other excellent methods for stiff problems.
ret (list(str) or str or None) –
Specifies what to return. If a list of strings, returns a list of lists, where each inner list corresponds to the requested attribute for all output neurons. If a single string, returns a list corresponding to the requested attribute for all output neurons. If None, returns a list of firing states for all output neurons. Valid strings are:
’fired’ - returns the firing states (1.0 if fired, 0.0 otherwise) ‘voltages’ - returns the membrane potentials (in millivolts) ‘recovery’ - returns the recovery variables ‘all’ - returns a list of lists: [fired states, voltages, recovery variables]
- Returns:
A list or a list of lists as specified by the ‘ret’ parameter, representing the state of the output neurons after the time step.
- Raises:
ValueError – If an invalid integration method is specified.
- advance_simple(dt_msec, method: str | None = 'LSODA', events: bool = False, ret: List[str] | str | None = None) List[float] | List[List[float]][source]¶
Advances the simulation by the given time step in milliseconds.
- Parameters:
dt_msec (float) – The time step in milliseconds.
method (str) –
The integration method to use. If None, uses manually written RK4, otherwise defaults to SciPy’s LSODA. If specified, uses SciPy’s solve_ivp with the given method. Valid methods are listed in the SciPy documentation for solve_ivp (https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html). And here is a summary of available methods:
’RK45’ (Default): An adaptive Runge-Kutta method of order 5(4). It’s a great general-purpose choice and a good starting point.
’RK23’: A lower-order adaptive Runge-Kutta method. Faster but less accurate than RK45.
’DOP853’: A high-order (8th) adaptive Runge-Kutta method for when you need very high precision.
’LSODA’: This is a particularly important one for spiking neurons. It’s a solver that automatically switches between methods for non-stiff and stiff problems. A “stiff” ODE is one where some parts of the solution change very rapidly while others change slowly (like the membrane potential during a spike!). LSODA is often very efficient and stable for these kinds of systems.
’BDF’ and ‘Radau’: Other excellent methods for stiff problems.
events (bool) – Whether to use event detection for spikes. Only applicable if ‘method’ is specified.
ret (list(str) or str or None) –
Specifies what to return. If a list of strings, returns a list of lists, where each inner list corresponds to the requested attribute for all output neurons. If a single string, returns a list corresponding to the requested attribute for all output neurons. If None, returns a list of firing states for all output neurons. Valid strings are:
’fired’ - returns the firing states (1.0 if fired, 0.0 otherwise) ‘voltages’ - returns the membrane potentials (in millivolts) ‘recovery’ - returns the recovery variables ‘all’ - returns a list of lists: [fired states, voltages, recovery variables]
- Returns:
A list or a list of lists as specified by the ‘ret’ parameter.
- Raises:
ValueError – If an invalid integration method is specified.
- static create(genome, config)[source]¶
Receives a genome and returns its phenotype (a neural network).
- get_time_step_msec()[source]¶
Returns a safe time step in milliseconds for the current network configuration. This is a placeholder implementation and should be replaced with a proper calculation.
- set_inputs(inputs: List[float])[source]¶
Assigns input voltages.
- Parameters:
inputs (list) – A list of input voltages. (in millivolts, where each voltage corresponds to an input neuron)
- class ctneat.iznn.IZNeuron(bias: float, a: float, b: float, c: float, d: float, inputs: List[Tuple[int, float]])[source]¶
Sets up and simulates the iznn nodes (neurons).
- __init__(bias: float, a: float, b: float, c: float, d: float, inputs: List[Tuple[int, float]])[source]¶
a, b, c, d are the parameters of the Izhikevich model.
- Parameters:
bias (float) – The bias of the neuron.
a (float) – The time-scale of the recovery variable.
b (float) – The sensitivity of the recovery variable.
c (float) – The after-spike reset value of the membrane potential.
d (float) – The after-spike reset value of the recovery variable.
inputs (list(tuple(int, float))) – A list of (input key, weight) pairs for incoming connections.
- advance(dt_msec: float)[source]¶
This is a default advance method which is simply a wrapper to the advance_scipy method.
- Parameters:
dt_msec (float) – The time step in milliseconds.
- advance_rk4(dt_msec: float)[source]¶
Advances simulation time using 4th-Order Runge-Kutta.
- if v >= 30 then
v <- c, u <- u + d
- else
v’ = 0.04 * v^2 + 5v + 140 - u + I u’ = a * (b * v - u)
- Parameters:
dt_msec (float) – The time step in milliseconds.
- advance_scipy(dt_msec: float, method: str = 'LSODA')[source]¶
Advances simulation time using a solver from SciPy.
- Parameters:
dt_msec (float) – The time step in milliseconds.
method (str) – The integration method to use (e.g., ‘RK45’, ‘LSODA’). Other options are listed in the SciPy documentation for solve_ivp (https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html).
The ctneat.iznn.dynamic_attractors Dynamic Attractors Module¶
This module provides functions to automatically find and analyze dynamic attractors in spiking neural networks.
- ctneat.iznn.dynamic_attractors.characterize_attractor_spikes(fired_history: ndarray, t_start: int, t_end: int, return_vec: bool = False) str | List[float][source]¶
Creates a spike pattern string for a detected attractor period.
- Parameters:
fired_history (np.ndarray) – A 2D array (time steps x neurons) of firing states (1.0 or 0.0).
t_start (int) – The starting time index of the attractor cycle.
t_end (int) – The ending time index of the attractor cycle.
return_vec (bool) – If True, returns a vector representation of the fingerprint instead of a string.
- Returns:
- A string representing the spike pattern. Neurons that fire at each time step are listed,
separated by commas, and time steps are separated by hyphens. Non-firing steps are denoted by ‘_’.
list: If return_vec is True, returns a list containing the vector representation of the fingerprint.
- Return type:
- ctneat.iznn.dynamic_attractors.characterize_attractor_voltage(voltage_history_cycle: ndarray, dt: float, num_peaks: int = 3, min_peak_prominence: float = 0.1, return_vec: bool = False) str | List[float][source]¶
Creates a voltage-based fingerprint for an attractor cycle that is invariant to neuron order.
It works by finding the top frequency components for each neuron’s voltage oscillation, creating a string representation for each, and then sorting these strings before joining them.
- Parameters:
voltage_history_cycle (np.ndarray) – A 2D array (time_steps x neurons) containing the voltage data for one full attractor period.
dt (float) – The time step of the uniformly sampled data in milliseconds.
num_peaks (int) – The maximum number of frequency peaks to include for each neuron.
min_peak_prominence (float) – The minimum prominence for a peak in the frequency spectrum to be considered. This helps filter out noise.
return_vec (bool) – If True, returns a vector representation of the fingerprint instead of a string.
- Returns:
- A canonical fingerprint string of the attractor’s voltage dynamics in the form:
”N1(f:10.5,m:2.3|f:21.0,m:1.1)-N2(f:9.8,m:1.5|f:20.5,m:0.9)” where each neuron’s peaks are sorted by frequency, and neurons are sorted alphabetically by their identifier (N1, N2, …). If the number of time steps is zero, returns “no_data”. If a neuron’s voltage is flat (no significant peaks), it is denoted as N<neuron_id>(flat, v:<last_voltage>).
- list: If return_vec is True, returns a list containing the vector representations of the fingerprints.
The length of the list will be num_neurons * (2 * num_peaks + 1), where each neuron contributes num_peaks frequency-magnitude pairs and one last voltage value (only set in the flat case). For the previous example, the vector would be: [10.5, 2.3, 21.0, 1.1, 0.0,
9.8, 1.5, 20.5, 0.9, 0.0]
In case of a flat signal with voltages of v1 and v2, the vector would be: [0.0, 0.0, 0.0, 0.0, v1,
0.0, 0.0, 0.0, 0.0, v2]
- Return type:
- ctneat.iznn.dynamic_attractors.dynamic_attractors_pipeline(voltage_history: ndarray, fired_history: ndarray, times_np: ndarray, dt_uniform_ms: float | str | None = None, using_simulation: bool = True, net: IZNN | None = None, burn_in: int | float | None = 0.25, variable_burn_in: bool = False, burn_in_rate: float = 0.5, min_repetitions: int = 3, min_points: int = 100, time_delay: int = 1, radius: float | None = None, theiler_corrector: int = 2, det_threshold: float = 0.2, metric: str = 'euclidean', fingerprint_using: str = 'voltage', fingerprint_vec: bool = False, superimpose: bool = False, use_lcm: bool = True, flat_signal_threshold: float = 0.001, num_peaks: int = 3, min_peak_prominence: float = 0.1, printouts: bool = True, verbose: bool = False) str | List[float] | None[source]¶
Full pipeline to analyze dynamic attractors in IZNN data. This includes resampling to uniform time steps, performing RQA, and characterizing attractors.
- Parameters:
voltage_history (np.ndarray) – A 2D numpy array where each row corresponds to a time step, and each column corresponds to a specific neuron’s voltage.
fired_history (np.ndarray) – A 2D numpy array where each row corresponds to a time step, and each column corresponds to a specific neuron’s firing state.
times_np (np.ndarray) – A 1D numpy array of time stamps corresponding to the data points.
dt_uniform_ms (Optional[Union[float, str]]) – The desired uniform time step in milliseconds. Valid options are a positive float or ‘min’, ‘max’, ‘avg’ and ‘median’. If not set, will be set to the smallest interval in times_np.
using_simulation (bool) – If true, uses the network provided in the net argument to recalculate the data. If false, uses linear interpolation to resample the data.
net (IZNN) – The IZNN network used to run the simulation.
burn_in (Optional[Union[int, float]]) – Number of initial time steps to discard from the analysis. If float, treated as percentage. If int, treated as absolute number of steps. If None, defaults to 0.
variable_burn_in (bool) – If True, adds an option to variably increase the burn-in period in case the one provided in burn_in is not sufficient to find the attractor.
burn_in_rate (float) – The rate at which to increase the burn-in period if variable_burn_in is True. For example, a rate of 0.5 means increasing that the new burn-in will include 50% of the non-burned-in data. Burn-in will continuously increase until an attractor is found or until not enough data is left.
min_repetitions (int) – Minimum number of repetitions of the attractor cycle to confirm its presence.
min_points (int) – Minimum number of data points required after burn-in to perform the analysis.
time_delay (int) – Time delay for embedding the time series. The time delay defines the number of time steps to skip when creating the embedded vectors.
radius (float) – The radius for the recurrence plot. If None, a default value is 0.2 * std(data). The radius defines the threshold distance in state space for considering two states as recurrent.
theiler_corrector (int) – Theiler window to exclude temporally close points. This prevents finding “fake” recurrences from points that are close in distance simply because they are also close in time. It excludes points within w time steps of each other from being considered recurrent pairs. A small value (e.g., a few steps more than your time_delay) is usually sufficient to remove these trivial correlations. Setting it to 0 disables it.
det_threshold (float) – The threshold of determinism (DET) above which to attempt attractor characterization. If the DET from RQA is above this threshold, the attractor characterization is performed.
metric (str) – The distance metric to use (‘euclidean’, ‘taxicab’, ‘maximum’) or alternatively (‘l2’, ‘l1’ and ‘linf’). Case insensitive. Default is ‘euclidean’.
fingerprint_using (str) – The method to use for generating the fingerprint of the attractor. Options are ‘voltage’ (using the voltage trace) or ‘firing’ (using the firing rate). Default is ‘voltage’.
fingerprint_vec (bool) – If True, returns a vector representation of the fingerprint instead of a string.
superimpose (bool) – Instead of doing a PCA reduction, simply superimpose all neuron voltages into one signal using max. (Default is False)
use_lcm (bool) – Whether to use the least common multiple of individual neuron periods to determine the overall period. If False, uses the dominant frequency from the combined signal. (Default is True)
flat_signal_threshold (float) – Threshold for standard deviation to consider a signal as “flat” (in mV).
num_peaks (int) – The maximum number of frequency peaks to include for each neuron when using voltage fingerprinting.
min_peak_prominence (float) – The minimum prominence for a peak in the frequency spectrum to be considered when using voltage fingerprinting. This helps filter out noise.
printouts (bool) – If True, prints summary information about the analysis.
verbose (bool) – If True, prints detailed information during the analysis. (If set to true, also enables printouts.)
- Returns:
- A string representing the spike pattern of the attractor, or None if no attractor can be found.
Neurons that fire at each time step are listed, separated by commas, and time steps are separated by hyphens. Non-firing steps are denoted by ‘_’. In case of voltage fingerprinting, the string represents the frequency components of each neuron. If fingerprint_vec is True and voltage fingerprinting is used, returns a list containing the vector representation of the fingerprint. If no attractor is found, returns None.
- Return type:
- Raises:
ValueError – If dt_uniform_ms is invalid or if fingerprint_using is not recognized.
- ctneat.iznn.dynamic_attractors.fingerprint_attractors(voltage_history: ndarray, fired_history: ndarray, times: ndarray, superimpose: bool = False, use_lcm: bool = False, fingerprint_using: str = 'voltage', fingerprint_vec: bool = False, burn_in: int | float | None = None, min_repetitions: int = 3, flat_signal_threshold: float = 0.001, num_peaks: int = 3, min_peak_prominence: float = 0.1, printouts: bool = False) str | List[float] | None[source]¶
Analyzes the voltage and firing history to identify and characterize attractor periods. It estimates the dominant period using FFT (Fast Fourier Transform) and then characterizes the spike pattern during the last full period.
- Parameters:
fired_history (np.ndarray) – A 2D array (time steps x neurons) of firing states (1.0 or 0.0).
voltage_history (np.ndarray) – A 2D array (time steps x neurons) of voltage values.
times (np.ndarray) – A 1D array of time stamps corresponding to the data points.
superimpose (bool) – Instead of doing a PCA reduction, simply superimpose all neuron voltages into one signal using max. (Default is False)
use_lcm (bool) – Whether to use the least common multiple of individual neuron periods to determine the overall period. If False, uses the dominant frequency from the combined signal. (Default is False)
fingerprint_using (str) – The method to use for generating the fingerprint of the attractor. Options are ‘voltage’ (using the voltage trace) or ‘firing’ (using the firing rate). Default is ‘voltage’.
fingerprint_vec (bool) – If True, returns a vector representation of the fingerprint instead of a string.
burn_in (Optional[Union[int, float]]) – Number of initial time steps to discard from the analysis. If float, treated as percentage. If int, treated as absolute number of steps. If None, defaults to 0.
min_repetitions (int) – Minimum number of repetitions of the attractor cycle to confirm its presence.
flat_signal_threshold (float) – Threshold for standard deviation to consider a signal as “flat” (in mV).
num_peaks (int) – The maximum number of frequency peaks to include for each neuron when using voltage fingerprinting.
min_peak_prominence (float) – The minimum prominence for a peak in the frequency spectrum to be considered when using voltage fingerprinting. This helps filter out noise.
printouts (bool) – Whether to print summarized analysis information.
- Returns:
- A string representing the spike pattern of the attractor, or None if no attractor is found.
In case of voltage fingerprinting, the string represents the frequency components of each neuron. In case of firing fingerprinting, the string represents the firing pattern of the attractor.
- Return type:
Optional[str]
- Raises:
ValueError – If the input arrays have incompatible shapes or if the time data is not uniformly sampled.
ValueError – If fingerprint_using is not recognized.
- ctneat.iznn.dynamic_attractors.perform_rqa_analysis(data_points: ndarray, burn_in: int | float | None = 0.25, time_delay: int = 1, radius: float | None = None, theiler_corrector: int = 2, metric: str = 'euclidean', printouts: bool = False, verbose: bool = False) RQAResult[source]¶
Perform Recurrence Quantification Analysis (RQA) on the given data points.
- Parameters:
data_points (np.ndarray) – A 2D numpy array where each row corresponds to a time step, and each column corresponds to a specific variable’s state.
burn_in (Optional[Union[int, float]]) – Number of initial time steps to discard from the analysis. If float, treated as percentage. If int, treated as absolute number of steps. If None, no burn-in is applied (same as if 0).
time_delay (int) – Time delay for embedding the time series. The time delay defines the number of time steps to skip when creating the embedded vectors.
radius (float) – The radius for the recurrence plot. If None, a default value is 0.2 * std(data). The radius defines the threshold distance in state space for considering two states as recurrent.
theiler_corrector (int) – Theiler window to exclude temporally close points. This prevents finding “fake” recurrences from points that are close in distance simply because they are also close in time. It excludes points within w time steps of each other from being considered recurrent pairs. A small value (e.g., a few steps more than your time_delay) is usually sufficient to remove these trivial correlations. Setting it to 0 disables it.
metric (str) – The distance metric to use (‘euclidean’, ‘taxicab’, ‘maximum’) or alternatively (‘l2’, ‘l1’ and ‘linf’). Case insensitive. Default is ‘euclidean’.
printouts (bool) – If True, prints summary information about the analysis.
verbose (bool) – If True, prints detailed information during the analysis. (If set to true, also enables printouts.)
- Returns:
None
- Raises:
ValueError – If an unsupported metric is provided.
- ctneat.iznn.dynamic_attractors.resample_data(times_np: ndarray, data_np: ndarray, dt_uniform_ms: float | str | None = None, using_simulation: bool = False, net: IZNN | None = None, events: bool = False, ret: str = 'voltages') Tuple[ndarray, ndarray][source]¶
Resamples non-uniformly sampled data to a uniform time grid using linear interpolation.
- Parameters:
times_np (np.ndarray) – The 1D array of non-uniform time stamps.
data_np (np.ndarray) – The 2D array of data (time steps x neurons).
dt_uniform_ms (float) – The desired uniform time step in milliseconds. Valid options are a positive float or ‘min’, ‘max’, ‘avg’ and ‘median’. If not set, will be set to the smallest interval in times_np.
using_simulation (bool) – If true, uses the network provided in the net argument to recalculate the data. If false, uses linear interpolation to resample the data.
net (IZNN) – The IZNN network used to run the simulation.
events (bool) – If using_simulation is True, specifies whether to do event-driven simulation.
ret (str) –
If using_simulation is True, specifies what to return from the simulation. Valid strings are:
’fired’ - returns the firing states (1.0 if fired, 0.0 otherwise) ‘voltages’ - returns the membrane potentials (in millivolts) ‘recovery’ - returns the recovery variables (in millivolts)
Default is ‘voltages’.
- Returns:
A tuple (uniform_times, uniform_data)
- Raises:
ValueError – If dt_uniform_ms is invalid or if using_simulation is True but no network is provided.