Thursday, February 20, 2014

Saving Cluster-Corrected Images in SPM

Once you've loaded up a contrast in SPM and thresholded it at a particular correction threshold, such as cluster corrected or FWE corrected, you can then simply save that image into a .hdr/.img file for use in another viewer, such as MRIcron. Just push the save button in the results window, and there you have it. This image can also be used for other purposes, such as doing an ROI analysis within only those voxels passing a corrected threshold for a given contrast.

Cluster-corrected image in the SPM interface

Same image, but saved out into .hdr/.img format and viewed in MRIcron.

In case it isn't clear how to do this from the above, I've also made an instructional video about how to do it, which - if you can believe it - was done in only one take. I have my little victories.



1 comment:

  1. Hi Andy,
    Thanks for this blog.
    I'm trying to do it with matlab code (-for loop that calculating contrasts, FWE correct them and save as a mask) but for some unknown reason the mask not saved on my direction. I think I might do something wrong, maybe you can share here the matlabatch code to do it?

    Here is my code -

    for i1 = 1:length(participants_list)
    SPM_folder = fullfile(participants_folder,participants_list{i1},'GLM');
    for i2=1:length(conditions)
    clear matlabbatch;
    cont = conditions{i2};
    matlabbatch{1}.spm.stats.con.spmmat = cellstr(fullfile(SPM_folder,'SPM.mat'));
    matlabbatch{1}.spm.stats.con.consess{1}.tcon.name = cont_file_name;
    matlabbatch{1}.spm.stats.con.consess{1}.tcon.weights = cont;
    matlabbatch{1}.spm.stats.con.consess{1}.tcon.sessrep = 'repl';
    matlabbatch{1}.spm.stats.con.delete = 0;
    spm_jobman('run', matlabbatch);
    %multiple comparison correction
    con_files = dir([SPM_folder,'\con*.*']); con_num = length(con_files);
    matlabbatch{1}.spm.stats.results.spmmat = cellstr(fullfile(SPM_folder,'SPM.mat'));
    matlabbatch{1}.spm.stats.results.conspec.titlestr = '';
    matlabbatch{1}.spm.stats.results.conspec.contrasts = length(con_files);
    matlabbatch{1}.spm.stats.results.conspec.threshdesc = 'FWE';
    matlabbatch{1}.spm.stats.results.conspec.thresh = 0.05;
    matlabbatch{1}.spm.stats.results.conspec.extent = 0;
    matlabbatch{1}.spm.stats.results.conspec.conjunction = 1;
    matlabbatch{1}.spm.stats.results.conspec.mask.none = 1;
    matlabbatch{1}.spm.stats.results.units = 1;
    matlabbatch{1}.spm.stats.results.export{1}.binary.basename = ['Bin_',conditions{i2}];
    spm_jobman('run', matlabbatch);
    end
    end

    Thanks!

    ReplyDelete