ContrastAnalysis.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. % ContratAnalysis.m
  2. %
  3. % This function creates the contrasts of interest. It uses the SPM.mat file
  4. % within the provided directory
  5. %
  6. % input:
  7. % directory - directory to search for SPM.mat file
  8. function ContrastAnalysis(directory)
  9. % create batch file
  10. matlabbatch = [];
  11. matlabbatch{1}.spm.stats.con.spmmat = cellstr([directory '/SPM.mat']);
  12. matlabbatch{1}.spm.stats.con.consess{1}.tcon.name = 'SP > sacc';
  13. contrast = zeros(8,18);
  14. contrast(:,4) = 1;
  15. contrast(:,10) = -1;
  16. contrast = constrast';
  17. matlabbatch{1}.spm.stats.con.consess{1}.tcon.convec = contrast(:);
  18. % equivalent to
  19. % matlabbatch{1}.spm.stats.con.consess{1}.tcon.convec = [0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 ...
  20. % 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 ... % session 2
  21. % 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 ... % session 3
  22. % 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 ... % session 4
  23. % 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 ... % session 5
  24. % 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 ... % session 6
  25. % 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 ... % session 7
  26. % 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 ... % session 8
  27. % ];
  28. matlabbatch{1}.spm.stats.con.consess{1}.tcon.sessrep = 'none';
  29. matlabbatch{1}.spm.stats.con.consess{2}.tcon.name = 'sacc > SP';
  30. contrast = zeros(8,18);
  31. contrast(:,4) = -1;
  32. contrast(:,10) = 1;
  33. contrast = constrast';
  34. matlabbatch{1}.spm.stats.con.consess{2}.tcon.convec = contrast(:);
  35. matlabbatch{1}.spm.stats.con.consess{2}.tcon.sessrep = 'none';
  36. matlabbatch{1}.spm.stats.con.consess{3}.tcon.name = 'SP > baseline';
  37. contrast = zeros(8,18);
  38. contrast(:,4) = 1;
  39. contrast = constrast';
  40. matlabbatch{1}.spm.stats.con.consess{3}.tcon.convec = contrast(:);
  41. matlabbatch{1}.spm.stats.con.consess{3}.tcon.sessrep = 'none';
  42. matlabbatch{1}.spm.stats.con.consess{4}.tcon.name = 'sacc > baseline';
  43. contrast = zeros(8,18);
  44. contrast(:,10) = 1;
  45. contrast = constrast';
  46. matlabbatch{1}.spm.stats.con.consess{4}.tcon.convec = contrast(:);
  47. matlabbatch{1}.spm.stats.con.consess{4}.tcon.sessrep = 'none';
  48. % execute job
  49. spm_jobman('run',matlabbatch);
  50. end