# Display Undistortion : problems loading config file

**URL:** <https://psychtoolbox.discourse.group/t/display-undistortion-problems-loading-config-file/1773>\
**Category:** Uncategorized\
**Created:** [December 17, 2011, 5:30pm UTC](https://psychtoolbox.discourse.group/t/display-undistortion-problems-loading-config-file/1773 "2011-12-17T17:30:39Z")\
**Posts on this page:** 2\
**Page:** 1

<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:** [December 17, 2011, 5:30pm UTC](https://psychtoolbox.discourse.group/t/display-undistortion-problems-loading-config-file/1773/1 "2011-12-17T17:30:39Z")

</div>

Hi everyone  
  
I use the Psychtoolbox to display some stimuli with a projector, on a curbed screen.  
  
I need correct the (multiple) distortion of the image. I used "DisplayUndistortionBVL" to generate the "undistortion config file". The file generation is ok.  
  
Now.. I load the file as indicated, but when I draw sometings, the distortion is not corrected (I have no changes! I have no error notification)  
  
Could someone help me, please ..?  
  
Thanks in advance  
  
- - -  
  
Here the code:  
  
%% Screen dimension  
ScreenXpix = 1024 ;  
ScreenYpix = 768 ;  
centroschermo = [(ScreenXpix/2) (ScreenYpix/2)] ;  
%% --------------- PARAMETERS and initialization ----------------%  
flipSpdwindow = 0;  
whichScreen = 1; % working window ----------   
rcD = 1; % duration of the Red Cross Fixation presentation [sec]   
data = [];  
%% --------------------- COLORS -------------------------%  
white = [255 255 255];   
gray = [128 128 128];  
Dgray = [54 54 54];  
black = [0 0 0];  
blue = [100 100 250];  
red = [200 50 50];  
green = [21 152 18];   
%% --------------------- Open Working Window ---------------------%  
% on line window  
rec = Screen('Rect',whichScreen); % Screen selection  
  
[W, H]=Screen('WindowSize', whichScreen);   
  
%%% [window, rect] = Screen('OpenWindow', whichScreen, black, rec);   
  
PsychImaging('PrepareConfiguration');  
  
PsychImaging('AddTask', 'AllView', 'GeometryCorrection', 'C:\Documents and Settings\acarlini\Application Data\Psychtoolbox\GeometryCalibration\BVLCalibdata\_1\_1280\_1024.mat', 0, 73 , 53) ;  
  
[window , rect] = PsychImaging('OpenWindow', whichScreen, black, rec);  
  
monitorFlipInterval = Screen('GetFlipInterval', window);   
  
% Screen center  
centroschermo = (rec (3:4) ) /2 ;  
  
  
%% Draws Window corners - to test the correction  
% Up Left  
Screen('FillRect',window, blue , [0 , 0 , 50 , 50] ) ;  
Screen('FillRect',window, black , [10 , 10 , 50 , 50] ) ;  
% Up Right  
Screen('FillRect',window, blue , [rect(3)-50 , 0 , rect(3) , 50] ) ;  
Screen('FillRect',window, black , [rect(3)-50 , 10 , rect(3)-10 , 50] ) ;  
% Down Left  
Screen('FillRect',window, blue , [0 , rect(4)-50 , 50 , rect(4)] ) ;  
Screen('FillRect',window, black , [10 , rect(4)-50 , 50 , rect(4)-10] ) ;  
% Down Right  
Screen('FillRect',window, blue , [rect(3)-50 , rect(4)-50 , rect(3) , rect(4)] ) ;  
Screen('FillRect',window, black , [rect(3)-50 , rect(4)-50 , rect(3)-10 , rect(4)-10] ) ;  
% Up   
Screen('FillRect',window, blue , [(round(rect(3)/2)-25) , 0 , (round(rect(3)/2)+25) , 10] ) ;  
Screen('FillRect',window, white , [(round(rect(3)/2)-2) , 0 , (round(rect(3)/2)+2) , 10] ) ;  
% Down  
Screen('FillRect',window, blue , [(round(rect(3)/2)-25) , rect(4)-10 , (round(rect(3)/2)+25) , rect(4)] ) ;  
Screen('FillRect',window, white , [(round(rect(3)/2)-2) , rect(4)-10 , (round(rect(3)/2)+2) , rect(4)] ) ;  
% Left  
Screen('FillRect',window, blue , [0 , (round(rect(4)/2)-25) , 10 , (round(rect(4)/2)+25)] ) ;  
% Right  
Screen('FillRect',window, blue , [rect(3)-10 , (round(rect(4)/2)-25) , rect(3) , (round(rect(4)/2)+25)] ) ;  
% Center  
dim\_cross = 8 ; % Cross dimension, in pixel  
spex\_cross = 3 ; % Cross'line dimension, in pixel  
Screen('DrawLine', window , red , centroschermo(1) - dim\_cross , centroschermo(2) - dim\_cross , centroschermo(1) + dim\_cross , centroschermo(2) + dim\_cross , spex\_cross ) ;  
Screen('DrawLine', window , red , centroschermo(1) + dim\_cross , centroschermo(2) - dim\_cross , centroschermo(1) - dim\_cross , centroschermo(2) + dim\_cross , spex\_cross ) ;  
  
Screen('Flip', window);  
  
%% Mouse clilck  
 pmb = 0 ;  
 while pmb == 0  
 [Xmouse,Ymouse,buttons] = GetMouse() ;  
 if any(buttons)  
 fprintf('Someone''s pressing a mouse button!\n');  
 MouseClick = [clock,buttons,Xmouse,Ymouse] ;  
 pmb = 1 ;  
 end  
 end  
  
%% -------------- Close PSICHTOOLBOX Working Window ----------%  
  
 Screen('CloseAll');

---

<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:** [December 19, 2011, 11:59am UTC](https://psychtoolbox.discourse.group/t/display-undistortion-problems-loading-config-file/1773/2 "2011-12-19T11:59:21Z")

</div>

Thank you for the solution, now it is working !  
  
Now I have a good display but I find a miscorrelation between the "corrected" display and the mouse click (when I get the click position with GetMouse() or GetClicks() ).  
  
I have the impression that the mouse click follows the original grid, not the corrected-one.  
  
Do you know if it is available a function or a system to solve this problem ?   
  
Thanks in advance !  
  
  
---------------------------------------------------------------  
  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Mario" \<mario.kleiner@...\> wrote:  
> \>  
> \> Simple:  
> \>   
> \> PsychImaging('AddTask', 'AllView', 'GeometryCorrection', 'C:\Documents and  
> \> Settings\acarlini\Application  
> \> Data\Psychtoolbox\GeometryCalibration\BVLCalibdata\_1\_1280\_1024.mat', 0, 73 , 53)  
> \> ;  
> \>   
> \> --\> 'AllViews', not 'AllView'. The parser silently ignores that 'AddTask' statement with unknown keyword.  
> \>   
> \> Btw. \<[http://docs.psychtoolbox.org/GetClicks](http://docs.psychtoolbox.org/GetClicks)\> may come handy for waiting for mouse clicks.  
> \>   
> \> -mario  
> \>   
> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "c\_drago" \<alex\_carlini@\> wrote:  
> \> \>  
> \> \> Hi everyone  
> \> \>   
> \> \> I use the Psychtoolbox to display some stimuli with a projector, on a curbed screen.  
> \> \>   
> \> \> I need correct the (multiple) distortion of the image. I used "DisplayUndistortionBVL" to generate the "undistortion config file". The file generation is ok.  
> \> \>   
> \> \> Now.. I load the file as indicated, but when I draw sometings, the distortion is not corrected (I have no changes! I have no error notification)  
> \> \>   
> \> \> Could someone help me, please ..?  
> \> \>   
> \> \> Thanks in advance  
> \> \>   
> \> \> - - -  
> \> \>   
> \> \> Here the code:  
> \> \>   
> \> \> %% Screen dimension  
> \> \> ScreenXpix = 1024 ;  
> \> \> ScreenYpix = 768 ;  
> \> \> centroschermo = [(ScreenXpix/2) (ScreenYpix/2)] ;  
> \> \> %% --------------- PARAMETERS and initialization ----------------%  
> \> \> flipSpdwindow = 0;  
> \> \> whichScreen = 1; % working window ----------   
> \> \> rcD = 1; % duration of the Red Cross Fixation presentation [sec]   
> \> \> data = [];  
> \> \> %% --------------------- COLORS -------------------------%  
> \> \> white = [255 255 255];   
> \> \> gray = [128 128 128];  
> \> \> Dgray = [54 54 54];  
> \> \> black = [0 0 0];  
> \> \> blue = [100 100 250];  
> \> \> red = [200 50 50];  
> \> \> green = [21 152 18];   
> \> \> %% --------------------- Open Working Window ---------------------%  
> \> \> % on line window  
> \> \> rec = Screen('Rect',whichScreen); % Screen selection  
> \> \>   
> \> \> [W, H]=Screen('WindowSize', whichScreen);   
> \> \>   
> \> \> %%% [window, rect] = Screen('OpenWindow', whichScreen, black, rec);   
> \> \>   
> \> \> PsychImaging('PrepareConfiguration');  
> \> \>   
> \> \> PsychImaging('AddTask', 'AllView', 'GeometryCorrection', 'C:\Documents and Settings\acarlini\Application Data\Psychtoolbox\GeometryCalibration\BVLCalibdata\_1\_1280\_1024.mat', 0, 73 , 53) ;  
> \> \>   
> \> \> [window , rect] = PsychImaging('OpenWindow', whichScreen, black, rec);  
> \> \>   
> \> \> monitorFlipInterval = Screen('GetFlipInterval', window);   
> \> \>   
> \> \> % Screen center  
> \> \> centroschermo = (rec (3:4) ) /2 ;  
> \> \>   
> \> \>   
> \> \> %% Draws Window corners - to test the correction  
> \> \> % Up Left  
> \> \> Screen('FillRect',window, blue , [0 , 0 , 50 , 50] ) ;  
> \> \> Screen('FillRect',window, black , [10 , 10 , 50 , 50] ) ;  
> \> \> % Up Right  
> \> \> Screen('FillRect',window, blue , [rect(3)-50 , 0 , rect(3) , 50] ) ;  
> \> \> Screen('FillRect',window, black , [rect(3)-50 , 10 , rect(3)-10 , 50] ) ;  
> \> \> % Down Left  
> \> \> Screen('FillRect',window, blue , [0 , rect(4)-50 , 50 , rect(4)] ) ;  
> \> \> Screen('FillRect',window, black , [10 , rect(4)-50 , 50 , rect(4)-10] ) ;  
> \> \> % Down Right  
> \> \> Screen('FillRect',window, blue , [rect(3)-50 , rect(4)-50 , rect(3) , rect(4)] ) ;  
> \> \> Screen('FillRect',window, black , [rect(3)-50 , rect(4)-50 , rect(3)-10 , rect(4)-10] ) ;  
> \> \> % Up   
> \> \> Screen('FillRect',window, blue , [(round(rect(3)/2)-25) , 0 , (round(rect(3)/2)+25) , 10] ) ;  
> \> \> Screen('FillRect',window, white , [(round(rect(3)/2)-2) , 0 , (round(rect(3)/2)+2) , 10] ) ;  
> \> \> % Down  
> \> \> Screen('FillRect',window, blue , [(round(rect(3)/2)-25) , rect(4)-10 , (round(rect(3)/2)+25) , rect(4)] ) ;  
> \> \> Screen('FillRect',window, white , [(round(rect(3)/2)-2) , rect(4)-10 , (round(rect(3)/2)+2) , rect(4)] ) ;  
> \> \> % Left  
> \> \> Screen('FillRect',window, blue , [0 , (round(rect(4)/2)-25) , 10 , (round(rect(4)/2)+25)] ) ;  
> \> \> % Right  
> \> \> Screen('FillRect',window, blue , [rect(3)-10 , (round(rect(4)/2)-25) , rect(3) , (round(rect(4)/2)+25)] ) ;  
> \> \> % Center  
> \> \> dim\_cross = 8 ; % Cross dimension, in pixel  
> \> \> spex\_cross = 3 ; % Cross'line dimension, in pixel  
> \> \> Screen('DrawLine', window , red , centroschermo(1) - dim\_cross , centroschermo(2) - dim\_cross , centroschermo(1) + dim\_cross , centroschermo(2) + dim\_cross , spex\_cross ) ;  
> \> \> Screen('DrawLine', window , red , centroschermo(1) + dim\_cross , centroschermo(2) - dim\_cross , centroschermo(1) - dim\_cross , centroschermo(2) + dim\_cross , spex\_cross ) ;  
> \> \>   
> \> \> Screen('Flip', window);  
> \> \>   
> \> \> %% Mouse clilck  
> \> \> pmb = 0 ;  
> \> \> while pmb == 0  
> \> \> [Xmouse,Ymouse,buttons] = GetMouse() ;  
> \> \> if any(buttons)  
> \> \> fprintf('Someone''s pressing a mouse button!\n');  
> \> \> MouseClick = [clock,buttons,Xmouse,Ymouse] ;  
> \> \> pmb = 1 ;  
> \> \> end  
> \> \> end  
> \> \>   
> \> \> %% -------------- Close PSICHTOOLBOX Working Window ----------%  
> \> \>   
> \> \> Screen('CloseAll');  
> \> \>  
> \>
