rsatoolbox.simulation.sim module

Functions for data simulation a specific RSA-model

make_design: creates design and condition vectors for fMRI design

make_dataset: creates a data set based on an RDM model

@author: jdiedrichsen

rsatoolbox.simulation.sim.make_dataset(model, theta, cond_vec, n_channel=30, n_sim=1, signal=1, noise=1, signal_cov_channel=None, noise_cov_channel=None, noise_cov_trial=None, use_exact_signal=False, use_same_signal=False)[source]

Simulates a fMRI-style data set

  • model (rsatoolbox.Model) – the model from which to generate data

  • theta (numpy.ndarray) – vector of parameters (one dimensional)

  • cond_vec (numpy.ndarray) –

    RSA-style model:

    vector of experimental conditions


    design matrix (n_obs x n_cond)

  • n_channel (int) – Number of channels (default = 30)

  • n_sim (int) – Number of simulation with the same signal (default = 1)

  • signal (float) – Signal variance (multiplied by predicted G)

  • signal_cov_channel (numpy.ndarray) – Covariance matrix of signal across channels

  • noise (float) – Noise variance

  • noise_cov_channel (numpy.ndarray) – Covariance matrix of noise (default = identity)

  • noise_cov_trial (numpy.ndarray) – Covariance matrix of noise across trials

  • use_exact_signal (bool) – Makes the signal so that G is exactly as specified (default: False)

  • use_same_signal (bool) – Uses the same signal for all simulation (default: False)


List of rsatoolbox.Dataset with obs_descriptors

Return type:

data (list)

rsatoolbox.simulation.sim.make_design(n_cond, n_part)[source]

Makes simple fMRI design with n_cond, each measures n_part times

  • n_cond (int) – Number of conditions

  • n_part (int) – Number of partitions


Tuple (cond_vec, part_vec) cond_vec (np.ndarray): n_obs vector with condition part_vec (np.ndarray): n_obs vector with partition

rsatoolbox.simulation.sim.make_signal(G, n_channel, make_exact=False, chol_channel=None)[source]

Generates signal exactly with a specified second-moment matrix (G)

To avoid errors: If the number of channels is smaller than the number of patterns we generate a representation with the minimal number of dimnensions and then delete dimensions to yield the desired number of dimensions.

  • G (np.array) – desired second moment matrix (ncond x ncond)

  • n_channel (int) – Number of channels

  • make_exact (bool) – enforce exact signal distances (default: False)

  • chol_channel – Cholensky decomposition of the signal covariance matrix (default: None - makes signal i.i.d.)


random signal

Return type:

np.array (n_cond x n_channel)