예제 #1
0
import numpy as np

cycles = 5000  # try cycles=10 for testing and cycles=5000 for real applications
sims = 10

exercise = 'part4'  # change this for each exercise

# define the experiment
EXP = experiment(
    TR=2,
    duration=300,
    P=[1.0 / 5.0, 1.0 / 5.0, 1.0 / 5.0, 1.0 / 5.0, 1.0 / 5.0],
    C=[[1.0, -1.0, 0, 0, 0], [0, 0, 1.0, -1.0, 0], [1.0, 1.0, -1.0, -1.0, 0]],
    n_stimuli=5,
    rho=0.3,
    resolution=0.1,
    stim_duration=1,
    ITImodel='exponential',
    ITImin=1,
    ITImean=2,
    ITImax=5,
    confoundorder=3,  # this cannot be 0
    hardprob=True,
)

# optimize the design for detection efficiency only using GA
POP_GA = optimisation(experiment=EXP,
                      weights=[0, 0.5, 0.5, 0],
                      preruncycles=2,
                      cycles=cycles,
                      seed=1,
                      outdes=5,
예제 #2
0
import numpy as np

cycles = 5000 # try cycles=10 for testing and cycles=5000 for real applications
sims = 10

exercise = 'part1' # change this for each exercise

# define the experiment
EXP = experiment(
    TR=2,
    duration=300,
    P = [.5, .5],
    C = [[1.0, -1.0]],
    n_stimuli = 2,
    rho = 0.3,
    resolution=0.1,
    stim_duration=1,
    ITImodel = 'exponential',
    ITImin = 1,
    ITImean = 4,
    ITImax=30,
    confoundorder=1, # this cannot be 0
    hardprob=True,
    )

# optimize the design for detection efficiency only using GA
POP_GA = optimisation(
    experiment=EXP,
    weights=[0,1,0,0],
    preruncycles = 2,
    cycles = cycles,
    seed=1,
예제 #3
0
import neurodesign

EXP = neurodesign.experiment(TR=1.2,
                             n_trials=20,
                             P=[0.3, 0.3, 0.4],
                             C=[[1, -1, 0], [0, 1, -1]],
                             n_stimuli=3,
                             rho=0.3,
                             stim_duration=1,
                             ITImodel="uniform",
                             ITImin=2,
                             ITImax=4)

DES1 = neurodesign.design(
    order=[0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1],
    ITI=[2] * 20,
    experiment=EXP)

DES1.designmatrix()

DES1.FCalc(weights=[0.25, 0.25, 0.25, 0.25])

import matplotlib.pyplot as plt

plt.plot(DES1.Xconv)
plt.savefig("output/example_figure_1.pdf", format="pdf")

DES2 = neurodesign.design(
    order=[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
    ITI=[2] * 20,
    experiment=EXP)
예제 #4
0
# ## Optimise designs

# First we define the experiment.  We will optimise an experiment with a TR of 2 seconds and 250 trials of 0.5 seconds each.  There are 4 stimulus types, and we are interested in the shared effect of the first and second stimulus versus baseline, as well as the difference between the first and the fourth stimulus.  We assume an autoregressive temporal autocorrelation of 0.3.
#
# We sample ITI's from a truncated exponential distribution with minimum 0.3 seconds and maximum 4 seconds, and the mean is 1 second.

# In[2]:

# define the experiment
EXP = experiment(TR=2,
                 n_trials=450,
                 P=[0.25, 0.25, 0.25],
                 C=[[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 0, -1]],
                 n_stimuli=3,
                 rho=0.3,
                 resolution=0.1,
                 stim_duration=1,
                 ITImodel="exponential",
                 ITImin=0.3,
                 ITImean=1,
                 ITImax=4)

# In[3]:

POP_Max = optimisation(experiment=EXP,
                       weights=[0, 0.5, 0.25, 0.25],
                       preruncycles=cycles,
                       cycles=2,
                       optimisation='GA')

POP_Max.optimise()
예제 #5
0
import neurodesign
from neurodesign import generate
import numpy as np

# define experimental setup

EXP = neurodesign.experiment(TR=2,
                             n_trials=20,
                             P=[0.3, 0.3, 0.4],
                             C=[[1, -1, 0], [0, 1, -1]],
                             n_stimuli=3,
                             rho=0.3,
                             stim_duration=1,
                             t_pre=0.5,
                             t_post=2,
                             ITImodel="exponential",
                             ITImin=2,
                             ITImax=4,
                             ITImean=2.1)

# define first design with a fixed ITI

DES = neurodesign.design(
    order=[0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1],
    ITI=[2] * 20,
    experiment=EXP)

# expand to design matrix

DES.designmatrix()
DES.FCalc(weights=[0, 0.5, 0.25, 0.25])
예제 #6
0
from neurodesign import experiment, optimisation, generate,msequence,report

EXP = experiment(
    TR=2,
    n_trials=100,
    P = [0.33,0.33,0.33],
    C = [[1,0,0],[0,1,0],[0,0,1],[1,-1,0],[0,1,-1]],
    n_stimuli = 3,
    rho = 0.3,
    resolution=0.1,
    stim_duration=1,
    t_pre = 0,
    t_post = 2,
    restnum=0,
    restdur=0,
    ITImodel = "exponential",
    ITImin = 1,
    ITImean = 2,
    ITImax=4
    )

POP = optimisation(
    experiment=EXP,
    weights=[0,0.5,0.25,0.25],
    preruncycles = 10,
    cycles = 10,
    seed=1,
    outdes=5,
    folder='/Users/Joke/'
    )