[PYTHON] Run a limited number of image presentation programs on PsychoPy

Hello. I'm new to python.

At university, I'm making a presentation program that reads a PNG format file in a folder named images, shuffles it, and displays it randomly, but after presenting the presented images, another folder (image = used). I want to remodel it so that it can be moved to a folder named). What kind of code should I add to the code below? I also want to be able to set a limit on the number of times. Run with psychopy.

from psychopy import visual, core, event import random, pathlib import csv import glob

if name == 'main':

stimuli_list = glob.glob('images/*.PNG')

for filename in stimuli_list: with open(filename, 'r') as input: random.shuffle (stimuli_list); # Randomize the order print (stimuli_list); # Display random order

current_folder = pathlib.Path (__ file__) .parent # Identify the folder containing the running program new_filename = "results_presented_stimuli.csv" # Use new filename in program with name new_filename new_filepath = current_folder / new_filename # specify new file path datafile = open (new_filepath, mode ='w') # create new file

win = visual.Window() fixation_stim = visual.TextStim (win, "+") # Notepoint no_trials = 0 # initialization of no_trials

for stim in stimuli_list: fixation_stim.draw () #Drawing the gaze point win.flip () #Display the gazing point resp = event.waitKeys (keyList = ['space','q','return']) #Waiting for space key input if resp == ['q']: Exit when #q is entered break stimulus = visual.ImageStim (win, stim) #Preparation for image stimulation stimulus.draw () #Draw image stimulus win.flip () #Display image stimulus core.wait(1.5) no_trials = no_trials + 1 data ='{}, {} \ n'.format (no_trials, stim) # Comma-separated strings datafile.write (data) # Write to file

datafile.close () # close the file win.close()

Recommended Posts

Run a limited number of image presentation programs on PsychoPy
Run headless-chrome on a Debian-based image
Paste a large number of image files into PowerPoint [python-pptx]
Get the number of readers of a treatise on Mendeley in Python
Run a Linux server on GCP
Run TensorFlow Docker Image on Python3
Run Matplotlib on a Docker container
Run TensorFlow2 on a VPS server
I measured the run queue wait time of a process on Linux
Run a batch of Python 2.7 with nohup on Amazon Linux AMI on EC2
Connect a large number of videos together!
Run Python code on A2019 Community Edition
Run Jupyter notebook on a remote server
Run matplotlib on a Windows Docker container
One-liner to create a large number of test files at once on Linux
[Python] Plot data by prefecture on a map (number of cars owned nationwide)