-
Notifications
You must be signed in to change notification settings - Fork 18
Exp server test #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exp server test #203
Changes from all commits
f32a0fe
c3bc046
4b8b28c
0a83b69
4f6ed09
facaef4
aad3a17
2213b18
d48bce2
635aca2
170a9dd
b0b24ca
31641f1
4e07c99
1a0f4c4
879ffc4
1f9af30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -612,14 +612,35 @@ function applyCalibration(obj, cal) | |
| Screen('LoadNormalizedGammaTable', obj.PtbHandle, gammaTable); | ||
| end | ||
|
|
||
| function c = calibration(obj, dev, lightIn, clockIn, clockOut) | ||
| % Creates a calibration file automatically using the light meter | ||
| function c = calibration(obj, dev, lightIn, clockIn, clockOut, makePlot) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how would you feel about something like this? I think having varargin and those optional inputs is clarifying here, and then an args struct could be used to specify default input args in the function body, which I like better than the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fine |
||
| % CALIBRATION Performs a gamma calibration for the screen | ||
| % Requires the user to hold a photodiode, connected to a NI-DAQ, | ||
| % against the screen in order to perform gamma calibration, and | ||
| % returns the results as a struct. | ||
| % | ||
| % Inputs: | ||
| % dev (int) : NI DAQ device ID to which the photodiode is | ||
| % connected | ||
| % lightIn (char) : analogue input channel name to which the | ||
| % photodiode is connected | ||
| % clockIn (char) : analogue input channel name for clocking pulse | ||
| % clockOut (char) : digital output channel name for clocking pulse | ||
| % makePlot (bool) : flag for making photodiode signal plot | ||
| % | ||
| % Output: | ||
| % c (struct) : calibration struct containing refresh rate and | ||
| % gamma tables | ||
| % | ||
| % See also calibrationStruct, applyCalibration | ||
|
|
||
| %first load a default gamma table | ||
| stdGammaTable = repmat(linspace(0, 1 - 1/256, 256)',[1 3]); | ||
| disp('Loading standard gamma table'); | ||
| Screen('LoadNormalizedGammaTable', obj.PtbHandle, stdGammaTable); | ||
|
|
||
| if nargin < 6 | ||
| makePlot = true; | ||
| end | ||
| if nargin < 5 | ||
| clockOut = 'port1/line0'; | ||
| end | ||
|
|
@@ -647,37 +668,37 @@ function applyCalibration(obj, cal) | |
| %% assess the delay between digital and analog | ||
|
|
||
| [xc, lags ] = xcorr(light, clock, 1000, 'coeff'); | ||
| % figure; plot(lags,xc) | ||
| [~,imax] = max(xc); | ||
| ishift = lags(imax); | ||
| delay = 1000*ishift/acqRate; % in ms | ||
| fprintf('Digital is ahead of screen by %2.2f ms\n',delay); | ||
|
|
||
| delayMsg = sprintf('Digital is ahead of screen by %2.2f ms\n', delay); | ||
| fprintf(delayMsg); | ||
|
|
||
| % correct the data | ||
| clock = circshift(clock,[ishift,0]); | ||
|
|
||
| %% plot the data | ||
|
|
||
| ns = length(light); | ||
| tt = (1:ns)/acqRate; | ||
|
|
||
| figure; plot(tt,clock); | ||
| ylabel('clock signal'); title('Clock'); | ||
|
|
||
| upCrossings = find(diff( clock > 1 ) == 1); | ||
| dnCrossings = find(diff( clock > 1 ) == -1); | ||
|
|
||
| figure; clf | ||
| for iC = 1:length(upCrossings) | ||
| plot(tt(upCrossings(iC))*[1 1],[0 5],'-', ... | ||
| 'color', 0.8*[1 1 1] ); hold on | ||
| if makePlot | ||
| ns = length(light); | ||
| tt = (1:ns)/acqRate; | ||
|
|
||
| figure; plot(tt,clock); | ||
| ylabel('clock signal'); title('Clock'); | ||
|
|
||
| upCrossings = find(diff( clock > 1 ) == 1); | ||
| dnCrossings = find(diff( clock > 1 ) == -1); | ||
|
|
||
| figure; clf | ||
| for iC = 1:length(upCrossings) | ||
| plot(tt(upCrossings(iC))*[1 1],[0 5],'-', ... | ||
| 'color', 0.8*[1 1 1] ); hold on | ||
| end | ||
| plot( tt, light ); hold on | ||
| xlabel('Time (s)'); | ||
| ylabel('Photodiode Signal (Volts)'); | ||
| set(gca,'ylim',[0 1.1*max(light)]); | ||
| title(delayMsg); | ||
| end | ||
| plot( tt, light ); hold on | ||
| xlabel('Time (s)'); | ||
| ylabel('Photodiode Signal (Volts)'); | ||
| set(gca,'ylim',[0 1.1*max(light)]); | ||
| title(sprintf('In this plot. digital has been delayed by %2.2f ms', delay)); | ||
|
|
||
| %% interpret the results | ||
|
|
||
| nsteps = length(steps); % length(UpCrossings)/3; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.