Skip to content

Commit

Permalink
BF: Fixes filtered noise issue
Browse files Browse the repository at this point in the history
Fixes tounding error in noise.py which was slightly altering the spatial frequency composition of Butterworth filtered noise and 'filtered' noise samples and doing so differenly for PY2 and PY3.
  • Loading branch information
schofiaj committed May 13, 2019
1 parent b669eab commit 5d0e360
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions psychopy/visual/noise.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# up by the pyglet GL engine and have no effect. # up by the pyglet GL engine and have no effect.
# Shaders will work but require OpenGL2.0 drivers AND PyOpenGL3.0+ # Shaders will work but require OpenGL2.0 drivers AND PyOpenGL3.0+


from __future__ import absolute_import, print_function from __future__ import absolute_import, print_function, division


import pyglet import pyglet
pyglet.options['debug_gl'] = False pyglet.options['debug_gl'] = False
Expand Down Expand Up @@ -495,8 +495,8 @@ def _filter(self, FT):
cutoff_y = self._upsf / filterSize, cutoff_y = self._upsf / filterSize,
n=self.noiseFilterOrder, n=self.noiseFilterOrder,
alpha=0, alpha=0,
offset_x = 2 / (filterSize-1), offset_x = 0.5/filterSize, #becuase FFTs are slightly off centred.
offset_y = 2 / (filterSize-1)) offset_y = 0.5/filterSize)
else: else:
filter = numpy.ones((int(filterSize),int(filterSize))) filter = numpy.ones((int(filterSize),int(filterSize)))
if self._lowsf > 0: if self._lowsf > 0:
Expand All @@ -509,8 +509,8 @@ def _filter(self, FT):
cutoff_y = self._lowsf / filterSize, cutoff_y = self._lowsf / filterSize,
n = self.noiseFilterOrder, n = self.noiseFilterOrder,
alpha = 0, alpha = 0,
offset_x = 2/(filterSize - 1), offset_x = 0.5/filterSize, #becuase FFTs are slightly off centred.
offset_y = 2/(filterSize - 1)) offset_y = 0.5/filterSize)
return FT * filter return FT * filter
else: else:
return FT return FT
Expand Down Expand Up @@ -691,7 +691,7 @@ def buildNoise(self):
if not(self.noiseType in ['binary','Binary','normal','Normal','uniform','Uniform']): if not(self.noiseType in ['binary','Binary','normal','Normal','uniform','Uniform']):
if (self.noiseType in ['filtered','Filtered']) or (self.filter in ['butterworth', 'Butterworth']): if (self.noiseType in ['filtered','Filtered']) or (self.filter in ['butterworth', 'Butterworth']):
self.noiseTex=self._filter(self.noiseTex) self.noiseTex=self._filter(self.noiseTex)
elif (self.noiseType in ['Isotropic','isotropic']) or (self.filter in ['isotropic', 'Isopropic']): elif (self.noiseType in ['Isotropic','isotropic']) or (self.filter in ['isotropic', 'Isotropic']):
self.noiseTex = self._isotropic(self.noiseTex) self.noiseTex = self._isotropic(self.noiseTex)
elif (self.noiseType in ['Gabor','gabor']) or (self.filter in ['gabor', 'Gabor']): elif (self.noiseType in ['Gabor','gabor']) or (self.filter in ['gabor', 'Gabor']):
self.noiseTex = self._gabor(self.noiseTex) self.noiseTex = self._gabor(self.noiseTex)
Expand Down

0 comments on commit 5d0e360

Please sign in to comment.