ck_GetEphys_pRF.m 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. function ck_GetEphys_pRF(monkeys,models,output)
  2. if nargin < 2
  3. fprintf('ERROR: Not enough arguments specified\n');
  4. return
  5. end
  6. clc;
  7. %% data location ==========================================================
  8. % location of this script
  9. homefld = pwd;
  10. % Get the root folder path for the hared data/code
  11. cd ../../../
  12. SHARED_ROOT_FLD = pwd;
  13. cd(homefld)
  14. fitres_path = fullfile(SHARED_ROOT_FLD,'FitResults','EPHYS');
  15. save_path = fullfile(SHARED_ROOT_FLD,'FitResults','EPHYS','Combined');
  16. chanmap_path = fullfile(SHARED_ROOT_FLD,'Preprocessed_data','EPHYS');
  17. %% Collect EPHYS ==========================================================
  18. fprintf('Collecting ephys retinotopic maps...\n');
  19. for m = 1:length(monkeys)
  20. fprintf(['Processing monkey: ' monkeys{m} '\n']);
  21. cMonkey = monkeys{m}; cMonkey(1)=upper(cMonkey(1));
  22. R(m).monkey = monkeys{m};
  23. R(m).mode = 'ephys';
  24. fprintf(['Getting channel maps \n']);
  25. CM = load(fullfile(chanmap_path,monkeys{m},...
  26. ['channel_area_mapping_' monkeys{m}]));
  27. R(m).ChanMap = CM; clear CM;
  28. for mm = 1:length(models)
  29. fprintf(['Model: ' models{mm} '\n']);
  30. R(m).model(mm).prfmodel = models{mm};
  31. if ~strcmp(models{mm},'classicRF')
  32. for i = 1:8
  33. fprintf(['Instance: ' num2str(i) '\n']);
  34. %% MUA --
  35. fprintf('MUA\n');
  36. RES = load(fullfile(fitres_path,monkeys{m},models{mm},...
  37. ['Instance_' num2str(i)],...
  38. ['pRF_Sess-mua_Inst_' num2str(i)]),'result');
  39. R(m).model(mm).MUA(i) = RES.result;
  40. clear RES
  41. %% LFP --
  42. for l=1:5
  43. fprintf(['LFP ' num2str(l) '\n']);
  44. RES = load(fullfile(fitres_path,monkeys{m},models{mm},...
  45. ['Instance_' num2str(i)],...
  46. ['pRF_Sess-lfp_fb' num2str(l) '_Inst_' num2str(i)]),'result');
  47. R(m).model(mm).LFP(i,l) = RES.result;
  48. clear RES
  49. end
  50. end
  51. else
  52. for i = 1:8
  53. fprintf(['Instance: ' num2str(i) '\n']);
  54. RES = load(fullfile(fitres_path,monkeys{m},models{mm},...
  55. ['RFs_instance' num2str(i)]));
  56. R(m).model(mm).MUA(i).RF = RES.RFs;
  57. % R(m).model(mm).MUA(i).chanRF = RES.channelRFs; % not used
  58. R(m).model(mm).MUA(i).SNR = RES.meanChannelSNR;
  59. R(m).model(mm).MUA(i).R2 = RES.meanChannelR2.*100;
  60. clear RES
  61. end
  62. end
  63. end
  64. end
  65. %% Save the combined results ==============================================
  66. fprintf('Saving the combined ephys result-file\n');
  67. [~,~,~] = mkdir(fullfile(save_path));
  68. save(fullfile(save_path,output),'R')