If this template helps then use it. If not then just delete and start from scratch.
Win11:
v2023.2.3:
Hi,
I am trying to build an experiment for the fMRI where people rate items with a slider. I have managed to use code components to make the slider usable with certain keys (which i will map to the button box of the MRI). The items will be presented one after the other and will only show for 10 seconds.
Up to this point everything runs smoothly, however the responses are not being recorded. I want the response at which the marker is placed at the time the routine ends to be the one recorded.
This moves the marker:
Begin Routine
event.clearEvents('keyboard')
sliderRating.markerPos = 2
Each Frame:
keys = event.getKeys()
if len(keys):
if 'left' in keys:
sliderRating.markerPos = sliderRating.markerPos - 1
elif 'right' in keys:
sliderRating.markerPos = sliderRating.markerPos + 1
This ends the routine after a certain time:
Begin Routine
startTime = core.Clock()
kb = keyboard.Keyboard()
each Frame
if startTime.getTime() >= 10:
sliderRating.recordRating(sliderRating.getRating())
continueRoutine = False
As you can see I used “sliderRating.recordRating(sliderRating.getRating())” here to record a response when the routine ends. I also tried placing this code at the End Routine tab of the code component that controls the slider movement, but both do not work.
If someone has any solutions I would be very thankful!
Best,
Niklas