spitschan / SilentSubstitutionToolbox

Toolbox to simulate colorimetric observers for evaluation of photoreceptor isolation
Other
7 stars 5 forks source link

Commenting needed: ReceptorIsolateOptimBackgroundMulti #15

Closed DavidBrainard closed 7 years ago

DavidBrainard commented 7 years ago

It is also possible that we should make ReceptporIsolate call through this, as in some sense it is a generalization. But write some good unit tests first.

spitschan commented 7 years ago

Commented in 0e56a15. ~There are bits of the code that I no longer understand, including the non-linear constraint defined in the nonlconstraint function in the bottom part of the code.~ (see below) I will re-write this function from first principles within the next few weeks but hopefully the comments will help you for now.

spitschan commented 7 years ago

Here's a detailed analysis of the function, which I now understand.

(1) Linear constraint. In ReceptorIsolateOptimBackgroundMulti, instead of setting a linear constraint for the receptors which should have zero contrast relative to the background, the contrast-to-be-zeroed is added to the error term. In ReceptorIsolate, this is expressed as a linear equality (all contrasts-to-be-zeroed should be 0). The reason why we have to do this is because while we can calculate the activation of the contrasts-to-be-zeroed outside of the optimization in ReceptorIsolate, this cannot be done in ReceptorIsolateOptimBackgroundMulti because it precisely finds the optimal background simultaneously.

(2) Non-linear constraint. In ReceptorIsolateOptimBackgroundMulti, there is a non-linear constraint which seems the upper and lower bounds for the modulation primaries and background primary. The reason why this is done as a non-linear constraint is that if the background shifts from e.g. a standard 0.5 half-on background, not all positive excursions (which maximize contrast) yield in-gamut negative excursions.

(3) Error function. The heart of ReceptorIsolateOptimBackgroundMulti is how the error function is defined. There are at present three definitions: a) for when the contrasts between receptors are yoked (e.g. LMS, with equal contrast on LMS), b) for when the contrasts are yoked but irregardless of sign (e.g. L-M with 10% on L and -10% on M or so), c) all other cases. Currently, there is the magical number 1000 which scales parts of the error function, and perhaps does so for the cases a-c differently. In any event, when optimizing for multiple modulation directions, the error terms just add up.

DavidBrainard commented 7 years ago

Thanks. I added the below to the header comments.

DB

From: Manuel Spitschan notifications@github.com Reply-To: spitschan/SilentSubstitutionToolbox reply@reply.github.com Date: Monday, August 7, 2017 at 7:55 AM To: spitschan/SilentSubstitutionToolbox SilentSubstitutionToolbox@noreply.github.com Cc: "Brainard, David H" brainard@psych.upenn.edu, Author author@noreply.github.com Subject: Re: [spitschan/SilentSubstitutionToolbox] Commenting needed: ReceptorIsolateOptimBackgroundMulti (#15)

(1) Linear constraint. In ReceptorIsolateOptimBackgroundMulti, instead of setting a linear constraint for the receptors which should have zero contrast relative to the background, the contrast-to-be-zeroed is added to the error term. In ReceptorIsolate, this is expressed as a linear equality (all contrasts-to-be-zeroed should be 0). The reason why we have to do this is because while we can calculate the activation of the contrasts-to-be-zeroed outside of the optimization in ReceptorIsolate, this cannot be done in ReceptorIsolateOptimBackgroundMulti because it precisely finds the optimal background simultaneously.

(2) Non-linear constraint. In ReceptorIsolateOptimBackgroundMulti, there is a non-linear constraint which seems the upper and lower bounds for the modulation primaries and background primary. The reason why this is done as a non-linear constraint is that if the background shifts from e.g. a standard 0.5 half-on background, not all positive excursions (which maximize contrast) yield in-gamut negative excursions.

(3) Error function. The heart of both ReceptorIsolateOptimBackgroundMulti is how the error function is defined. There are at present three definitions: a) for when the contrasts between receptors are yoked (e.g. LMS, with equal contrast on LMS), b) for when the contrasts are yoked but irregardless of sign (e.g. L-M with 10% on L and -10% on M or so), c) all other cases. Currently, there is the magical number 1000 which scales parts of the error function, and perhaps does so for the cases a-c differently. In any event, when optimizing for multiple modulation directions, the sums just add up.