URL of experiment: Sign in · GitLab
Below is the python code from the Begin Experiment tab of one of my code components in the builder:
# Get current time
now_AV = ptb.GetSecs()
background_sound_AV = sound.Sound('Sound_stim/T500bi_100ms.wav', volume = 1.0)
# get all filenames containing images in my directory
filenames_AV = glob.glob(os.path.join('/Users/ha/Library/CloudStorage/OneDrive-Personal/Seaver_Intern_24/dotImages', '*.png'))
# create an array that will contain the images
images_AV =[]
# add all the images to the list of 'images'
for eachfile in filenames_AV:
images_AV.append(visual.ImageStim(win=win, image=eachfile))
# save the number of images to be displayed
numberOfImages_AV = len(images_AV)
# check to see if there are any files in the directory containing images
if numberOfImages_AV < 1:
errorMsg_AV = 'No Images found in the Images Directory'
logging.warning(errorMsg_AV)
# establish the first image
whichImage_AV = random.randint(0, numberOfImages_AV - 1)
Below is another piece of python code from the Begin Experiment tab in the code component in the builder:
# Get current time
now_V = ptb.GetSecs()
# Get the sound stimulus file for the experiment
# Setting volume to zero because we are using this file as a timing mechanism
background_sound_V = sound.Sound('Sound_stim/T500bi_100ms.wav', volume = 0)
# get all filenames containing images in my directory
filenames_V = glob.glob(os.path.join('/Users/ha/Library/CloudStorage/OneDrive-Personal/Seaver_Intern_24/dotImages', '*.png'))
# create an array that will contain the images
images_V =[]
# add all the images to the list of 'images'
for eachfile in filenames_V:
images_V.append(visual.ImageStim(win=win, image=eachfile))
# save the number of images to be displayed
numberOfImages_V = len(images_V)
# check to see if there are any files in the directory containing images
if numberOfImages_V < 1:
errorMsg_V = 'No Images found in the Images Directory_V'
logging.warning(errorMsg_V)
# establish the first image
whichImage_V = random.randint(0, numberOfImages_V - 1)
#start with the first image
#whichImage = 0
#lastImage = 0
Description of the problem:
I am not the best at coding and have never used JavaScript or tried to create an online experiment. So if anyone can help me convert these code components into JavaScript it would be greatly appreciated.