plot_LLHperTrial.m 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. clear; clc
  2. load(fullfile(ottBari2020_root, 'Data', 'Modeling', 'ModelFits', 'intBlocks_MLEfits.mat'));
  3. int_task = [os.Blocks] == 0;
  4. os = os(int_task);
  5. VP_mask = contains({os.Region}, 'VP');
  6. os = os(VP_mask); % only VP neurons
  7. % get relevant behavior models
  8. modelCriterion = 'AIC';
  9. plotFlag = false;
  10. models_of_interest_RPE = {'base','curr','mean'};
  11. models_of_interest_V = {'base','mean'};
  12. timePeriod = 'RD';
  13. bm_RD = select_RPEmods(os, timePeriod,'scoreToUse',modelCriterion,...
  14. 'plotModels_Flag',plotFlag,...
  15. 'particularModel',models_of_interest_RPE);
  16. timePeriod = 'cue';
  17. bm_cue = select_RPEmods(os, timePeriod,'scoreToUse',modelCriterion,...
  18. 'plotModels_Flag',plotFlag,...
  19. 'particularModel',models_of_interest_V);
  20. %% likelihood per trial
  21. timePeriod = 'RD'; % RD, cue
  22. LH = struct();
  23. switch timePeriod
  24. case 'RD'
  25. mods = {'base','curr','mean'};
  26. bm = bm_RD;
  27. mOfInt = 'mod_RD';
  28. case 'cue'
  29. mods = {'base','mean'};
  30. bm = bm_cue;
  31. mOfInt = 'mod_cue';
  32. end
  33. % generate a blank LH structure
  34. for m1 = mods
  35. m1 = m1{:};
  36. for m2 = mods
  37. m2 = m2{:};
  38. LH.(m1).(m2) = [];
  39. end
  40. end
  41. % add for each neuron
  42. LH_cutoff = 10;
  43. for n = 1:length(os)
  44. nTrials = numel(os(n).spikeCount_RD);
  45. for m1 = mods
  46. m1 = m1{:};
  47. if bm.(['mask_' m1])(n) == 1 % if this is a neuron of interest
  48. for m2 = mods
  49. m2 = m2{:};
  50. tmp_LH = -os(n).(mOfInt).(m2).LH/nTrials;
  51. if tmp_LH < LH_cutoff
  52. LH.(m1).(m2) = [LH.(m1).(m2) tmp_LH];
  53. else
  54. LH.(m1).(m2) = [LH.(m1).(m2) NaN];
  55. end
  56. end
  57. end
  58. end
  59. end
  60. % fix names
  61. mods_forLabel = mods;
  62. mods_forLabel = strrep(mods_forLabel,'base','RPE');
  63. mods_forLabel = strrep(mods_forLabel,'curr','Current outcome');
  64. mods_forLabel = strrep(mods_forLabel,'mean','Unmodulated');
  65. % plot it
  66. h_boxplot = figure;
  67. set(h_boxplot, 'units', 'normalized', 'outerposition', [0 0 1 1])
  68. n_plot = length(mods);
  69. for m1_ind = 1:length(mods)
  70. m1 = mods{m1_ind};
  71. box_mat = [];
  72. for m2_ind = 1:length(mods)
  73. m2 = mods{m2_ind};
  74. box_mat(:,m2_ind) = LH.(m1).(m2);
  75. end
  76. h_sp_LH(m1_ind) = subplot(2,n_plot,m1_ind); hold on
  77. boxplot(box_mat,'BoxStyle','filled','PlotStyle','traditional','symbol','')
  78. set(gca,'tickdir','out','xtick',1:4,'xticklabel',cellfun(@(i) [i ' model'],mods_forLabel,'UniformOutput',false),'xticklabelrotation',60)
  79. ylabel('LH/trial')
  80. title([mods_forLabel{m1_ind} ' neurons'],'interpreter','none')
  81. % plot relative to mean model
  82. box_mat = [];
  83. for m2_ind = 1:length(mods) - 1 % all except the mean model
  84. m2 = mods{m2_ind};
  85. box_mat(:,m2_ind) = LH.(m1).(m2) - LH.(m1).mean;
  86. end
  87. h_sp_LHrel(m1_ind) = subplot(2,n_plot,m1_ind + n_plot); hold on
  88. boxplot(box_mat,'BoxStyle','filled','PlotStyle','traditional','symbol','')
  89. set(gca,'tickdir','out','xtick',1:3,'xticklabel',cellfun(@(i) [i ' model'],mods_forLabel(1:3),'UniformOutput',false),'xticklabelrotation',60)
  90. ylabel('\DeltaLH/trial (relative to Unmodulated model)')
  91. title([mods_forLabel{m1_ind} ' neurons'],'interpreter','none')
  92. plot([0.5 2.5],[0 0],'k:')
  93. end
  94. pause(0.1)
  95. ylim_LH = [-0.1 max([h_sp_LH.YLim])];
  96. ylim_LHrel = [-1 0.1];
  97. for cp = h_sp_LH
  98. subplot(cp)
  99. ylim(ylim_LH)
  100. end
  101. for cp = h_sp_LHrel
  102. subplot(cp)
  103. ylim(ylim_LHrel)
  104. end
  105. %%
  106. fprintf('RPE neurons [IQR]: %0.2f [%0.2f - %0.2f]\n', median(LH.base.base), prctile(LH.base.base, 25), prctile(LH.base.base, 75))
  107. fprintf('Current outcome neurons [IQR]: %0.2f [%0.2f - %0.2f]\n', median(LH.curr.curr), prctile(LH.curr.curr, 25), prctile(LH.curr.curr, 75))
  108. fprintf('Unmodulated neurons [IQR]: %0.2f [%0.2f - %0.2f]\n', median(LH.mean.mean), prctile(LH.mean.mean, 25), prctile(LH.mean.mean, 75))