OCD_modeling.analysis

class OCD_modeling.analysis.SymbolicModel[source]

Bases: ABC

Abstract class that implement common functions to all symbolic Reduced Wong Wang models

OCD_modeling.analysis.compute_equilibrium_point_curve(model, fps, pdomain)[source]

Find equilibrium point curve(s) of the system, starting from each fixed point (if exist).

Parameters:
  • model (PyDSTool.Vode_ODEsystem) – Model object in PyDSTool.

  • fps (PyDSTool.Toolbox.phaseplane.fixedpoint_2D) – Fixed points of the system.

  • pdomain (dict) – Free variable (or order parameter) to perform the bifurcation analyis from.

Returns:

cont – PyDSTool Continuation Class object populated with equilibrium point curves.

Return type:

PyDSTool.ContClass

OCD_modeling.analysis.compute_trajectories(model, n, tdata=[0, 1000])[source]

Compute n trajectories from model, each with different initial conditions.

Parameters:
  • model (PyDSTool.Vode_ODEsystem) – PyDSTool model object.

  • n (int) – Number of trajectories to compute.

  • tdata (list) – Time interval of the saved trajectories.

OCD_modeling.analysis.create_model(params, args=None)[source]

Create the Dynamical System in PyDSTool

\[\dot{S_i} = - \cfrac{S_i}{\tau_S} + (1 - S_i) \gamma H(x_i) + \sigma v_i\]

with

\[H(x) = \cfrac{ax-b}{1-\exp{(-d(ax-b))}}\]

and

\[x_i = w J_N S_i + G J_N \sum_j{C_{ij} S_j} + I_0\]
Parameters:
  • params (dict) – Parameters of the model

  • args (Argparse.Namespace) – Optional arguments

Returns:

rww – PyDSTool object containing the dynamical system

Return type:

PyDSTool.Vode_ODEsystem

OCD_modeling.analysis.find_roots(f, x, itv=None, slope_thr=0.05)[source]

Find zero crossings of function f (numerical roots).

:param slope_thr” defines the slopes above which the zero crossing is an artifact e.g. in case of hyperbolic function

OCD_modeling.analysis.get_fixed_point_stability(model, fp, params)[source]

Derive stability based on eigenvalues of the jacobian around the fixed point

OCD_modeling.analysis.get_fixed_points(model, params, xdomain={'S1': [0, 1], 'S2': [0, 1]}, args=None)[source]

Get model’s nullclines \(\frac{dS_1}{dt}=0\) and \(\frac{dS_2}{dt}=0\) and fixed points \(\frac{dS_1}{dt}=\frac{dS_2}{dt}=0\) for a given set of parameters.

Parameters:
  • model (PyDSTool.Vode_ODEsystem) – Model object in PyDSTool.

  • params (dict) – Model parameters.

  • xdomain (dict) – Variable and lower/upper bounds.

  • args (Argparse.Namespace) – Optional extra arguments.

Returns:

  • model (PyDSTool.Vode_ODEsystem) – Updated model object with given parameters.

  • fps (PyDSTool.Toolbox.phaseplane.fixedpoint_2D) – Fixed points of the system.

  • (nulls_x, nulls_y) (tuple) – Tuple containing nullclines (arrays of paired xs and ys).

OCD_modeling.analysis.get_parser()[source]

parsing global script argument

OCD_modeling.analysis.lambdify_model(model, default_params, order_params)[source]

evaluate model for parameters using sympa lambdify.

Parameters:
  • model – symbolic model (object)

  • params – dictionnary of parameters

OCD_modeling.analysis.launch_stability_analysis(order_params, default_params, out_queue, args)[source]

Ghost process that launches the stability analysis for a set of defined order parameter, creating a child process with a set timeout per child process, such that the stbaility analysis does not hang waiting for the continuation to terminate if it does not converge.

Parameters:
  • order_params (dict) – Fixed parameters, for which to analyse the system using discretized values, for example {'C_21': np.linspace(0.2,0.8,4)}.

  • default_params (dict) – Default model’s parameters.

  • out_queue (Queue) – Output queue on which to append the results.

  • args (Argparse.Namespace) – Structure of necessary options. For example, must include args.compute_epc = True to compute equilibrium point curves.

OCD_modeling.analysis.perform_stability_analysis(model, order_params, default_params, out_queue, x=array([-3., -2.98996656, -2.97993311, -2.96989967, -2.95986622, -2.94983278, -2.93979933, -2.92976589, -2.91973244, -2.909699, -2.89966555, -2.88963211, -2.87959866, -2.86956522, -2.85953177, -2.84949833, -2.83946488, -2.82943144, -2.81939799, -2.80936455, -2.7993311, -2.78929766, -2.77926421, -2.76923077, -2.75919732, -2.74916388, -2.73913043, -2.72909699, -2.71906355, -2.7090301, -2.69899666, -2.68896321, -2.67892977, -2.66889632, -2.65886288, -2.64882943, -2.63879599, -2.62876254, -2.6187291, -2.60869565, -2.59866221, -2.58862876, -2.57859532, -2.56856187, -2.55852843, -2.54849498, -2.53846154, -2.52842809, -2.51839465, -2.5083612, -2.49832776, -2.48829431, -2.47826087, -2.46822742, -2.45819398, -2.44816054, -2.43812709, -2.42809365, -2.4180602, -2.40802676, -2.39799331, -2.38795987, -2.37792642, -2.36789298, -2.35785953, -2.34782609, -2.33779264, -2.3277592, -2.31772575, -2.30769231, -2.29765886, -2.28762542, -2.27759197, -2.26755853, -2.25752508, -2.24749164, -2.23745819, -2.22742475, -2.2173913, -2.20735786, -2.19732441, -2.18729097, -2.17725753, -2.16722408, -2.15719064, -2.14715719, -2.13712375, -2.1270903, -2.11705686, -2.10702341, -2.09698997, -2.08695652, -2.07692308, -2.06688963, -2.05685619, -2.04682274, -2.0367893, -2.02675585, -2.01672241, -2.00668896, -1.99665552, -1.98662207, -1.97658863, -1.96655518, -1.95652174, -1.94648829, -1.93645485, -1.9264214, -1.91638796, -1.90635452, -1.89632107, -1.88628763, -1.87625418, -1.86622074, -1.85618729, -1.84615385, -1.8361204, -1.82608696, -1.81605351, -1.80602007, -1.79598662, -1.78595318, -1.77591973, -1.76588629, -1.75585284, -1.7458194, -1.73578595, -1.72575251, -1.71571906, -1.70568562, -1.69565217, -1.68561873, -1.67558528, -1.66555184, -1.65551839, -1.64548495, -1.63545151, -1.62541806, -1.61538462, -1.60535117, -1.59531773, -1.58528428, -1.57525084, -1.56521739, -1.55518395, -1.5451505, -1.53511706, -1.52508361, -1.51505017, -1.50501672, -1.49498328, -1.48494983, -1.47491639, -1.46488294, -1.4548495, -1.44481605, -1.43478261, -1.42474916, -1.41471572, -1.40468227, -1.39464883, -1.38461538, -1.37458194, -1.36454849, -1.35451505, -1.34448161, -1.33444816, -1.32441472, -1.31438127, -1.30434783, -1.29431438, -1.28428094, -1.27424749, -1.26421405, -1.2541806, -1.24414716, -1.23411371, -1.22408027, -1.21404682, -1.20401338, -1.19397993, -1.18394649, -1.17391304, -1.1638796, -1.15384615, -1.14381271, -1.13377926, -1.12374582, -1.11371237, -1.10367893, -1.09364548, -1.08361204, -1.0735786, -1.06354515, -1.05351171, -1.04347826, -1.03344482, -1.02341137, -1.01337793, -1.00334448, -0.99331104, -0.98327759, -0.97324415, -0.9632107, -0.95317726, -0.94314381, -0.93311037, -0.92307692, -0.91304348, -0.90301003, -0.89297659, -0.88294314, -0.8729097, -0.86287625, -0.85284281, -0.84280936, -0.83277592, -0.82274247, -0.81270903, -0.80267559, -0.79264214, -0.7826087, -0.77257525, -0.76254181, -0.75250836, -0.74247492, -0.73244147, -0.72240803, -0.71237458, -0.70234114, -0.69230769, -0.68227425, -0.6722408, -0.66220736, -0.65217391, -0.64214047, -0.63210702, -0.62207358, -0.61204013, -0.60200669, -0.59197324, -0.5819398, -0.57190635, -0.56187291, -0.55183946, -0.54180602, -0.53177258, -0.52173913, -0.51170569, -0.50167224, -0.4916388, -0.48160535, -0.47157191, -0.46153846, -0.45150502, -0.44147157, -0.43143813, -0.42140468, -0.41137124, -0.40133779, -0.39130435, -0.3812709, -0.37123746, -0.36120401, -0.35117057, -0.34113712, -0.33110368, -0.32107023, -0.31103679, -0.30100334, -0.2909699, -0.28093645, -0.27090301, -0.26086957, -0.25083612, -0.24080268, -0.23076923, -0.22073579, -0.21070234, -0.2006689, -0.19063545, -0.18060201, -0.17056856, -0.16053512, -0.15050167, -0.14046823, -0.13043478, -0.12040134, -0.11036789, -0.10033445, -0.090301, -0.08026756, -0.07023411, -0.06020067, -0.05016722, -0.04013378, -0.03010033, -0.02006689, -0.01003344, 0., 0.01003344, 0.02006689, 0.03010033, 0.04013378, 0.05016722, 0.06020067, 0.07023411, 0.08026756, 0.090301, 0.10033445, 0.11036789, 0.12040134, 0.13043478, 0.14046823, 0.15050167, 0.16053512, 0.17056856, 0.18060201, 0.19063545, 0.2006689, 0.21070234, 0.22073579, 0.23076923, 0.24080268, 0.25083612, 0.26086957, 0.27090301, 0.28093645, 0.2909699, 0.30100334, 0.31103679, 0.32107023, 0.33110368, 0.34113712, 0.35117057, 0.36120401, 0.37123746, 0.3812709, 0.39130435, 0.40133779, 0.41137124, 0.42140468, 0.43143813, 0.44147157, 0.45150502, 0.46153846, 0.47157191, 0.48160535, 0.4916388, 0.50167224, 0.51170569, 0.52173913, 0.53177258, 0.54180602, 0.55183946, 0.56187291, 0.57190635, 0.5819398, 0.59197324, 0.60200669, 0.61204013, 0.62207358, 0.63210702, 0.64214047, 0.65217391, 0.66220736, 0.6722408, 0.68227425, 0.69230769, 0.70234114, 0.71237458, 0.72240803, 0.73244147, 0.74247492, 0.75250836, 0.76254181, 0.77257525, 0.7826087, 0.79264214, 0.80267559, 0.81270903, 0.82274247, 0.83277592, 0.84280936, 0.85284281, 0.86287625, 0.8729097, 0.88294314, 0.89297659, 0.90301003, 0.91304348, 0.92307692, 0.93311037, 0.94314381, 0.95317726, 0.9632107, 0.97324415, 0.98327759, 0.99331104, 1.00334448, 1.01337793, 1.02341137, 1.03344482, 1.04347826, 1.05351171, 1.06354515, 1.0735786, 1.08361204, 1.09364548, 1.10367893, 1.11371237, 1.12374582, 1.13377926, 1.14381271, 1.15384615, 1.1638796, 1.17391304, 1.18394649, 1.19397993, 1.20401338, 1.21404682, 1.22408027, 1.23411371, 1.24414716, 1.2541806, 1.26421405, 1.27424749, 1.28428094, 1.29431438, 1.30434783, 1.31438127, 1.32441472, 1.33444816, 1.34448161, 1.35451505, 1.36454849, 1.37458194, 1.38461538, 1.39464883, 1.40468227, 1.41471572, 1.42474916, 1.43478261, 1.44481605, 1.4548495, 1.46488294, 1.47491639, 1.48494983, 1.49498328, 1.50501672, 1.51505017, 1.52508361, 1.53511706, 1.5451505, 1.55518395, 1.56521739, 1.57525084, 1.58528428, 1.59531773, 1.60535117, 1.61538462, 1.62541806, 1.63545151, 1.64548495, 1.65551839, 1.66555184, 1.67558528, 1.68561873, 1.69565217, 1.70568562, 1.71571906, 1.72575251, 1.73578595, 1.7458194, 1.75585284, 1.76588629, 1.77591973, 1.78595318, 1.79598662, 1.80602007, 1.81605351, 1.82608696, 1.8361204, 1.84615385, 1.85618729, 1.86622074, 1.87625418, 1.88628763, 1.89632107, 1.90635452, 1.91638796, 1.9264214, 1.93645485, 1.94648829, 1.95652174, 1.96655518, 1.97658863, 1.98662207, 1.99665552, 2.00668896, 2.01672241, 2.02675585, 2.0367893, 2.04682274, 2.05685619, 2.06688963, 2.07692308, 2.08695652, 2.09698997, 2.10702341, 2.11705686, 2.1270903, 2.13712375, 2.14715719, 2.15719064, 2.16722408, 2.17725753, 2.18729097, 2.19732441, 2.20735786, 2.2173913, 2.22742475, 2.23745819, 2.24749164, 2.25752508, 2.26755853, 2.27759197, 2.28762542, 2.29765886, 2.30769231, 2.31772575, 2.3277592, 2.33779264, 2.34782609, 2.35785953, 2.36789298, 2.37792642, 2.38795987, 2.39799331, 2.40802676, 2.4180602, 2.42809365, 2.43812709, 2.44816054, 2.45819398, 2.46822742, 2.47826087, 2.48829431, 2.49832776, 2.5083612, 2.51839465, 2.52842809, 2.53846154, 2.54849498, 2.55852843, 2.56856187, 2.57859532, 2.58862876, 2.59866221, 2.60869565, 2.6187291, 2.62876254, 2.63879599, 2.64882943, 2.65886288, 2.66889632, 2.67892977, 2.68896321, 2.69899666, 2.7090301, 2.71906355, 2.72909699, 2.73913043, 2.74916388, 2.75919732, 2.76923077, 2.77926421, 2.78929766, 2.7993311, 2.80936455, 2.81939799, 2.82943144, 2.83946488, 2.84949833, 2.85953177, 2.86956522, 2.87959866, 2.88963211, 2.89966555, 2.909699, 2.91973244, 2.92976589, 2.93979933, 2.94983278, 2.95986622, 2.96989967, 2.97993311, 2.98996656, 3.]))[source]

Analyses the stability of the system of ODEs.

Parameters:
  • model – sympy model

  • order_params – dictionary of order parameters

  • default_params – dictionary of other default parameters

  • x – substitution variable values

OCD_modeling.analysis.plot_3d_bifurcations(outputs, azim=0, elev=0)[source]

plot bifurcation diagram in 3D

OCD_modeling.analysis.plot_bifurcation_grid(outputs, order_params, args=None)[source]

Plot a grid of bifurcation diagrams

OCD_modeling.analysis.plot_bifurcation_row(outputs, order_params, rww=None, t_range=None, args=None)[source]

Plot a row of bifurcation diagrams (ie. a 1 by n grid).

Parameters:
  • outputs (list) – Outputs from stability analysis.

  • order_params (dict) – Order parameters of the analysis in {‘param_name’: np.array} format where np.array is the list of order parameters param_name.

  • rww (OCD_modeling.models.ReducedWongWangOU) – Model instance that ran.

  • t_range (list) – [start, stop] timestamp values of the RWW model traces to plot in the diagrams.

  • args (Argparse.Namespace) – Extra options.

OCD_modeling.analysis.plot_phasespace(model, fps, nullclines, trajs, ax=None, args=None)[source]

Plot vector field, nullclines and fixed points of a model previously set with parameters.

Parameters:
  • model (PyDSTool.Vode_ODEsystem) – PyDSTool model object.

  • fps (PyDSTool.Toolbox.phaseplane.fixedpoint_2D) – Fixed points of he system

  • nullclines (list) – list of PyDSTool nullcline objects, containing arrays of xs and ys of nullclines.

  • trajs (list of dict) – Simulated trajectories.

  • ax (matplotlib.Axis) – Axis in which to plot the phasespace.

OCD_modeling.analysis.plot_phasespace_grid(outputs, order_params, args=None)[source]

Plot a grid of phasespaces from stability analysis outputs.

Parameters:
  • outputs (list) – Outputs from stability analysis.

  • order_params (dict) – Fixed parameters, for which to analyse the system using discretized values, for example {'C_21': np.linspace(0.2,0.8,4)}.

  • args (Argparse.Namespace) – Optional extra arguments in argprase Namespace, such as args.save_figs=True to save figure and args.plot_figs=True to plot figures.

OCD_modeling.analysis.plot_timeseries_phasespace_bif(outputs, rww, df_eta_sigma, args)[source]

Show \(S1\), \(S2\), \(C_{12}\) timeseries, \(S1-S2\) phase space with trajectories and \(C_{12} - S1|S2\) phase space. with bifurcation diagram.

Parameters:
  • outputs (list) – Outputs from stability analysis.

  • rww (OCD_modeling.models.ReducedWongWangOU) – Model instance that ran.

  • df_eta_sigma (pandas.DataFrame) – Data from the simulations varying eta and sigma parameters.

  • args (Argparse.Namespace) – Extra options.

class OCD_modeling.analysis.pw_RWW_2D[source]

Bases: SymbolicModel

Piecewise linear Reduced Wong Wang symbolic model

__init__()[source]
OCD_modeling.analysis.run_stability_analysis(order_params, default_params, args)[source]

Starts a pool of parallel processes to run the stability analysis.

Parameters:
  • order_params (dict) – Fixed parameters, for which to analyse the system using discretized values, for example {'C_21': np.linspace(0.2,0.8,4)}.

  • default_params (dict) – Default model’s parameters.

  • args (Argparse.Namespace) – Structure of necessary options. For example, must include args.compute_epc = True to compute equilibrium point curves.

Returns:

OCD_modeling.analysis.stability_analysis(order_params, default_params, out_queue, args, pdomain={'C_12': [-0.5, 1.5]})[source]

Create model and analyse dynamics using PyDSTool.

Parameters:
  • order_params (dict) – Fixed parameters, for which to analyse the system using discretized values, for example {'C_21': np.linspace(0.2,0.8,4)}.

  • default_params (dict) – Default model’s parameters.

  • out_queue (Queue) – Queue to put results in (used for parallel computation) for each values of order parameter.

  • args (Argparse.Namespace) – Structure of necessary options. For example, must include args.compute_epc = True to compute equilibrium point curves.

  • pdomain (dict) – Free variable (or order parameter) to perform the bifurcation analyis from.

Returns:

A dict with model, nullclines (ncs), fixed points (fps), trajectories (trajs), and a pickled (dilled) continuation object (if equilibrium curves are asked in args), is appended to the queue.

Return type:

None

class OCD_modeling.analysis.symRWW_2D[source]

Bases: SymbolicModel

Original Reduced Wong Wang model

__init__()[source]