main.m 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. % === Analysis pipeline for the Visual Search project ===
  2. % this file contains references to the main functions and comments about
  3. % how they should be used.
  4. %% specify the base directory for this system so that the code works ====
  5. % temporarily here to make it easier for CK to switch systems @home
  6. switch computer
  7. case 'MACI64'
  8. ThisSystem = 'CK-MBP';
  9. case 'GLNXA64'
  10. ThisSystem = 'CK-Home-Lin';
  11. % specify for your own system: add case
  12. end
  13. switch ThisSystem
  14. case 'CK-NIN-Lin'
  15. fld.basedir = '/home/chris/Desktop/VISUAL_SEARCH/MANUSCRIPT/Data_and_Code/DATA';
  16. case 'CK-Home-Lin'
  17. fld.basedir = '/home/chris/Desktop/VISUAL_SEARCH/MANUSCRIPT/Data_and_Code/DATA';
  18. case 'CK-MBP'
  19. fld.basedir = ['/Volumes/OSX/Users/chris/Dropbox/CURRENT_PROJECTS/'...
  20. 'MONKEY_EPHYS/VISUAL_SEARCH/MANUSCRIPT/Data_and_Code/DATA'];
  21. % specify for your own system: add case
  22. end
  23. fld.procdatadir = fullfile(fld.basedir,'Processed_Data');
  24. fprintf('=============================================================\n')
  25. fprintf(['System used: ' ThisSystem '\n'])
  26. fprintf(['Basedir used: ' fld.basedir '\n'])
  27. fprintf('=============================================================\n')
  28. % info --
  29. addpath(genpath(fullfile(pwd,'info')));
  30. % subfunctions --
  31. addpath(genpath(fullfile(pwd,'functions')));
  32. addpath(genpath(fullfile(pwd,'figfunctions')));
  33. %% individual session analysis ==========================================
  34. % Store individual % channels from individual sessions as individual files,
  35. % such that they can easily be concatenated.
  36. % LOG data are stored as LUTs (tables) that can be concatenated easily.
  37. if false % avoid running this redundantly
  38. % the following function returns a master list of all dates, that can be
  39. % used to load data
  40. datainfo = session_info(); %#ok<*UNRCH>
  41. % the following function loads the data, extracts all necessary
  42. % information and stores it in a more flexible format (a LUT).
  43. % It also preprocesses env data. The data is stored per channel.
  44. sessions = datainfo(1).dates;
  45. analyse_individual_sessions(fld, 'M1',sessions);
  46. sessions = datainfo(2).dates;
  47. analyse_individual_sessions(fld, 'M2',sessions);
  48. end
  49. %% adjust saved data ====================================================
  50. % we added goodtrials as an array, but it needs to be a cell array because
  51. % it doesn't have the same number of fields between sessions (so it can't
  52. % be concatenated). let's fix it once, using this function, so we don't
  53. % have to re-run analyse_individual_sessions.
  54. if false % avoid running this redundantly
  55. modify_mp(fld,'M1',datainfo(1).dates);
  56. modify_mp(fld,'M2',datainfo(2).dates);
  57. % there is an issue with the LUTs, namely that sometimes stimonset and
  58. % targonset are empty (we created the LUTs by converting log files into a
  59. % table. let's fix those.
  60. fix_lut(fld,'M1');
  61. fix_lut(fld,'M2');
  62. end
  63. %% extra info ===========================================================
  64. % this script loads data from the usable channels (i.e. channels that at
  65. % some point have a stimulus in their RF) and compares the SNR, to get a
  66. % better idea of which channels we can use.
  67. if false % avoid running this redundantly
  68. check_snr_over_sessions(fld,'M1',false);
  69. check_snr_over_sessions(fld,'M2',false);
  70. end
  71. %% figure behavior ======================================================
  72. % behavior
  73. figure_behavior(fld);
  74. %% output some general numbers for the methods section ==================
  75. methods_numbers(fld)
  76. %% figure neurotrace ====================================================
  77. % this figure shows the main result, namely that responses to targets are
  78. % enhanced and responses to distractors are supressed, both compared to
  79. % nontargets. this function also estimates the latency.
  80. if false % run prep-script
  81. for si = 1:2
  82. figure_neurotrace_prepare(fld,['M' num2str(si)],true);
  83. end
  84. end
  85. figure_neurotrace(fld)
  86. %% figure binmod ========================================================
  87. % do a binned version of the modulation plots
  88. figure_binmod(fld);
  89. %% figure neurobar ======================================================
  90. % this figure is a sort of extension of figure_neurotrace we show the
  91. % responses for when the monkey is correct (i.e. he chose the target, not
  92. % the nontarget or the distractor). Here we only look at bar plots
  93. % of averages in a window, but we add conditions in which the monkey was
  94. % incorrect (he chose either nontarget or distractor), and if he chose
  95. % nontarget, also we compare when that particular nontarget was in the RF
  96. % vs when it wasn't.
  97. % limit trials to include -------------------------------------------------
  98. % % do all possible combination in a loop ---
  99. % % by reactiontime
  100. % for rt=[0 -1 1]
  101. % limit.ReactionTime = rt;
  102. % % set to -1 (for lower) or +1 (for higher) or 0 for none at all
  103. % limit.ReactimeTimePerc = 30; % percentile
  104. % for dct = [0 1]
  105. % % by distance from target on error trials
  106. % limit.DistChoiceToTarget = dct;
  107. %
  108. % dctr=[1 1; 2 3];
  109. % for i=1:2
  110. % limit.DistChoiceToTarget_range = dctr(i,:); % [min max]
  111. %
  112. % for dcs = [0 1]
  113. % % by distance from SD on error trials
  114. % limit.DistChoiceToSD = dcs;
  115. %
  116. % dcsr=[1 1; 2 3];
  117. % for j=1:2
  118. % limit.DistChoiceToSD_range = dcsr(j,:); % [min max]
  119. %
  120. % limit.PlotBehavior = false;
  121. % % -------------------------------------------------------------------------
  122. %
  123. % figure_neurobar_prepare(fld,'M1', limit);
  124. % figure_neurobar_prepare(fld,'M2', limit);
  125. % figure_neurobar(fld, limit);
  126. % end
  127. % end
  128. % end
  129. % end
  130. % end
  131. limit.ReactionTime = 0;
  132. % set to -1 (for lower) or +1 (for higher) or 0 for none at all
  133. limit.ReactimeTimePerc = 30; % percentile
  134. % by distance from target on error trials
  135. limit.DistChoiceToTarget = 0;
  136. limit.DistChoiceToTarget_range = [1 1]; % [min max]
  137. % by distance from SD on error trials
  138. limit.DistChoiceToSD = 0;
  139. limit.DistChoiceToSD_range = [1 1]; % [min max]
  140. limit.PlotBehavior = false;
  141. % -------------------------------------------------------------------------
  142. figure_neurobar_prepare(fld,'M1', limit);
  143. figure_neurobar_prepare(fld,'M2', limit);
  144. figure_neurobar(fld, limit);
  145. %% figure priming (behavior and RT color same/swap high/low reward) =====
  146. figure_priming_color(fld)
  147. figure_priming_shape(fld)
  148. figure_priming_col_vs_shape(fld)
  149. %% figure neuropriming (neuronal effect of shape/color swap =============
  150. figure_neuropriming_prepare(fld,'M1')
  151. figure_neuropriming_prepare(fld,'M2')
  152. figure_neuropriming(fld)
  153. %% figure saccadic response times (SRT) =================================
  154. figure_SRT(fld)