Skip to content
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

added option to display calibration plot within expServer #245

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
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
42 changes: 40 additions & 2 deletions +srv/expServer.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function expServer(useTimelineOverride, bgColour)
rewardToggleKey = KbName('w');
rewardPulseKey = KbName('space');
rewardCalibrationKey = KbName('m');
viewCalibrationKey = KbName('k');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about changing this to a 'v' and including the gamma calibrations in the display?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems reasonable to me! I think the water calibration is the thing the techs look at the most, but making more information more accessible seems like a good thing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I'll change it to 'v' and make an issue about adding other plots in the future.

gammaCalibrationKey = KbName('g');
timelineToggleKey = KbName('t');
toggleBackground = KbName('b');
Expand Down Expand Up @@ -119,6 +120,7 @@ function expServer(useTimelineOverride, bgColour)
end

running = true;
calibration_displayed = false;

%% Main loop for service
while running
Expand Down Expand Up @@ -162,8 +164,21 @@ function expServer(useTimelineOverride, bgColour)

% check for reward calibration
if firstPress(rewardCalibrationKey) > 0
log('Performing a reward delivery calibration');
calibrateWaterDelivery();
log('Performing a reward delivery calibration');
calibrateWaterDelivery();
end

% check for view calibration
if firstPress(viewCalibrationKey) > 0
if ~calibration_displayed
log('Displaying calibration');
viewCalibration();
calibration_displayed = true;
else
log('Un-displaying calibration');
Screen('Flip', rig.stimWindow.PtbHandle);
calibration_displayed = false;
end
end

% check for gamma calibration
Expand Down Expand Up @@ -345,6 +360,29 @@ function calibrateWaterDelivery()
save(rigHwFile, 'daqController', '-append');
end

function viewCalibration()

k1o0 marked this conversation as resolved.
Show resolved Hide resolved
calib = rig.daqController.SignalGenerators(rewardId).Calibrations(end);
k1o0 marked this conversation as resolved.
Show resolved Hide resolved

fig = figure; hold on
plot([calib.measuredDeliveries.durationSecs],...
[calib.measuredDeliveries.volumeMicroLitres],'x-')
if isfield(calib, 'dateTime')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a case where dateTime isn't a field? It's assumed to be there in other parts of the code...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was coming up for me, but I think it's an issue that's specific to some things I had done on my branch that re fixed now. I think in dev it's safe to assume dateTime will always be there if a calibration in.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I removed the if statement because on master there would be an error thrown beforehand, here:

Rigbox/+hw/devices.m

Lines 54 to 57 in 7d6b601

if isprop(sg,'Calibrations')
[newestDate, ~] = max([sg.Calibrations.dateTime]);
fprintf('\nApplying reward calibration performed on %s\n', datestr(newestDate));
end

title(datestr(calib.dateTime))
end

xlabel('Duration (sec)'); ylabel('Volume (uL)')
ylim([0, 5])
set(gca, 'fontsize', 16)

plot_values = getframe(fig);
imageDisplay = Screen('MakeTexture', rig.stimWindow.PtbHandle, plot_values.cdata);
Screen('DrawTexture', rig.stimWindow.PtbHandle, imageDisplay);
Screen('Flip', rig.stimWindow.PtbHandle);
WaitSecs(0.5);
k1o0 marked this conversation as resolved.
Show resolved Hide resolved

end

function whiteScreen()
% WHITESCREEN Changes screen background to white
rig.stimWindow.BackgroundColour = rig.stimWindow.White;
Expand Down