Skip to content

Commit

Permalink
Add contrastPreMultiplicator for gabor patches
Browse files Browse the repository at this point in the history
  • Loading branch information
kurokida committed Jan 7, 2022
1 parent 62554c5 commit 8a873fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/_pages/objectProperties.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ See also [Presenting gabor patches in online/web experiments](/gabor/).
|drift|numeric|0| The velocity of the drifting gabor patch. The angular velocity per frame. The unit is the degree.|
|method|text|numeric| The method of drawing the gabor patch. 'numeric' or 'math' [The numeric.js](https://github.com/sloisel/numeric) is considerably faster than [the math.js](https://mathjs.org/).|
|disableNorm|boolean|false| Disable normalization of the gaussian function. That is, coefficient: 1/(sqrt(2*pi) * sc) will not be multiplied. If this property is specified as true, the contrast value should be relatively small.|
|contrastPreMultiplicator|numeric|1| This value is multiplied as a scaling factor to the requested contrast value. For the meaning of this variable, see [CreateProceduralGabor](http://psychtoolbox.org/docs/CreateProceduralGabor).|

# obj_type: 'manual'

Expand Down
10 changes: 8 additions & 2 deletions jspsych-psychophysics.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@
default: 20,
description: 'The contrast of the gabor patch.'
},
contrastPreMultiplicator: {
type: jspsych.ParameterType.FLOAT,
pretty_name: 'contrastPreMultiplicator',
default: 1,
description: 'A scaling factor'
},
drift: {
type: jspsych.ParameterType.FLOAT,
pretty_name: 'drift',
Expand Down Expand Up @@ -755,7 +761,7 @@
const exp_value = math.exp(tmp2)
const tmp3 = math.dotMultiply(exp_value, sinWave)
const tmp4 = math.multiply(multConst, tmp3)
const tmp5 = math.multiply(this.contrast, tmp4)
const tmp5 = math.multiply(this.contrast, math.multiply(tmp4, this.contrastPreMultiplicator))
const m = math.multiply(256, math.add(0.5, tmp5))
gabor_data = m._data
} else { // numeric
Expand All @@ -770,7 +776,7 @@
const exp_value = numeric.exp(tmp2)
const tmp3 = numeric.mul(exp_value, sinWave)
const tmp4 = numeric.mul(multConst, tmp3)
const tmp5 = numeric.mul(this.contrast, tmp4)
const tmp5 = numeric.mul(this.contrast, numeric.mul(tmp4, this.contrastPreMultiplicator))
const m = numeric.mul(256, numeric.add(0.5, tmp5))
gabor_data = m
}
Expand Down

0 comments on commit 8a873fc

Please sign in to comment.