function masking = tbx_config_masking % Configuration file for Masking toolbox under SPM5 or later % See also: tbx_config2cfg_masking if ~isdeployed, addpath(fullfile(spm('dir'), 'toolbox', 'Masking')); end innames = Files('Input Images', 'innames', 'image', [1 Inf]); outname = Entry('Output Filename', 'outname', 's', [1 Inf], ... {'average.nii'}); outname.help = {'The output image is saved with this name. ' ... ['If a path name is given here, the output ' ... 'directory setting will be ignored. If there is no path and ' ... 'no output directory, then the current working directory is used']}; outdir = Files('Output Directory', 'outdir', 'dir', [0 1], {''}); outdir.help = {['Output files will be written into this ' ... 'directory. If no directory is given, images will be ' ... 'written to current working directory. If both output ' ... 'filename and output directory contain a directory, then '... 'output filename takes precedence.']}; %% Make average avgexpr = Menu('Average Expression', 'avgexpr', ... {'Arithmetic mean', 'Median'}, {'mean(X)', 'median(X)'}, {'mean(X)'}); avgexpr.help = {'Type of average to compute'}; makeavg = Branch('Make Average', 'makeavg', ... {innames avgexpr outname outdir}, @make_average, @make_average_vout); makeavg.help = {... ['The Masking toolbox contains code for creating a thresholded ' ... 'binary image that can be specified as an explicit analysis mask ' ... 'when setting up a statistical model in SPM. '] ... ['This user-interface implements a strategy for automatically ' ... 'computing a threshold for an image which is typically an average ' ... 'of the scans to be analysed.'] ... 'This module first creates an average from the selected images.'}; %% Optimal thresholding inname = Files('Input Image', 'inname', 'image', [1 1]); outname.val = {'average_optthr.nii'}; optfunc = Menu('Optimality Criterion', 'optfunc', ... {'Corr(img, img > thr)', 'Luo-Nichols anti-mode'}, ... {'@opt_thr_corr', '@opt_thr_antimode'}, {'@opt_thr_corr'}); optfunc.help = {'Choice of objective. See help on Optimal Thresholding.'}; optthr = Branch('Optimal Thresholding', 'optthr', ... {inname optfunc outname outdir}, @opt_thresh, @opt_thresh_vout); optthr.help = {... ['The Masking toolbox contains code for creating a thresholded ' ... 'binary image that can be specified as an explicit analysis mask ' ... 'when setting up a statistical model in SPM. '] ... ['This user-interface implements a strategy for automatically ' ... 'computing a threshold for an image which is typically an average ' ... 'of the scans to be analysed.'] ... ['This module optimally thresholds an image, according to ' ... 'one of two objective functions.'] ... 'The first is the one from the paper by Ridgway et al, ' ... ' http://dx.doi.org/10.1016/j.neuroimage.2008.08.045 ' ... ['It is based on maximising the correlation between the original ' ... 'and thresholded images. This is equivalent to finding the ' ... 'threshold that gives the largest two-sample t-statistic between ' ... 'the above and below threshold parts of the data, ' ... 'which is similar to the classic Otsu thresholding criterion, ' ... 'based on maximum between-class separation with the histrogram. '] ... ' http://en.wikipedia.org/wiki/Otsu''s_method' ... 'Please cite Ridgway et al. if you find the toolbox useful.' ... '', 'The second is described in appendix B of the paper ' ... [' Diagnosis and exploration of massively univariate ' ... 'neuroimaging models'] ... ' Luo & Nichols (2003) Neuroimage 19:1014-1032 ' ... ' http://www.sph.umich.edu/ni-stat/SPMd/SPMd.pdf ' ... ' http://dx.doi.org/10.1016/S1053-8119(03)00149-6 ' ... ['Please cite both Ridgway et al. and Luo & Nichols if you use ' ... 'this method.']}; %% Main toolbox masking = Repeat('Mask Creation', 'masking', {makeavg, optthr}); masking.help = {... ['The Masking toolbox contains code for creating a thresholded ' ... 'binary image that can be specified as an explicit analysis mask ' ... 'when setting up a statistical model in SPM. '] ... ['This user-interface implements a strategy for automatically ' ... 'computing a threshold for an image which is typically an average ' ... 'of the scans to be analysed.'] ... ['Command-line functions are available for some other approaches,' ... 'for example make_majority_mask.m. '] ... 'These strategies, and related aspects, are described in the paper' ... [' Issues with threshold masking ' ... 'in Voxel Based Morphometry of atrophied brains. '] ... [' Ridgway, G.R.; Omar, R.; Ourselin, S.; Hill, D.L.G.; ' ... 'Warren, J.D.; and Fox, N.C. (in press) NeuroImage'] ... ' http://dx.doi.org/10.1016/j.neuroimage.2008.08.045 ' ... ' pre-print available from http://eprints.ucl.ac.uk/13060/' ... 'Please cite this paper if you find the toolbox useful.'}; %% functions for nodes described in spm5/spm_config.m % (arguments after the ... and line-break are optional) function out = Menu(name, tag, labels, values, ... val, def, help) out = struct(... 'type', 'menu', ... 'name', name, ... 'tag', tag, ... 'labels', {labels}, ... 'values', {values} ... ); if exist('val', 'var') && ~isempty(val) out.val = val; end if exist('def', 'var') && ~isempty(def) out.def = def; end if exist('help', 'var') && ~isempty(help) out.help = help; end %-------------------------------------------------------------------------- function out = Entry(name, tag, strtype, num, ... val, def, extras, help) out = struct(... 'type', 'entry', ... 'name', name, ... 'tag', tag, ... 'strtype', strtype, ... 'num', num ... ); if exist('val', 'var') && ~isempty(val) out.val = val; end if exist('def', 'var') && ~isempty(def) out.def = def; end if exist('extras', 'var') && ~isempty(extras) out.extras = extras; end if exist('help', 'var') && ~isempty(help) out.help = help; end %-------------------------------------------------------------------------- function out = Files(name, tag, filter, num, ... val, def, help, dir, ufilter) out = struct(... 'type', 'files', ... 'name', name, ... 'tag', tag, ... 'filter', filter, ... 'num', num ... ); if exist('val', 'var') && ~isempty(val) out.val = val; end if exist('def', 'var') && ~isempty(def) out.def = def; end if exist('help', 'var') && ~isempty(help) out.help = help; end if exist('dir', 'var') && ~isempty(dir) out.dir = dir; end if exist('ufilter', 'var') && ~isempty(ufilter) out.ufilter = ufilter; end %-------------------------------------------------------------------------- function out = Branch(name, tag, val, ... prog, vfiles, check, modality, help) out = struct(... 'type', 'branch', ... 'name', name, ... 'tag', tag, ... 'val', {val} ... ); if exist('prog', 'var') && ~isempty(prog) out.prog = prog; end if exist('vfiles', 'var') && ~isempty(vfiles) out.vfiles = vfiles; end if exist('check', 'var') && ~isempty(check) out.check = check; end if exist('modality', 'var') && ~isempty(modality) out.modality = modality; end if exist('help', 'var') && ~isempty(help) out.help = help; end %-------------------------------------------------------------------------- function out = Repeat(name, tag, values, ... num, help) out = struct(... 'type', 'repeat', ... 'name', name, ... 'tag', tag, ... 'values', {values} ... ); if exist('num', 'var') && ~isempty(num) out.num = num; end if exist('help', 'var') && ~isempty(help) out.help = help; end