Skip to content

Instantly share code, notes, and snippets.

@lindemann09
Last active August 29, 2015 14:01
Show Gist options
  • Save lindemann09/e2c5f1cf4056a2899e52 to your computer and use it in GitHub Desktop.
Save lindemann09/e2c5f1cf4056a2899e52 to your computer and use it in GitHub Desktop.
Dictionary of Expyriment pictures from files in a subfolder
import os as _os
def picture_dict(suffix, subfolder="", preload=False):
"""Returns a dictionary of Expyriment pictures from files in a subfolder
Returns
-------
picture_dict : dictionary
key: filename (with suffix)
value: Expyriment stimulus
"""
rtn = {}
path = _os.path.dirname("." + _os.path.sep + subfolder + _os.path.sep)
for flname in _os.listdir(path):
if flname.endswith(suffix):
rtn[flname] = stimuli.Picture(filename = path + _os.path.sep + flname)
if preload:
rtn[flname].preload()
return rtn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment