Adjusting sampling rate of continuously rated data

PsychoPy version (e.g. 1.84.x):

I have made an experiment in PsychoPy builder to continuously collect urge to move data when listening to a track. Is it possible to adjust the sampling rate/how many times per second data is collected (Ex. making it 4 Hz/per second)?

Hi @Ksab22, it’s not as straightforward as just lowering the sampling frequency. But you can start a timer in the beginning of the routine, continuously check whether it has passed .25 seconds and if so, take a sample and reset the timer. This would work like this:

Begin routine

rating = []
timestamp = []

timer = core.Clock()

Each frame

if timer.getTime() >= .25:
    rating.append(slider.getMarkerPos())
    timestamp.append(t)
    timer.reset()

Hi @ajus, Thanks so much for the reply. Do I need to put anything in the brackets of the code? Because when I look at the data after running the experiment in Pavlovia it seems to be sampling the same as before adding the code. Is there anything I can provide to help with understanding the issue? It also doesn’t seem to be showing all the data

Nothing is needed in the brackets.

Have you added any code to save the data?

In End Routine

thisExp.addData('ratings',rating)
thisExp.addData('timestamps',timestamp)

Thanks so much for your help. I added the end code