Movements Documentation#

movements.py is a module that contains classes and functions to generate different types of simulated movements.


monalysa.movements.data_span(data: array) float#

Returns the ampltide span of the given list or array.

Parameters:

data (np.array, list, tuple) – The data whose amplitude span is to be calcuated.

Returns:

span – The span, defined as the different between the max. and min. values of the given data.

Return type:

float

Notes

Examples

>>> data_span([-1,4,0,-23,27,0.573])
50
>>> data_span([])
Empty list or array provided! Span cannot be calculated.
monalysa.movements.gaussian_discrete_movement(amp: float = 1.0, dur: float = 1.0, loc: float = 0.0, time: array = array([- 5.0000000e-01, - 4.9000000e-01, - 4.8000000e-01, - 4.7000000e-01, - 4.6000000e-01, - 4.5000000e-01, - 4.4000000e-01, - 4.3000000e-01, - 4.2000000e-01, - 4.1000000e-01, - 4.0000000e-01, - 3.9000000e-01, - 3.8000000e-01, - 3.7000000e-01, - 3.6000000e-01, - 3.5000000e-01, - 3.4000000e-01, - 3.3000000e-01, - 3.2000000e-01, - 3.1000000e-01, - 3.0000000e-01, - 2.9000000e-01, - 2.8000000e-01, - 2.7000000e-01, - 2.6000000e-01, - 2.5000000e-01, - 2.4000000e-01, - 2.3000000e-01, - 2.2000000e-01, - 2.1000000e-01, - 2.0000000e-01, - 1.9000000e-01, - 1.8000000e-01, - 1.7000000e-01, - 1.6000000e-01, - 1.5000000e-01, - 1.4000000e-01, - 1.3000000e-01, - 1.2000000e-01, - 1.1000000e-01, - 1.0000000e-01, - 9.0000000e-02, - 8.0000000e-02, - 7.0000000e-02, - 6.0000000e-02, - 5.0000000e-02, - 4.0000000e-02, - 3.0000000e-02, - 2.0000000e-02, - 1.0000000e-02, 4.4408921e-16, 1.0000000e-02, 2.0000000e-02, 3.0000000e-02, 4.0000000e-02, 5.0000000e-02, 6.0000000e-02, 7.0000000e-02, 8.0000000e-02, 9.0000000e-02, 1.0000000e-01, 1.1000000e-01, 1.2000000e-01, 1.3000000e-01, 1.4000000e-01, 1.5000000e-01, 1.6000000e-01, 1.7000000e-01, 1.8000000e-01, 1.9000000e-01, 2.0000000e-01, 2.1000000e-01, 2.2000000e-01, 2.3000000e-01, 2.4000000e-01, 2.5000000e-01, 2.6000000e-01, 2.7000000e-01, 2.8000000e-01, 2.9000000e-01, 3.0000000e-01, 3.1000000e-01, 3.2000000e-01, 3.3000000e-01, 3.4000000e-01, 3.5000000e-01, 3.6000000e-01, 3.7000000e-01, 3.8000000e-01, 3.9000000e-01, 4.0000000e-01, 4.1000000e-01, 4.2000000e-01, 4.3000000e-01, 4.4000000e-01, 4.5000000e-01, 4.6000000e-01, 4.7000000e-01, 4.8000000e-01, 4.9000000e-01]), data_type: str = 'vel') array#

Generate a discrete Gaussian movement speed profile of the given amplitude, duration and time location for the given time span.

Parameters:
  • amp (float) – Amplitude of the Gaussian discrete movement.

  • dur (float) – Duration of the Gaussian discrete movement.

  • loc (float) – The temporal location of the center of the Gaussian speed profile.

  • time (np.array) – The time values for which the speed profile values are to be returned.

  • data_type (string) – The type data returned by the function. The function can return velocity, acceleration or jerk. There are only three possibilities, {‘vel’, ‘accl’, ‘jerk’}, corresponding to velocity, acceleration and jerk.

Returns:

movement – The movement speed profile of the Gaussian discrete movement.

Return type:

np.array

Notes

Examples

monalysa.movements.gaussian_rhytmic_movement(amp: float, dur: float, interval: float, ts: float, n_movements: int) tuple[numpy.array, numpy.array]#

Generates a rhythmic (repetitive) Gaussian movement speed profiles that is the sum of individual Gaussian speed profiles.

Parameters:
  • amp (float) – Amplitude of each submovement.

  • dur (float) – Duration of each submovement.

  • interval (float) – Time interval between the peaks two successive Gaussian movements.

  • ts (float) –

  • n_movements (int) – The number of Gaussian movements in the overall movementsnt.

Returns:

  • time (np.array) – The time of the movement starting from 0.

  • movement (np.array) – The movement speed profile of the Gaussian rhythmic movement.

Notes

monalysa.movements.generate_movement(Ns: int, amp: array, dT: array, T: array, ts: float = 0.001, move_type: str = 'gaussian', data_type: str = 'vel') tuple[numpy.array, numpy.array, numpy.array]#

Generates a movement as sum of submovements with the given parameters.

Parameters:
  • Ns (int) – This indicates the number of submovements

  • amp (np.array) – The amplitude of the Ns submovements.

  • dT (np.array) – This is the inter-submovement interval. This is of length Ns-1, as it only contains the intervals with respect to the previous submovement. The first submovement is assumed to start from zero, i.e. the its center is located at half its duration.

  • T (np.array) – The durations of the Ns submovements.

  • ts (float) – This is the sampling duration.

  • move_type (string) – This must be a string indicating the type of submovement to use - ‘gaussian’ or ‘mjt’.

  • data_type (string) – The type data returned by the function. The function can return velocity, acceleration or jerk. There are only three possibilities, {‘vel’, ‘accl’, ‘jerk’}, corresponding to velocity, acceleration and jerk.

Returns:

  • t (np.array) – The time of the movement starting from 0.

  • movement (np.array) – The speed profile of the generated random movement.

  • submovements (np.array) – A two dimensional array containing the individual submovements in the generated random movement. The number of row is equal to the number of submovements, and the number of columns corresponds to the number of data points for the duration of the generated movement.

Notes

monalysa.movements.generate_random_movement(move_type: str = 'gaussian') tuple[numpy.array, numpy.array, numpy.array]#

Generates a random movement as a sum of Gaussian submovements. The number of submovements, their duration, time location and amplitude are chosen randomly.

Parameters:

move_type (string) – This must be a string indicating the type of discrete movement to use for generating the random movement.

Returns:

  • t (np.array) – The time of the movement starting from 0.

  • movement (np.array) – The speed profile of the generated random movement.

  • submovements (np.array) – A two dimensional array containing the individual submovements in the generated random movement. The number of row is equal to the number of submovements, and the number of columns corresponds to the number of data points for the duration of the generated movement.

Notes

monalysa.movements.get_movement_endtime(dT: float, T: array)#

Returns the end time of the movement assuming that the start time is zero.

monalysa.movements.mjt_discrete_movement(amp=1.0, dur=1.0, loc=0.0, time=array([- 5.0000000e-01, - 4.9000000e-01, - 4.8000000e-01, - 4.7000000e-01, - 4.6000000e-01, - 4.5000000e-01, - 4.4000000e-01, - 4.3000000e-01, - 4.2000000e-01, - 4.1000000e-01, - 4.0000000e-01, - 3.9000000e-01, - 3.8000000e-01, - 3.7000000e-01, - 3.6000000e-01, - 3.5000000e-01, - 3.4000000e-01, - 3.3000000e-01, - 3.2000000e-01, - 3.1000000e-01, - 3.0000000e-01, - 2.9000000e-01, - 2.8000000e-01, - 2.7000000e-01, - 2.6000000e-01, - 2.5000000e-01, - 2.4000000e-01, - 2.3000000e-01, - 2.2000000e-01, - 2.1000000e-01, - 2.0000000e-01, - 1.9000000e-01, - 1.8000000e-01, - 1.7000000e-01, - 1.6000000e-01, - 1.5000000e-01, - 1.4000000e-01, - 1.3000000e-01, - 1.2000000e-01, - 1.1000000e-01, - 1.0000000e-01, - 9.0000000e-02, - 8.0000000e-02, - 7.0000000e-02, - 6.0000000e-02, - 5.0000000e-02, - 4.0000000e-02, - 3.0000000e-02, - 2.0000000e-02, - 1.0000000e-02, 4.4408921e-16, 1.0000000e-02, 2.0000000e-02, 3.0000000e-02, 4.0000000e-02, 5.0000000e-02, 6.0000000e-02, 7.0000000e-02, 8.0000000e-02, 9.0000000e-02, 1.0000000e-01, 1.1000000e-01, 1.2000000e-01, 1.3000000e-01, 1.4000000e-01, 1.5000000e-01, 1.6000000e-01, 1.7000000e-01, 1.8000000e-01, 1.9000000e-01, 2.0000000e-01, 2.1000000e-01, 2.2000000e-01, 2.3000000e-01, 2.4000000e-01, 2.5000000e-01, 2.6000000e-01, 2.7000000e-01, 2.8000000e-01, 2.9000000e-01, 3.0000000e-01, 3.1000000e-01, 3.2000000e-01, 3.3000000e-01, 3.4000000e-01, 3.5000000e-01, 3.6000000e-01, 3.7000000e-01, 3.8000000e-01, 3.9000000e-01, 4.0000000e-01, 4.1000000e-01, 4.2000000e-01, 4.3000000e-01, 4.4000000e-01, 4.5000000e-01, 4.6000000e-01, 4.7000000e-01, 4.8000000e-01, 4.9000000e-01]), data_type='vel') array#

Generate a discrete Minimum Jerk Trajectory (MJT) movement speed profile of the given amplitude, duration and time location for the given time span.

Parameters:
  • amp (float) – Amplitude of the MJT discrete movement.

  • dur (float) – Duration of the MJT discrete movement.

  • loc (float) – The temporal location of the center of the MJT speed profile.

  • time (np.array) – The time values for which the speed profile values are to be returned.

  • data_type (string) – The type data returned by the function. The function can return velocity, acceleration or jerk. There are only three possibilities, {‘vel’, ‘accl’, ‘jerk’}, corresponding to velocity, acceleration and jerk.

Returns:

movement – The movement speed profile of the MJT discrete movement.

Return type:

np.array

Notes

Examples