ery_4a_prep_s2_merge_pheno_files.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. %% ery_4a_prep_s2_merge_pheno_files
  2. %
  3. % This quick and dirty script merges the phenotype.tsv files with online
  4. % and offline ratings into one single ratings_all.tsv file, and saves it
  5. %
  6. % NOTE: script needs to be run from BIDS/phenotype dir, NOT from root dir
  7. %
  8. %
  9. %__________________________________________________________________________
  10. %
  11. % author: Lukas Van Oudenhove
  12. % date: April, 2022
  13. %
  14. %__________________________________________________________________________
  15. % @(#)% ery_4a_prep_s2_merge_pheno_files v1.0
  16. % last modified: 2022/04/25
  17. %% READ OFFLINE FILE
  18. varNames = {'trial_type','participant_id','hunger','intensity','liking'};
  19. varTypes = {'categorical','categorical','double','double','double'};
  20. delimiter = '\t';
  21. filetype = 'text';
  22. datastartline = 2;
  23. opts = delimitedTextImportOptions('VariableNames',varNames,...
  24. 'VariableTypes',varTypes,...
  25. 'Delimiter',delimiter,...
  26. 'DataLines',datastartline);
  27. offline = readtable('ratings_offline.tsv',opts);
  28. %% READ ONLINE FILE
  29. online = readtable('ratings_online.tsv','Delimiter',delimiter,'FileType',filetype);
  30. online.participant_id = categorical(online.participant_id);
  31. online.trial_type = categorical(online.trial_type);
  32. %% MERGE AND WRITE
  33. all = join(online,offline);
  34. writetable(all,'ratings_all.tsv','FileType',filetype,'Delimiter',delimiter);