Flipping the mirror image

228 views
Skip to first unread message

Sampada

unread,
Dec 7, 2013, 10:47:27 PM12/7/13
to psychop...@googlegroups.com
Hello everyone,

I have built this experimental model where I have to show words to the participant under the fMRI machine. Since the headset of the machine has two mirrors the image is getting flipped. I went to properties of the trial and tried to work with flip (mirror) option but its is not working. Will someone please tell me how do I flip the words so that the participant can see proper word image on the mirror?  Do I need to add something in the coder view and if yes then where should I write the command?



Initialize components for Routine "trial"
trialClock = core.Clock()
wordtrial1 = visual.TextStim(win=win, ori=0, name='wordtrial1',
    text='nonsense',    font='Arial',
    pos=[0, 0], height=0.1, wrapWidth=None,
    color=[-1.000,-1.000,-1.000], colorSpace='rgb', opacity=1,
    depth=0.0)


Thanks and regards,

Sampada

Sampada

unread,
Dec 7, 2013, 10:49:23 PM12/7/13
to psychop...@googlegroups.com
Also, I went to the user forum and found this but don't know where do I write this command.

Jeremy Gray

unread,
Dec 7, 2013, 11:00:16 PM12/7/13
to psychop...@googlegroups.com
From the builder see the tooltip over the flip box in the text component. 

From coder I think it's flipHoriz and flipVert=True, or google for the psychopy API for text if that does not work. The online API is super helpful for this sort of thing. 

Jeremy 

/* sent from a phone; pls forgive typo & brevity */ 
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/492cba39-d1df-45d7-8903-c6e867e12cd8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sampada

unread,
Dec 8, 2013, 4:02:59 AM12/8/13
to psychop...@googlegroups.com
Hello Jeremy,

Thanks for your reply.

Problem with the Builder view:  In the builder view  I already used the tool tip  'horiz' to flip the image to reverse before I posted my query here, but its not recognizing the 'horiz' command and though the experiment is still running the image remain is as it is. Interestingly when I checked the coder view to confirm the change I did in the builder view it does not show the new change.

Problem with the Coder view: When I typed the code flipHoriz=True within the trial Textstim it said 'invalid syntax' and when I wrote this code outside the textstim it said 'indentation error-Unexpected indent'.

I referred the API (under TextStim) before and I tried to make my experiment work but its still not flipping the image to reverse.

Regards,

Sampada


On Saturday, December 7, 2013 10:47:27 PM UTC-5, Sampada wrote:

Michael MacAskill

unread,
Dec 8, 2013, 4:35:32 AM12/8/13
to psychop...@googlegroups.com
I just tried this in Builder and can confirm that the "Flip (mirror)" setting has no visible effect. The flipHoriz attribute doesn't get set in the .py file.

Sampada: if you edit the .py file in the Coder view like this, it will work:

text = visual.TextStim(win=win, ori=0, name='text',
text=u'Any text\n\nincluding line breaks', font=u'Arial',
pos=[0, 0], height=0.1, wrapWidth=None,
color=u'white', colorSpace=u'rgb', opacity=1,
depth=-1.0, flipHoriz=True)

NB this file gets overwritten each time a change is made in the Builder view, so for this hack to work, you should save the file with a new name and then run it from the Coder view.

This isn't ideal, however, as it means you can't make further changes in Builder.

So this is probably a bug that needs to be addressed. For developers, I found that when selecting "set every repeat" rather than "constant", these lines appeared in the code:

# update component parameters for each repeat
text.setFlip(u"'horiz'")

So at least some attempt is made to set that attribute in that case. But there is still no visible effect. Haven't dug into the code to see how these setters work, but somehow this doesn't seem to be turned into the equivalent of 'flipHoriz=True' (and similarly for vertical flipping).

Cheers,

Mike

Michael MacAskill

unread,
Dec 8, 2013, 4:48:30 AM12/8/13
to psychop...@googlegroups.com
Hi Sampada,

On further investigation, the error is just in the tooltip hint itself.

Don't type 'horiz' in the "Flip (mirror" field. Instead, just type the word horiz (i.e. without any quotes. Everything will then work as expected, and you won't need to edit the code in the Coder view.

Otherwise, the value ends up double-quoted in the code, which caused the attribute to not be applied.

Regards,

Mike




On 8 Dec, 2013, at 22:02, Sampada <drsampa...@gmail.com> wrote:

Jeremy Gray

unread,
Dec 8, 2013, 7:41:17 AM12/8/13
to psychop...@googlegroups.com
Glad to hear it was this simple. Mike, I've implemented your suggested
clarification to the tooltip, good idea.

--Jeremy
> --
> You received this message because you are subscribed to the Google Groups "psychopy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
> To post to this group, send email to psychop...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/9DCE2D96-7F59-468D-9824-8FA8713A92A0%40otago.ac.nz.

Sampada

unread,
Dec 8, 2013, 1:24:52 PM12/8/13
to psychop...@googlegroups.com
Thanks so much Michael and Jeremy. The words are getting flipped now! I used your idea of using horiz in the flip option of the builder view and its been very simple that way. Thank you so much Michael! My experiment is ready to go on floor now! 

Regards,

Sampada

On Saturday, December 7, 2013 10:47:27 PM UTC-5, Sampada wrote:

Michael MacAskill

unread,
Dec 8, 2013, 3:07:26 PM12/8/13
to psychop...@googlegroups.com
Thanks Jeremy. A trivial fix so should have done it myself but was just heading to bed…

Cheers,

Mike

Sampada

unread,
Dec 9, 2013, 10:33:06 AM12/9/13
to psychop...@googlegroups.com
Thanks Jeremy! :)


On Saturday, December 7, 2013 10:47:27 PM UTC-5, Sampada wrote:

Jonathan Peirce

unread,
Dec 9, 2013, 11:52:03 AM12/9/13
to psychop...@googlegroups.com
I forgot, but PsychoPy already has a system whereby you can scale (or flip) the entire window, which you could use for your present-in-a-mirror study.

visual.Window has an attribute called viewScale which can independently scale the x and y dimensions of everything rendered to the screen (very efficiently with nothing being recalculated). Simply set this before any rendering, or even between rednering of objects if you want somethings flipped on screen and somethings not. Just remember that the whole window coordinate frame is changing (so position as well as size is being flipped)

examples:
    win.viewScale = [-1, 1] #flip only the x axis
    win.viewScale = [-1, -1] #flip both
    win.viewScale = [2, -2] #twice as big and flipped up-down
   
hope that's helpful!
Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

-- 
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk

This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it.   Please do not use, copy or disclose the information contained in this message or in any attachment.  Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system, you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.


Sampada

unread,
Dec 9, 2013, 12:11:56 PM12/9/13
to psychop...@googlegroups.com
Thanks Jon! I will remember this next time.

Regards,

Sampada


On Saturday, December 7, 2013 10:47:27 PM UTC-5, Sampada wrote:
Reply all
Reply to author
Forward
0 new messages