def setupExperiment():
    from psychopy import gui
    """
    Setup the experimental variables with a dialog box
    """
    dlgMonitor, monitorInfo = setup_monitor()

    expInfo = {
        'Partecipant': 'Subj',
        'Block': ['Unilateral', 'Bilateral', 'Uni+Bi'],
        'Subject code': '00',
        'NumBalls': 4,
        'RectWidth': 6,
        'RectHeight': 6,
        'BallRadius': 0.25,
        'Duration': 2,
        'BlinkTime': 1,
        'SimulationMode': False,
        'MaxAnswerTime': 2,
        'DrawRectangles': False
    }

    dlg = gui.DlgFromDict(
        dictionary=expInfo,
        title='Tracking Experiment',
        order=[
            'Partecipant', 'Subject code', 'Block', 'RectWidth', 'RectHeight',
            'BallRadius', 'Duration', 'BlinkTime', 'NumBalls', 'SimulationMode'
        ],
        tip={
            'Partecipant Name':
            'Name of the participant',
            'Subject code':
            'Code of the subject',
            'RectWidth':
            'Width in cm of the left or right rectangle',
            'RectHeight':
            'Height in cm of the left or right rectangle',
            'BallRadius':
            'Radius of the balls in cm',
            'Duration':
            'Duration of the stimulus in seconds',
            'BlinkTime':
            'Time of white/black ball blinking in seconds',
            'SimulationMode':
            'Run the experiment with a perfect cumulative normal observer'
        })

    if not dlg.OK:
        core.quit()  # user pressed cancel
    # nUp is the number of incorrect (or 0) responses before the staircase level increases.
    # nDown is the number of correct (or 1) responses before the staircase
    # level decreases.
    staircaseInfo = {
        'StepType': ['lin', 'db', 'log'],
        'Selection': ['random', 'sequential'],
        'TotalTrialsPerCondition': 16,
        'Unilateral-Left speed': 5.0,
        'Unilateral-Right speed': 5.0,
        'Bilateral-Left speed': 2.5,
        'Bilateral-Right speed': 2.5
    }

    dlgStaircase = gui.DlgFromDict(
        dictionary=staircaseInfo,
        title='Trials options',
        order=[
            'StepType', 'Selection', 'TotalTrialsPerCondition',
            'Unilateral-Left speed', 'Unilateral-Right speed',
            'Bilateral-Left speed', 'Bilateral-Right speed'
        ])

    if not dlgStaircase.OK:
        core.quit()

    outputfile = set_output_file(expInfo, 'trackingFixed_')
    save_experimental_settings(outputfile + '_info.pickle', expInfo,
                               staircaseInfo, monitorInfo)
    return expInfo, staircaseInfo, outputfile, monitorInfo
Example #2
0
def setupExperiment():
    from psychopy import gui
    """
    Setup the experimental variables with a dialog box
    """
    dlgMonitor, monitorInfo = setup_monitor()

    expInfo = {
        'Partecipant': 'Subj',
        'Subject code': '00',
        'SquareEdge': 6,
        'BallRadius': 2,
        'TrainingTrials': 0,
        'SaveVideo': False,
        'ContrastDuration': 2.0
    }

    dlg = gui.DlgFromDict(dictionary=expInfo,
                          title='Flicker Experiment',
                          order=[
                              'Partecipant',
                              'Subject code',
                              'SquareEdge',
                              'BallRadius',
                              'TrainingTrials',
                          ],
                          tip={
                              'Partecipant Name':
                              'Name of the participant',
                              'Subject code':
                              'Code of the subject',
                              'SquareEdge':
                              'Length of the virtual square edge',
                              'BallRadius':
                              'Radius of the balls in cm',
                              'TrainingTrials':
                              'Number of preparation training trials',
                          })

    if dlg.OK is False:
        core.quit()  # user pressed cancel

    # nUp is the number of incorrect (or 0) responses before the staircase level increases.
    # nDown is the number of correct (or 1) responses before the staircase
    # level decreases.
    staircaseInfo = {
        'StepType': ['lin', 'db', 'log'],
        'Selection': ['random', 'sequential'],
        'MinReversals': 6,
        'MinTrials': 10,
        'ContrastLeft': 0.0,
        'ContrastRight': 0.0,
        'StepSizes': '[0.05]',
        'nUpLeft': 1,
        'nUpRight': 1,
        'nDownLeft': 1,
        'nDownRight': 1,
        'AverageReversals': 3
    }

    dlgStaircase = gui.DlgFromDict(dictionary=staircaseInfo,
                                   title='Staircase procedure')

    if dlgStaircase.OK is False:
        core.quit()

    outputfile = set_output_file(expInfo, 'contrast_')
    save_experimental_settings(outputfile + '_info.pickle', expInfo,
                               staircaseInfo, monitorInfo)
    return expInfo, staircaseInfo, outputfile, monitorInfo