jeudi 29 septembre 2016

Generating psuedo random lists with specific constraints in Python

I am relatively new to python and am trying to implement it (and psychopy) in a simple experiment that loads either target or distractor images in a new order every time it is run.

The experimenter puts constants into a GUI when it initiates that dictate specific constraints about the order of the list as follows (percentages and locations can change)

  • % distractors 90

  • % targets 10

  • min number of distractors between targets = 4

  • targetdirectory = (directory of where the target images are)

  • distractordirectory = (directory of where the distractor images are)

My goal would be to have something generate a list of the image names based on the directories that meet the criteria that the experimenter would input.

The only way I can think of doing this now is by having python generate a list of images from the two directories given the percentages, then randomize it, and finally loop to check the number between targets is more than 4.

Does anyone have any ways that I could simplify this?

Are there other random snippets of code I might be missing that would make this easier? Or that would make this approach easier?

Thank you!




Aucun commentaire:

Enregistrer un commentaire