Hi all!
My lab primarily used MATLAB in the past, but we are trying to transition to online experiments at the moment.
I am trying to mimic the experiment that was built in MATLAB but I am having some difficulty.
The main issue I am having now is in trying to present a square that oscillates around a center point from left to right.
Here is the code I am using:
from psychopy import visual,core,event
import numpy as np
import random
# Specify Window Size
win = visual.Window(
size = (1920,1080),
units='pix',
fullscr= True,
monitor = "default",
waitBlanking = True
)
clock = core.Clock()
# Get Center of Screen
xCenter = win.size[0]/2
# Get Frame Interval
ifi = 1000/60
rect = visual.Rect(
win, # Where to display
units="pix", # What unit
width=100, # Original width
height=100,# Original height
fillColor=[-1,-1,-1], # Black
lineColor=[-1,-1,-1] # Black
)
amplitude = 960 * 0.25
frequency = 0.2
angFreq = 2 * np.pi * frequency
startPhase = 0
time = 0
for practice in range(5):
timestart = core.getTime()
while ((core.getTime()-timestart) < 1):
xpos = amplitude * np.sin(angFreq * time + startPhase)
squareXpos = 0+xpos
rect.pos = (squareXpos,0)
rect.draw()
win.flip()
time = time + ifi
print(rect.pos[0])
I am using this site as a reference point and trying to MATLAB > python/psychopy.
Currently the square move extremely fast from left to right but there are three simultaneous images at once. I want to just have one square that glides from left to right.
This is my first time posting here so if I am missing anything I apologize and I will add it ASAP!
Thank you!