Diff for "BatchRenderRfx" - MRC CBU Imaging Wiki
location: Diff for "BatchRenderRfx"
Differences between revisions 2 and 3
Revision 2 as of 2006-10-01 20:18:33
Size: 4899
Comment:
Revision 3 as of 2006-11-03 10:23:52
Size: 5010
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Modified version Ferath's script to threshhold and print SPM5 results. The script prints rendered activations as well as a list of coordinates. The first six blocks of lines are the ones you need to (or are most likely to
want to) change. Originally modified by DannyMitchell and subsequently by IanNimmoSmith.
Modified version Ferath's script to threshhold and print SPM5 results. The script prints rendered activations as well as a list of coordinates. The first six blocks of lines are the ones you need to (or are most likely to want to) change. Originally modified by DannyMitchell and subsequently by IanNimmoSmith.
Line 4: Line 3:

1. Path to data, and where the results are printed 
 1. Path to data, and where the results are printed
Line 14: Line 12:
 1. Set the following variable to 'yes' to do a 2-tailed test and show rendered activations and deactivations  (assumes that positive and negative second level contrasts have already been calculated; Glass brains will   only show positive activations). Set it to 'no' to to a 1-tailed test and only calculate positive activations.  1. Set the following variable to 'yes' to do a 2-tailed test and show rendered activations and deactivations (assumes that positive and negative second level contrasts have already been calculated; glass brains will only show positive activations). Set it to 'no' to do a 1-tailed test and only calculate positive activations.
Line 21: Line 18:
 1. Minimum number of contiguous voxels 
 {{{ExtentThreshold=0;}}} 
 1. Minimum number of contiguous voxels
 {{{ExtentThreshold=0;}}}
Line 24: Line 21:
 * The program needs files cls_getRes.m and cls_getSPM2.m. For CBU people this line will find them, otherwise you need to download them and point to their path.
 1. The program needs files cls_getRes.m and cls_getSPM2.m. For CBU people this line will find them, otherwise you need to download them and point to their path.
Line 28: Line 24:
 * Method for correcting for multiple comparisons : 'FWE','FDR', or 'none'
 {{{MCC='FDR';}}} 
 1. Method for correcting for multiple comparisons : 'FWE','FDR', or 'none'
 {{{MCC='FDR';}}}
Line 31: Line 27:
 * The brain on which you want to render the results  1. The brain on which you want to render the results
Line 34: Line 30:
 * Do it:  1. Do it:
Line 65: Line 61:
        xSPM.u=0.025; % 2-tailed
        TailText='2-tailed, p<0.05';
        xSPM.u=Threshold/2; % 2-tailed
        TailText=strcat('2-tailed, p<',Threshold);
Line 68: Line 64:
        xSPM.u=0.05; % 1-tailed
        TailText='1-tailed, p<0.05';
        xSPM.u=Threshold; % 1-tailed
        TailText=strcat('1-tailed, p<',Threshold);
Line 71: Line 67:
    xSPM.k=0;     xSPM.k=ExtentThreshold;
Line 73: Line 69:
    delete(gcf) % this is a bit annoying, but for some reason I had problems without it 
    for i=2:-1:1 
    delete(gcf) % this is a bit annoying, but for some reason I had problems without it
    for i=2:-1:1
Line 89: Line 85:
        spm_render(flipdat,0.5,Brain);         spm_render(flipdat,0.5,Brain); % change the middle parameter to play with brightness of activations

Modified version Ferath's script to threshhold and print SPM5 results. The script prints rendered activations as well as a list of coordinates. The first six blocks of lines are the ones you need to (or are most likely to want to) change. Originally modified by DannyMitchell and subsequently by IanNimmoSmith.

  1. Path to data, and where the results are printed

    dataroot = '/imaging/yourname/TestReCon';

  2. Name of folder, in above directory, where analysis is

    outputdir='';

  3. Cell array of folder names in outputdir, containing the SPMs for each contrast

    cond_dir={'EarlySmoothNoReCon'};

  4. Set the following variable to 'yes' to do a 2-tailed test and show rendered activations and deactivations (assumes that positive and negative second level contrasts have already been calculated; glass brains will only show positive activations). Set it to 'no' to do a 1-tailed test and only calculate positive activations.

    ShowDeactivations = 'no';

  5. p threshold

    Threshold=0.05;

  6. Minimum number of contiguous voxels

    ExtentThreshold=0;

  7. The program needs files cls_getRes.m and cls_getSPM2.m. For CBU people this line will find them, otherwise you need to download them and point to their path.

    addpath /imaging/dm01/MoreTools/spm2Batch

  8. Method for correcting for multiple comparisons : 'FWE','FDR', or 'none'

    MCC='FDR';

  9. The brain on which you want to render the results

    Brain='/imaging/local/spm/spm5/rend/render_smooth_average.mat';

  10. Do it:
    if exist(fullfile(dataroot,strcat(outputdir,'_RFX_Rendered.ps')))==2
        delete(fullfile(dataroot,strcat(outputdir,'_RFX_Rendered.ps')));
    end;
    disp(strcat('Printing results to:...',fullfile(dataroot,strcat(outputdir,'_RFX_Rendered.ps'))))
    spm_defaults;
    global defaults
    defaults.modality='FMRI';
    
    %--------------------------------------------------------------------
    %- xSPM is a structure for the parameters
    
    xSPM = struct( ...
        'swd', '', ... % full path to SPM.mat file
        'Ic', [], ... % no of contrast (or contrasts for conjunction)
        'Im', [],... % no of contrast to mask with. Empty for no masking
        'pm', [],... % masking contrast uncorrected p
        'Ex', [],... % whether masking is inclusive or exclusive
        'title', '',... % if empty results in default contrast title
        'Mcp', MCC,... % Mutiple comp method: FWE|FDR|none
        'u', Threshold,... % threshold (corrected or uncorrected, as above)
        'k', ExtentThreshold); % extent threshold
    
    clear SPM
    
    for i = 1:size(cond_dir,2)
        condir = fullfile(dataroot,outputdir,cond_dir{i});
        cd(condir);
        xSPM.spmmat = fullfile(condir,'SPM.mat'); % Get SPM path
        if ShowDeactivations(1)=='y'
            xSPM.u=Threshold/2; % 2-tailed
            TailText=strcat('2-tailed, p<',Threshold);
        else
            xSPM.u=Threshold; % 1-tailed
            TailText=strcat('1-tailed, p<',Threshold);
        end
        xSPM.k=ExtentThreshold;
        bck_xSPM=xSPM;
        delete(gcf) % this is a bit annoying, but for some reason I had problems without it
        for i=2:-1:1
            xSPM= bck_xSPM; % Reset xSPM to default
            xSPM.Ic=i; %Set the current contrast Index
            [hReg,xSPM,SPM] = csl_getRes(xSPM);
            dat(3-i) = struct( 'XYZ', xSPM.XYZ,...
                't', xSPM.Z',...
                'mat', xSPM.M,...
                'dim', xSPM.DIM);
        end
        clear flipdat
        flipdat(1)=dat(2);
        if ShowDeactivations(1)=='y'
            flipdat(2)=dat(1);
        end
        try
            spm_render(flipdat,0.5,Brain); % change the middle parameter to play with brightness of activations
            ann1=annotation('textbox',[0 .94 1 .06],'Color','r','String',{strcat('RFX results (',TailText,' correction=',MCC,', red=positive)'),strcat('Data:...',condir),strcat('Date:...',datestr(now,0))},'edge','none');
        catch
            try
                spm_render(flipdat(1),0.5,Brain);
                ann1=annotation('textbox',[0 .94 1 .06],'Color','r','String',{strcat('RFX results (',TailText,' correction=',MCC,', red=positive)'),strcat('Data:...',condir),strcat('Date:...',datestr(now,0))},'edge','none');
            catch
                try
                    spm_render(flipdat(2),0.5,Brain);
                    ann1=annotation('textbox',[0 .94 1 .06],'Color','r','String',{strcat('RFX results (',TailText,' correction=',MCC,', RED=NEGATIVE)'),strcat('Data:...',condir),strcat('Date:...',datestr(now,0))},'edge','none');
                catch
                    ann1=annotation('textbox',[0 .94 1 .06],'Color','r','String',{strcat('RFX results (',TailText,' correction=',MCC,') No significant effects'),strcat('Data:...',condir),strcat('Date:...',datestr(now,0))},'edge','none');
                end
            end
        end
        spm_print(fullfile(dataroot,strcat(outputdir,'_RFX_Rendered.ps')));
        spm_list('List',xSPM,hReg);
        spm_print(fullfile(dataroot,strcat(outputdir,'_RFX_Rendered.ps')));
        xSPM= bck_xSPM; % Reset xSPM to default
        delete(ann1);
    end

CbuImaging: BatchRenderRfx (last edited 2013-03-07 21:24:07 by localhost)