neuroelf_gui_-_scripting
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | neuroelf_gui_-_scripting [2011/02/28 22:59] (current) – created jochen | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== NeuroElf - GUI Scripting ====== | ||
+ | ===== Motivation ===== | ||
+ | While using the GUI manually (browsing maps, setting thresholds, etc.) is usually the first step in getting a feel for the data, sometimes it is yet convenient to create a set of images (screenshots, | ||
+ | |||
+ | NeuroElf thus offers the capability to control much of the behavior available via mouse clicks as function calls to the neuroelf_gui function. | ||
+ | |||
+ | ===== Requirements ===== | ||
+ | In the presented case, a GLM file was manually opened, and a VMP file was pre-created containing the result of regression maps. | ||
+ | |||
+ | ===== Script ===== | ||
+ | <code matlab negui_script_example.m> | ||
+ | global ne_gcfg; | ||
+ | |||
+ | % list of maps to cluster and show effects of | ||
+ | maps = [1, 2, 11, 12, 21, 22, 31, 32]; | ||
+ | |||
+ | % get handle to xff class | ||
+ | x = xff; | ||
+ | |||
+ | % which file to use as underlay for display | ||
+ | try | ||
+ | vmr = x(' | ||
+ | catch | ||
+ | vmr = neuroelf_file(' | ||
+ | end | ||
+ | vmr.Browse; | ||
+ | |||
+ | % load VMP | ||
+ | try | ||
+ | vmp = x(' | ||
+ | catch | ||
+ | vmp = xff('/ | ||
+ | end | ||
+ | vmp.Browse; | ||
+ | |||
+ | % open montage window | ||
+ | neuroelf_gui(' | ||
+ | drawnow; | ||
+ | |||
+ | % options for montage images | ||
+ | miopt = struct( ... | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | % get (Matlab UI) handle of all beta plot windows | ||
+ | cfigs = fieldnames(ne_gcfg.cc); | ||
+ | bpfig = cfigs(~isemptycell(regexpi(cfigs, | ||
+ | bpglm = bpfig; | ||
+ | bpglmf = bpglm; | ||
+ | bpglmvb = bpglm; | ||
+ | for fc = 1: | ||
+ | bpglm{fc} = ne_gcfg.cc.(bpfig{fc}).Config.glm; | ||
+ | bpfig{fc} = ne_gcfg.cc.(bpfig{fc}).SatelliteMLH; | ||
+ | [glmpath, bpglmf{fc}] = fileparts(bpglm{fc}.FilenameOnDisk); | ||
+ | end | ||
+ | bpfig = cat(1, bpfig{:}); | ||
+ | |||
+ | % set figure size(s) | ||
+ | set(bpfig, ' | ||
+ | |||
+ | % iterate over maps | ||
+ | for mc = 1: | ||
+ | | ||
+ | % get map number and name | ||
+ | mn = maps(mc); | ||
+ | mnm = makelabel(vmp.Map(mn).Name); | ||
+ | | ||
+ | % enable clustering thresholds and two-tailed test | ||
+ | vmp.Map(mn).ClusterSize = 57; | ||
+ | vmp.Map(mn).EnableClusterCheck = 1; | ||
+ | vmp.Map(mn).ShowPositiveNegativeFlag = 3; | ||
+ | | ||
+ | % set as current map | ||
+ | neuroelf_gui(' | ||
+ | | ||
+ | % enforce correct threshold | ||
+ | neuroelf_gui(' | ||
+ | | ||
+ | % create cluster table | ||
+ | neuroelf_gui(' | ||
+ | | ||
+ | % continue if no clusters | ||
+ | if isempty(ne_gcfg.voi.VOI) | ||
+ | continue; | ||
+ | end | ||
+ | | ||
+ | % set map in options for montage image | ||
+ | drawnow; | ||
+ | miopt.stvix = mn; | ||
+ | miopt.stthr = [vmp.Map(mn).LowerThreshold, | ||
+ | | ||
+ | % restrict clusters to 8mm spheres | ||
+ | neuroelf_gui(' | ||
+ | neuroelf_gui(' | ||
+ | | ||
+ | % get VOI object handle | ||
+ | voi = ne_gcfg.voi; | ||
+ | | ||
+ | % extract betas | ||
+ | for fc = 1: | ||
+ | bpglmvb{fc} = bpglm{fc}.VOIBetas(voi); | ||
+ | end | ||
+ | | ||
+ | % iterate over clusters | ||
+ | for cc = 2: | ||
+ | | ||
+ | % get coordinate and text | ||
+ | svoi = voi.VOI(cc); | ||
+ | svoic = svoi.Voxels(1, | ||
+ | svoin = regexprep(svoi.Name, | ||
+ | svoin = regexprep(svoin, | ||
+ | svoin = regexprep(svoin, | ||
+ | | ||
+ | % build cluster name | ||
+ | clname = sprintf(' | ||
+ | | ||
+ | % set cluster | ||
+ | neuroelf_gui(' | ||
+ | | ||
+ | % draw and update | ||
+ | pause(0.01); | ||
+ | drawnow; | ||
+ | pause(0.01); | ||
+ | | ||
+ | % handle barplots | ||
+ | for fc = 1: | ||
+ | | ||
+ | % get frame(s) from figure(s) | ||
+ | bplot = getframe(bpfig(fc)); | ||
+ | | ||
+ | % save as PNGs | ||
+ | imwrite(bplot.cdata, | ||
+ | | ||
+ | % save extract data as well | ||
+ | vb = bpglmvb{fc}(:, | ||
+ | save(sprintf(' | ||
+ | end | ||
+ | | ||
+ | % create three panel views | ||
+ | miopt.drc = 1; % SAG | ||
+ | miopt.filename = sprintf(' | ||
+ | miopt.frame = [128, 128, 128; svoic(1), -127.99, -127.9999]; | ||
+ | neuroelf_gui(' | ||
+ | miopt.drc = 2; % COR | ||
+ | miopt.filename = sprintf(' | ||
+ | miopt.frame = [128, 128, 128; -127.99, svoic(2), -127.9999]; | ||
+ | neuroelf_gui(' | ||
+ | miopt.drc = 3; % TRA | ||
+ | miopt.filename = sprintf(' | ||
+ | miopt.frame = [128, 128, 128; -127.99, -127.99, svoic(3)]; | ||
+ | neuroelf_gui(' | ||
+ | end | ||
+ | end</ | ||
+ | |||
+ | ===== Remarks ===== | ||
+ | Many aspects of this script can still be adapted, such as the settings for the single-slice montage images, or the thresholding options. The usefulness of such a script is, of course, questionable, |
neuroelf_gui_-_scripting.txt · Last modified: 2011/02/28 22:59 by jochen