From 8a873fcd504a3e3554bcf640221597d4941c7684 Mon Sep 17 00:00:00 2001 From: Daiichiro Kuroki <32691644+kurokida@users.noreply.github.com> Date: Sat, 8 Jan 2022 08:40:31 +0900 Subject: [PATCH] Add contrastPreMultiplicator for gabor patches --- docs/_pages/objectProperties.md | 1 + jspsych-psychophysics.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/_pages/objectProperties.md b/docs/_pages/objectProperties.md index d7d24c7..7c6eaa7 100644 --- a/docs/_pages/objectProperties.md +++ b/docs/_pages/objectProperties.md @@ -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' diff --git a/jspsych-psychophysics.js b/jspsych-psychophysics.js index 05640aa..f1fd4f2 100755 --- a/jspsych-psychophysics.js +++ b/jspsych-psychophysics.js @@ -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', @@ -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 @@ -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 }