ott_RW_RPE_curr.m 867 B

12345678910111213141516171819202122232425262728
  1. function [LH, probSpike, V, mean_predictedSpikes, RPE] = ott_RW_RPE_curr(startValues, spikeCounts, rewards, timeLocked)
  2. % firing rate only correlates with current reward; no real learning happens
  3. % reward is 0: mal, 1: suc, 2: water
  4. slope = startValues(1);
  5. intercept = startValues(2);
  6. rho = startValues(3); % how valuable is maltodextrin on a water -> malto -> sucrose scale
  7. water_ind = rewards == 2;
  8. mal_ind = rewards == 0;
  9. rewards(water_ind) = 0;
  10. rewards(mal_ind) = rho; % scale mal between 0 and 1
  11. rateParam = exp(slope*rewards + intercept);
  12. probSpike = poisspdf(spikeCounts, rateParam(timeLocked)); % mask rateParam to exclude trials where the animal didn't lick fast enough
  13. mean_predictedSpikes = rateParam(timeLocked);
  14. if any(isinf(log(probSpike)))
  15. LH = 1e9;
  16. else
  17. LH = -1 * sum(log(probSpike));
  18. end
  19. V = NaN;
  20. RPE = NaN;