justingardner / mgl

A suite of mex/m files for displaying psychophysics stimuli
http://justingardner.net/mgl
Other
18 stars 22 forks source link

No function fixBadChars #10

Closed DavidBrainard closed 9 years ago

DavidBrainard commented 9 years ago

A) The function fixBadChars is called on line 142 of mglSetGammaTable, but I get an error because this function does not exist on my path. The line is:

fieldCheck = fixBadChars(fieldCheck);

B) Commenting out the line allows a warning message to print, although it is a bit garbled:

(mglSetGammaTable) Size of input table (3) does not match hardwware gamma table size (256). Interpolating using nearest neighbors - this should make the gamma table act as expected for an 1.584963e+00 bit display

The code that leads to this warning message runs fine on an older Mac with an older version (mgl64 from the riken SVN site - not sure which version). It may be some latent problem with our calling code that wasn't detected before, but if there is a known change in behavior about what mglSetGammaTable wants as input, it would be great to know.

DavidBrainard commented 9 years ago

The issue with B) is that we are passing a 3 by 256 matrix as the gamma table, but the code on line 71 of mglSetGammaTable that checks to see which orientation the gamma table was passed in only checks to see if the row size is 1 to decide if it should be transposed.

if inputSize == 1 inputTable = inputTable'; inputSize = size(inputTable,1); end

Changing that to

if inputSize == 1 || inputSize == 3 ,,, end

fixes the problem for me.

I don't know if this changed behavior was intentional or crept in. It doesn't look like there are likely to be bad consequences of adding the option for 3, unless it is allowable to pass a partial gamma table, in which case there would be trouble when only 3 entries were passed.

Let me know what you think. I can probably update my calling programs to pass the table in the other orientation, although this will be a bit of a pain.

justingardner commented 9 years ago

I updated the function mglSetGammaTable recently due to a change in the way that MacOS sets gamma tables and must have introduced the problem then. Before MacOS assumed that every gamma table had 256 entries in it (since everything in MacOS is -sadly- 8 bit). Recently that behavior changed so that if you pass in 256 entries to a graphics card that allows a 1024 entry table MacOS interpolates out the values to 1024. This caused us problems since the interpolation did some strange things. So, I added a check there. Anyway, that's just some history.

You should be able to pass tables in either format, I will fix the code to allow this and add the missing functions (which is in mrTools/mrUtilities if you need). I'll try to do that later today as I'm tied up this morning.

BTW, I hope that is the first step for Cupertino to embrace higher color resolution.

DavidBrainard commented 9 years ago

Thanks! No super urgency since I have a local fix that makes my code work for now. I’ll grab the update when it is ready.

Best,

David

On Sep 1, 2015, at 11:38 AM, Justin Gardner notifications@github.com wrote:

I updated the function mglSetGammaTable recently due to a change in the way that MacOS sets gamma tables and must have introduced the problem then. Before MacOS assumed that every gamma table had 256 entries in it (since everything in MacOS is -sadly- 8 bit). Recently that behavior changed so that if you pass in 256 entries to a graphics card that allows a 1024 entry table MacOS interpolates out the values to 1024. This caused us problems since the interpolation did some strange things. So, I added a check there. Anyway, that's just some history.

You should be able to pass tables in either format, I will fix the code to allow this and add the missing functions (which is in mrTools/mrUtilities if you need). I'll try to do that later today as I'm tied up this morning.

BTW, I hope that is the first step for Cupertino to embrace higher color resolution.

— Reply to this email directly or view it on GitHub https://github.com/justingardner/mgl/issues/10#issuecomment-136764201.

justingardner commented 9 years ago

Ok. I fixed and pushed. Let me know if that works for you now...

DavidBrainard commented 9 years ago

On Sep 2, 2015, at 8:37 PM, Justin Gardner notifications@github.com wrote:

Ok. I fixed and pushed. Let me know if that works for you now...

— Reply to this email directly or view it on GitHub https://github.com/justingardner/mgl/issues/10#issuecomment-137282565.

David H. Brainard Professor of Psychology Director, Penn Vision Research Center Director, Institute for Research in Cognitive Science University of Pennsylvania 3401 Walnut Street, Suite 400A (mail address) 3401 Walnut Street, Room 315C (office location) Philadelphia, PA, 19104 Phone: 215-573-7579 Email: brainard@psych.upenn.edu Web: http://color.psych.upenn.edu/brainard

DavidBrainard commented 9 years ago

Yes, thanks. Appears to work perfectly. DB