grating + noise

580 views
Skip to first unread message

Pablo

unread,
Nov 9, 2011, 12:54:02 PM11/9/11
to psychopy-users
Hi all
I would like to use psychopy to present gratings embedded in random
noise. How could I build such image using visual.PatchStim? I can get
nice gratings but I cannot add noise.
Thanks
Pablo

Rebecca Sharman

unread,
Nov 10, 2011, 11:51:26 AM11/10/11
to psychop...@googlegroups.com
Hi Pablo,

In order to generate noise you want to create a code component like this: http://www.psychopy.org/builder/components/code.html#create-a-patch-of-noise

If you want the grating to be on top of it then just make sure it's drawn before the grating and if you want it to overlay the grating do the opposite.

Hope that helps,
Becky


--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To post to this group, send email to psychop...@googlegroups.com.
To unsubscribe from this group, send email to psychopy-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/psychopy-users?hl=en.


Daniel Shub

unread,
Nov 26, 2011, 12:48:25 PM11/26/11
to psychop...@googlegroups.com

I am running v1.71.00 on both Linux and Windows. I am having problems with the staircase loop in builder. I can run the builder psychophysicsStaircase demo fine. If I try and edit the trials loop I get the following error in the coder view output window:

 

  File "C:\Program Files\PsychoPy2\lib\site-packages\psychopy-1.70.00-py2.6.egg\psychopy\app\builder\builder.py", line 342, in OnMouse

    self.editLoopProperties(loop=comp)

  File "C:\Program Files\PsychoPy2\lib\site-packages\psychopy-1.70.00-py2.6.egg\psychopy\app\builder\builder.py", line 312, in editLoopProperties

    condOrig = loop.params['conditions'].val

KeyError: 'conditions'

 

I have no idea why the error say 1.70.00 and not 1.71.01. I am also not sure if that is what is causing the error. If I try and build my own experiment and add a loop with insert loop and set the loopType to be staircase, I get the following error:

 

Traceback (most recent call last):

  File "C:\Program Files\PsychoPy2\lib\site-packages\psychopy-1.70.00-py2.6.egg\psychopy\app\builder\builder.py", line 2273, in onOK

    self.refreshConditions()

  File "C:\Program Files\PsychoPy2\lib\site-packages\psychopy-1.70.00-py2.6.egg\psychopy\app\builder\builder.py", line 2250, in refreshConditions

    val = self.currentCtrls['conditionsFile'].valueCtrl.GetValue()

KeyError: 'conditionsFile'

 

Again, it refers to 1.70.00. Any ideas as to what I am doing wrong?

 

Thanks

 

Dan


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.

Jonathan Peirce

unread,
Nov 27, 2011, 7:13:03 AM11/27/11
to psychop...@googlegroups.com
Yes, I actually spotted this one too. It's a bug that appeared around version 1.70 when we started trying to check whether there were name conflicts with the conditions file (for method of constants designs) and accidentally performed on staircases as well even though they don't have a conditions file.

It's fixed in the repository, and in the latest test release that is uploaded here:
    http://code.google.com/p/psychopy/downloads/list

If you download the zip file manually and install it using the tools>updates menu item you should be up and running again.

Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To post to this group, send email to psychop...@googlegroups.com.
To unsubscribe from this group, send email to psychopy-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/psychopy-users?hl=en.

-- 
Dr. Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk/

Jan Willem de Gee

unread,
Nov 22, 2013, 8:25:16 AM11/22/13
to psychop...@googlegroups.com
Hello,


However, if I want to have visual noise of bigger grain, what do I do?

Thanks in advance!

JW

Jan Willem de Gee

unread,
Nov 22, 2013, 8:47:15 AM11/22/13
to psychop...@googlegroups.com
Well -- asking the question often is answering it:

noiseTexture = scipy.random.rand(512,512)*2.0-1
smooth_factor = 2**4
for i in np.arange(0,noiseTexture.shape[0],smooth_factor):
    for j in np.arange(0,noiseTexture.shape[0],smooth_factor):
        noiseTexture[i:i+smooth_factor,j:j+smooth_factor] = noiseTexture[i,j]

If there's a more elegant way, I'd still be interesting of course. :-)

Cheers,

JW

Jonathan Peirce

unread,
Nov 22, 2013, 8:51:00 AM11/22/13
to psychop...@googlegroups.com
Bare in mind that the elements in the texture will be stretched to whatever size you set the stimulus to have. So you could just alter the number of elements in the noiseTexture and keep the stimulus size at some fixed value.

You'd probably want to think though about whether you want interpolation turned on (linear interp) or off (nearest neighbour interp) for your stimulus.

Jon
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/c655391b-1097-4440-8efa-c75363dd9eea%40googlegroups.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.


Jonathan Peirce

unread,
Nov 22, 2013, 8:52:41 AM11/22/13
to psychop...@googlegroups.com
Or bear it in mind if you prefer ;-)

Jan Willem de Gee

unread,
Mar 8, 2014, 3:35:53 PM3/8/14
to psychop...@googlegroups.com
Hello,

In order to generate noise you want to create a code component like this: http://www.psychopy.org/builder/components/code.html#create-a-patch-of-noise

If you want the grating to be on top of it then just make sure it's drawn before the grating and if you want it to overlay the grating do the opposite.

I also require to draw both noise and a grating on top. Right now I do the following:

        # mask:
        radius = filters.makeRadialMatrix(256)
        annulus = np.where(radius<1.0, 1,0)*np.where(radius>0.25, 1,0)*2-1
        
        # noise:
        noiseTexture = sp.random.rand(512,512)*2.0-1
        self.noise = visual.GratingStim(
                self.screen, 
                opacity=1,
                tex=noiseTexture, 
                texRes = 512,
                mask=annulus, 
                size=600, 
                interpolate=True, 
                autoLog=False,
                units='pix',)
        
        # gabor:
        self.gabor = visual.GratingStim(
                self.screen,
                opacity=1,
                tex="sin",
                mask=annulus,
                texRes=512,
                size=600,
                sf=[0.01,0], 
                ori=0, 
                contrast=0, 
                name='gabor1', 
                interpolate=True)
       
        self.noise.draw()
        self.gabor.draw()

However, now I don't see the noise anymore...

Is there a way to draw both without using the opacity parameter?

Thank you!

Jan Willem
Reply all
Reply to author
Forward
0 new messages