Last active
August 29, 2015 14:01
-
-
Save lindemann09/e2c5f1cf4056a2899e52 to your computer and use it in GitHub Desktop.
Dictionary of Expyriment pictures from files in a subfolder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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