# Reading the Gamma file

**URL:** <https://psychtoolbox.discourse.group/t/reading-the-gamma-file/1250>\
**Category:** Uncategorized\
**Created:** [March 26, 2003, 12:50pm UTC](https://psychtoolbox.discourse.group/t/reading-the-gamma-file/1250 "2003-03-26T12:50:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranibaron](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ranibaron](https://psychtoolbox.discourse.group/u/ranibaron)\
**Post date:** [March 26, 2003, 12:50pm UTC](https://psychtoolbox.discourse.group/t/reading-the-gamma-file/1250/1 "2003-03-26T12:50:42Z")

</div>

Hi all,  
  
I can't seem to understand how to use the gamma correction file I create with the VisualGammaDemo (am I wrong to use this file?).  
Moreover, the VisualGammaDemo should be configured from a distance of 3.2 meters while my experiment room has only about a 1.5 meters   
from the monitor. I have to test the gamma in the same room I do the experiment.  
  
Thanks in advance,  
  
Rani Bar-On  
IIPDM  
University of Haifa  
[http://iipdm.haifa.ac.il](http://iipdm.haifa.ac.il)

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [March 26, 2003, 11:33pm UTC](https://psychtoolbox.discourse.group/t/reading-the-gamma-file/1250/2 "2003-03-26T23:33:15Z")

</div>

I am using PsychSerial to read eye position data from an ASL eyetracker.   
I am not certain that PsychSerial is functioning properly, but I may also   
be doing something wrong, or using the wrong settings.  
  
The ASL box sends 8 bytes of data in response to a single byte I send to   
it. Here is an example. According to the serial buffer log I can view   
with the software that came with my serial-to-USB converter, the ASL box   
sent the following 8 bytes (in hex): 00 00 28 00 01 38 07 a3.  
  
To read the bytes with PsychSerial, I do:  
  
tmp=double(PsychSerial('Read',port));  
  
In this case, I get tmp = 0,0,40,0,1,56,7,65443  
  
Everything is fine except for the last "byte". 65443 corresponds to   
ffa3, so somehow PsychSerial seems to have merged another byte onto the   
last byte. And in fact this occurs for any byte in the stream greater   
than or equal to 128. That is, if the most significant bit of the byte   
is 1, then PsychSerial reports the byte as a 16-bit byte with the first 8   
bits set to 1.  
  
Does PsychSerial assume that this is a signed byte or something? It is   
not a problem with Matlab's conversion to double, because this extra ff   
is also present in the char data.  
  
The fix is easy, all I have to do is tmp=bitand(255,tmp), but I am   
wondering why this is necessary.  
  
Also, PsychSerial does not seem to be appending an additional null, as   
mentioned in the documentation. The ASL box sends 8 bytes, and   
PsychSerial reports 8 bytes.  
  
I am using the (apparently latest) version of PsychSerial that is   
included with the PTB 2.52 release.  
  
Thanks for any help,  
  
keith

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [April 4, 2003, 3:55pm UTC](https://psychtoolbox.discourse.group/t/reading-the-gamma-file/1250/3 "2003-04-04T15:55:47Z")

</div>

I have been considering writing Matlab functions to read form and control  
and ASL eyetracker and so I was interested to see your query. Did you get  
any responses or resolve your problem in some other way?  
  
Ted Wright  
==============================================================================  
| Charles E. (Ted) Wright: Associate Professor & Chair, Cognitive Sciences |  
| |  
| Office: Room 3219 USMail: Dept. of Cognitive Sciences |  
| Social Science Plaza Social Sciences Plaza, Rm. 3151 |  
| (949) 824-7589 UC-Irvine |  
| Fax: (949) 856-2307 Irvine, CA 92697-5100 |  
| email: [cewright@...](mailto:cewright@...) web: www.socsi.uci.edu/cogsci |  
==============================================================================  
  

> On Wed, 26 Mar 2003, Keith Schneider wrote:  
>    
> \> I am using PsychSerial to read eye position data from an ASL eyetracker.  
> \> I am not certain that PsychSerial is functioning properly, but I may also  
> \> be doing something wrong, or using the wrong settings.  
> \>  
> \> The ASL box sends 8 bytes of data in response to a single byte I send to  
> \> it. Here is an example. According to the serial buffer log I can view  
> \> with the software that came with my serial-to-USB converter, the ASL box  
> \> sent the following 8 bytes (in hex): 00 00 28 00 01 38 07 a3.  
> \>  
> \> To read the bytes with PsychSerial, I do:  
> \>  
> \> tmp=double(PsychSerial('Read',port));  
> \>  
> \> In this case, I get tmp = 0,0,40,0,1,56,7,65443  
> \>  
> \> Everything is fine except for the last "byte". 65443 corresponds to  
> \> ffa3, so somehow PsychSerial seems to have merged another byte onto the  
> \> last byte. And in fact this occurs for any byte in the stream greater  
> \> than or equal to 128. That is, if the most significant bit of the byte  
> \> is 1, then PsychSerial reports the byte as a 16-bit byte with the first 8  
> \> bits set to 1.  
> \>  
> \> Does PsychSerial assume that this is a signed byte or something? It is  
> \> not a problem with Matlab's conversion to double, because this extra ff  
> \> is also present in the char data.  
> \>  
> \> The fix is easy, all I have to do is tmp=bitand(255,tmp), but I am  
> \> wondering why this is necessary.  
> \>  
> \> Also, PsychSerial does not seem to be appending an additional null, as  
> \> mentioned in the documentation. The ASL box sends 8 bytes, and  
> \> PsychSerial reports 8 bytes.  
> \>  
> \> I am using the (apparently latest) version of PsychSerial that is  
> \> included with the PTB 2.52 release.  
> \>  
> \> Thanks for any help,  
> \>  
> \> keith  
> \>  
> \>  
> \> [http://psychtoolbox.org](http://psychtoolbox.org)  
> \> POST a message to: [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com)  
> \> UNSUBSCRIBE by sending a blank message to:  
> \> [psychtoolbox-unsubscribe@yahoogroups.com](mailto:psychtoolbox-unsubscribe@yahoogroups.com)  
> \>  
> \> Your use of Yahoo! Groups is subject to [http://docs.yahoo.com/info/terms/](http://docs.yahoo.com/info/terms/)  
> \>  
> \>

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [April 4, 2003, 5:39pm UTC](https://psychtoolbox.discourse.group/t/reading-the-gamma-file/1250/4 "2003-04-04T17:39:35Z")

</div>

On Fri, 4 Apr 2003, Charles E. (Ted) Wright wrote:  
  

> \> I have been considering writing Matlab functions to read form and control  
> \> and ASL eyetracker and so I was interested to see your query. Did you get  
> \> any responses or resolve your problem in some other way?

Hi, no responses. I don't know why PsychSerial adds those extra bits.   
But, the solution of bitand(255,output) strips them and seems to work.  
  
I'm getting some strange output from the ASL box and I need to talk to   
one of their engineers. Once I have things ironed out I will post some code.  
  
keith
