Skip to content
Permalink
Browse files

BF: Fixes filtered noise issue

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 5d0e360d87b0d96436a2ff374c3ad5eee0a15b98
Showing with 6 additions and 6 deletions.
  1. +6 −6 psychopy/visual/noise.py
@@ -16,7 +16,7 @@
# up by the pyglet GL engine and have no effect.
# 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
pyglet.options['debug_gl'] = False
@@ -495,8 +495,8 @@ def _filter(self, FT):
cutoff_y = self._upsf / filterSize,
n=self.noiseFilterOrder,
alpha=0,
offset_x = 2 / (filterSize-1),
offset_y = 2 / (filterSize-1))
offset_x = 0.5/filterSize, #becuase FFTs are slightly off centred.
offset_y = 0.5/filterSize)
else:
filter = numpy.ones((int(filterSize),int(filterSize)))
if self._lowsf > 0:
@@ -509,8 +509,8 @@ def _filter(self, FT):
cutoff_y = self._lowsf / filterSize,
n = self.noiseFilterOrder,
alpha = 0,
offset_x = 2/(filterSize - 1),
offset_y = 2/(filterSize - 1))
offset_x = 0.5/filterSize, #becuase FFTs are slightly off centred.
offset_y = 0.5/filterSize)
return FT * filter
else:
return FT
@@ -691,7 +691,7 @@ def buildNoise(self):
if not(self.noiseType in ['binary','Binary','normal','Normal','uniform','Uniform']):
if (self.noiseType in ['filtered','Filtered']) or (self.filter in ['butterworth', 'Butterworth']):
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)
elif (self.noiseType in ['Gabor','gabor']) or (self.filter in ['gabor', 'Gabor']):
self.noiseTex = self._gabor(self.noiseTex)

0 comments on commit 5d0e360

Please sign in to comment.
You can’t perform that action at this time.