Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion +hw/+ptb/Window.m
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ function applyCalibration(obj, cal)
[light, clock, acqRate] = obj.measuredStim(colours, dev, lightIn, clockIn, clockOut);

%% assess the delay between digital and analog

[xc, lags ] = xcorr(light, clock, 1000, 'coeff');
% figure; plot(lags,xc)
[~,imax] = max(xc);
Expand All @@ -661,6 +662,7 @@ function applyCalibration(obj, cal)
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);
Expand All @@ -672,7 +674,7 @@ function applyCalibration(obj, cal)
end
plot( tt, light ); hold on
xlabel('Time (s)');
ylabel('Signal (Volts)');
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));

Expand Down
13 changes: 7 additions & 6 deletions +srv/expServer.m
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,14 @@ function whiteScreen()
function calibrateGamma()
stimWindow = rig.stimWindow;
DaqDev = rig.daqController.DaqIds;
lightIn = 'ai0'; % defaults from hw.ptb.Window
clockIn = 'ai1';
clockOut = 'port1/line0 (PFI4)';
log(['Please connect photodiode to %s, clockIn to %s and clockOut to %s.\r'...
'Press any key to contiue\n'],lightIn,clockIn,clockOut);
lightIn = 'ai1'; % defaults from hw.ptb.Window
clockIn = 'ai0';
clockOut = 'port1/line0';
clockOutHint = 'PFI4';
log(['Please connect photodiode to %s, clockIn to %s and clockOut to %s (%s).\r'...
'Press any key to contiue\n'],lightIn,clockIn,clockOut,clockOutHint);
pause; % wait for keypress
stimWindow.Calibration = stimWindow.calibration(DaqDev); % calibration
stimWindow.Calibration = stimWindow.calibration(DaqDev,lightIn, clockIn, clockOut); % calibration
pause(1);
saveGamma(stimWindow.Calibration);
stimWindow.applyCalibration(stimWindow.Calibration);
Expand Down