get_mp.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. function [MP, MP_old] = get_mp(fld,monkey, sessions)
  2. % this function concatenates the mp table that was created for individual
  3. % sessions. it has 1 row per channel, so the resulting MP table will have 1
  4. % row per channel per session. this function also removes rows that never
  5. % have a stimulus in their RF. the original (with all rows intact) is
  6. % returned as MP_old.
  7. datadir = fld.procdatadir;
  8. MP = [];
  9. for sid = 1:length(sessions)
  10. % session info
  11. session = sessions{sid};
  12. q = strsplit(session,'_');
  13. cdate = q{2};
  14. block = str2num(q{3}(end-4));
  15. % load the data
  16. session_id = [monkey '_' cdate '_' num2str(block)];
  17. sessiondir = fullfile(datadir, monkey, session_id);
  18. try
  19. load(fullfile(sessiondir, [session_id '_channels.mat']));
  20. catch
  21. continue
  22. end
  23. %load([sessiondir session_id '_LUT.mat']);
  24. % add some session data
  25. session_id = repmat(sid,size(mp,1),1);
  26. date = repmat({cdate},size(mp,1),1);
  27. block = repmat(block,size(mp,1),1);
  28. mp = addvars(mp,session_id,date,block,'After','monkey_id');
  29. % concatenate
  30. MP = [MP; mp];
  31. end
  32. %% count rows that have empty values for Tar
  33. % in constructing MP, we added all channels that were available. each
  34. % channel is given a value for RFPos, which is available in MP.rfpos. this
  35. % value is technically between 1 and 6 and denotes the stimulus positions
  36. % that falls in the RF, but in practice, it's only ever 1 or empty.
  37. % this means that channels with RFPos=1 have a stimulus in their RF. we can
  38. % exclude channels that have an empty RFPos.
  39. emptyrows = cellfun('isempty',MP.Tar);
  40. disp(['There are ' num2str(sum(emptyrows)) ' empty rows']);
  41. MP_old = MP;
  42. MP(emptyrows,:) = [];
  43. disp(['There are ' num2str(length(unique(MP.chan_id))) ' usable channels for this monkey']);