Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] int object is not iterable

edited March 2015 in OpenSesame

Hi all!

I'm programming an experiment in which I have created 8 different image buttons (the image of the buttons are recall referring to the loop list); I need to collect both accuracy and reaction times from them. I have tried to use the inline code but when I run it opensesame gave me the following error:

TypeErrore: 'int' object is not iterable

When I use "fixed" images instead of referring to the loop list this error disappear.
Is there any way to record the data when the image buttons are not "fixed" images?

Thanks in advance!!

Best,
Andrea

Comments

  • edited 8:54AM

    Hi Andrea,

    It is a bit hard to offer you a solution based on the information you provided.
    In general, your error often occurs, if one is trying to loop over a single element of a list, instead of over the entire list. Therefore, I suppose you did something similar when you check your buttons. However, as long as you're not providing a bit more information on the code you are using, I can't really tell what exactly is going wrong.

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited February 2015

    Hi Eduard!

    Thank you so much for your reply and your suggestions! I'm not sure I've completely understood what the problem is...Do you mean that there are some variable on my list that are not include in the loop?
    I attach the code I'm using. After that code I insert a logger with the default options selected.

    from libopensesame import widgets
    
    # Create a form
    form = widgets.form(self.experiment, cols=[1,1,1,1], rows=[1,1], margins=10,10,10,10), spacing=15)
    
    # Create widgets
    image_button1 = widgets.image_button(form, path=self.experiment.get_file(self.get('dist1')), var='dist1')
    image_button2 = widgets.image_button(form, path=self.experiment.get_file(self.get('dist2')), var='dist2')
    image_button3 = widgets.image_button(form, path=self.experiment.get_file(self.get('dist3')), var='dist3')
    image_button4 = widgets.image_button(form, path=self.experiment.get_file(self.get('dist4')), var='dist4')
    image_button5 = widgets.image_button(form, path=self.experiment.get_file(self.get('dist5')), var='dist5')
    image_button6 = widgets.image_button(form, path=self.experiment.get_file(self.get('dist6')), var='dist6')
    image_button7 = widgets.image_button(form, path=self.experiment.get_file(self.get('dist7')), var='dist7')
    image_button8 = widgets.image_button(form, path=self.experiment.get_file(self.get('dist8')), var='dist8')
    
    
    # Add the widgets to the form. 
    form.set_widget(image_button1, (0,0), colspan=1, rowspan=1)
    form.set_widget(image_button2, (0,1), colspan=1, rowspan=1)
    form.set_widget(image_button3, (1,0), colspan=1, rowspan=1)
    form.set_widget(image_button4, (1,1), colspan=1, rowspan=1)
    form.set_widget(image_button5, (2,0), colspan=1, rowspan=1)
    form.set_widget(image_button6, (2,1), colspan=1, rowspan=1)
    form.set_widget(image_button7, (3,0), colspan=1, rowspan=1)
    form.set_widget(image_button8, (3,1), colspan=1, rowspan=1)
    
    
    # Determine the starting time of the form item
    start_time = self.time()
    
    # Execute the form
    button_clicked = form._exec()
    
    # Determine the current time:
    timestamp = self.time()
    
    # Determine RT
    self.experiment.set('response_time', timestamp-start_time)
    

    Sorry for the format of the code! I've tried to upload an image but I wasn't successful!!

    Thank you so much again!!!
    Andrea

  • edited 8:54AM

    Thanks.....


    GuL

  • edited 8:54AM

    Hi Andrea,

    Could you also post at which point the error message occurs? Maybe it is easiest, if you upload the entire experiment and share it here.

    Thanks,

    Eduard

    Buy Me A Coffee

  • edited 8:54AM

    Hi,

    the error occurs before the screen with the eight image_button appears.
    I've also shared the entire experiment; here it's the link:

    http://www.filedropper.com/fullfaces

    Thank you!

    Andrea

  • edited 8:54AM

    Hi Andrea,

    You uploaded an .opensesame file. These files only include the script you wrote, but not the files in the filepool. Therefore, I can't run it (Images are not found). Could you please save the experiment as a opensesame.tar.gz and upload this one again?

    Thanks,

    Eduard

    Buy Me A Coffee

  • edited 8:54AM

    Hi Eduard,

    You're right!! Sorry for the incovenience!! Here it is:

    http://www.filedropper.com/fullfacesopensesametar

    Thank you so much,
    Andrea

  • edited 8:54AM

    Hi Andrea,

    I just tried your experiment, and it works without any trouble. Are you sure that you haven't "accidentally" solved the issue already by yourself?
    What version of OpenSesame are you running? Maybe if you update it to 2.9.4, it will work (that's the one I am running right now).
    If you can reproduce the error, can you post the error message here? Maybe this will help to see what goes wrong in your case.

    Thanks,

    Eduard

    Buy Me A Coffee

  • edited 8:54AM

    Hi Eduard,

    I have tried my experiment again (the same I've uploaded) and it gives me the same error.
    Actually, I'm running the 2.9.2 version of OpenSesame; so I'll update my version of OpenSesame and try it again!
    Meanwhile I post here the error message the experiment gives to me:

    http://img.cogsci.nl/?q=550702bd04c21

    Thank you so much!

    Andrea

  • edited 8:54AM

    I've update my version of OpenSesame to 2.9.4 and tried it again, but it still gives me the same error.
    I don't really know what could be....could the backend make any difference?

  • edited 8:54AM

    Hi Andrea,

    You ran into an unfortunate combination of weird images and a bug in OpenSesame. On some systems (Windows, but not Linux), OpenSesame fails to read your images using the standard mechanism. If that happens, it falls backs to a different mechanism. But the fallback mechanism had a bug, which resulted in the weird error message.

    So the solution would be to either:

    • Update to the latest prerelease of 2.9.5 (>= pre6), which should fix this issue.
    • Use a different image format, such as .png.

    could the backend make any difference

    This is not really related to this issue, but yes, different back-ends support different image formats. But all common formats are supported by all back-ends.

    Cheers,
    Sebastiaan

  • edited 8:54AM

    Hi Sebastiaan,

    oh I see! I've change the image format to .png and now the experiment works!

    Thank you so much!

    Andrea

Sign In or Register to comment.