Choice Comparison

Overview

The Choice Comparison Template is a versatile SightLab experiment template designed to allow participants to make choices between two objects using various input methods: laser pointer, rating scale, or keypress. This template can be easily set up using either the SightLab GUI or leveraging the built in SightLab and Vizard code, as well as expanding with python. The default configuration involves choosing between two food items, but it can be adapted for various comparison tasks.

Use for Consumer Preference Studies , Product Placement, Decision Making Strategies and more. 

Features

Key Components of Potential Studies:

Code Example: Laser Pointer

Below is an example of the SightLab experiment script using a laser pointer for making choices.

import sightlab_utils.sightlab as sl

from sightlab_utils.settings import *

from sightlab_utils import selector

from tools import highlighter

import vizshape


sightlab = sl.SightLab()

sightlab.setStartText(' ')


def sightLabExperiment():

    i = 0

    while True:

        if i == 0:

            yield viztask.waitEvent(EXPERIMENT_START)

            i = 1


        yield sightlab.startTrial(startExperimentText="Use the grip button to bring up higlighter and Trigger to Choose Your Preference.\n\n Press Trigger to begin")

selector.setupSelector(sightlab.getConfig())

        env = sightlab.getEnvironment()

        target_names = list(sightlab.sceneObjects[GAZE_OBJECTS].keys())


        target_objects = {}

        object_name_map = {}


        for name in target_names:

            obj = env.getChild(name)

            if obj:

                sightlab.addSceneObject(name, obj, gaze=True, grab=True)

                target_objects[name] = obj

                object_name_map[obj] = name

                print(f'Added {name} to scene objects: {obj}')


        selector.tool.setItems(list(target_objects.values()))

        selector.tool2.setItems(list(target_objects.values()))

        selector.tool.setHighlightMode(highlighter.MODE_NONE)

        selector.tool2.setHighlightMode(highlighter.MODE_NONE)


        targetObject = list(target_objects.values())

        print(f'Target objects: {targetObject}')


        global isConfirmingTarget, currentHighlightedObject, readyToConfirm

        isConfirmingTarget = False

        readyToConfirm = False

        currentHighlightedObject = None


        def confirmTarget(e):

            global isConfirmingTarget, readyToConfirm, currentHighlightedObject

            if readyToConfirm and currentHighlightedObject in targetObject:

                isConfirmingTarget = True

                object_name = object_name_map.get(currentHighlightedObject, 'Unknown object')

                print(f'{object_name} is confirmed')

                readyToConfirm = False  # Reset the flag after confirmation

                currentTime = round(sightlab.hud.getCurrentTime(), 4)  # Round to 4 decimal places

                sightlab.setExperimentSummaryData('Choice', object_name)

                sightlab.setExperimentSummaryData('Time', currentTime)


        viz.callback(viz.getEventID('triggerPress'), confirmTarget)

        viz.callback(viz.getEventID('triggerPressLeft'), confirmTarget)


        def onHighlight(e):

            global currentHighlightedObject, readyToConfirm

            currentHighlightedObject = e.new

            if currentHighlightedObject in targetObject:

                object_name = object_name_map.get(currentHighlightedObject, 'Unknown object')

                print(f'{object_name} is highlighted')

                readyToConfirm = True  # Set the flag when an object is highlighted


        viz.callback(highlighter.HIGHLIGHT_EVENT, onHighlight)


        while not isConfirmingTarget:

            yield viztask.waitTime(0.1)


        yield viztask.waitTime(0.7)


        yield sightlab.endTrial(endExperimentText="Thank you for participating")

        yield viztask.waitTime(2)


viztask.schedule(sightlab.runExperiment)

viztask.schedule(sightLabExperiment)

viz.callback(viz.getEventID('ResetPosition'), sightlab.resetViewPoint)

Data Analysis and Visualization

The template provides tools to analyze and visualize the data collected during the experiment. This includes:

Running the Experiment

Connecting to Biopac Acqknowledge

The template supports integration with Biopac Acqknowledge for synchronizing physiological data. Ensure that the Biopac system is correctly set up and connected before running the experiment. The data will be synchronized and saved for further analysis.

Customization

The template can be easily customized to fit different research needs: