Figure gallery

Here are some examples of figures and (sometimes incomplete) code snips that can give you an idea of how they were created using CANlab tools.

Blobs on brain surface

Download the data and matlab code



















3D connected brain

Download the data and matlab code












Surface plot

% b = softmax beta param
% s = value of square
% t = value of triangle
 
b = 1;  % inv temperature
 
% softmax function
sm = @(t, s, b) exp(b.*t) ./ (exp(b.*t)+exp(b.*s))
 
% range of values
 
tvals = [0:.1:5];
svals = tvals;
 
clear pt
 
for i = 1:length(svals)
 
    pt(i, :) = sm(tvals, svals(i), b);
 
end
 
%[data_matrix12, xvals2, yvals2, data_matrix22] = surf_plot_tor(data_matrix1, xvals, yvals, xname, yname, zname, [data_matrix2])
 
surf_plot_tor(pt, svals, tvals, 'V(s)', 'V(t)', 'P(choose t)');

%% add 2nd surface with different b value
 
b = 3;
 
for i = 1:length(svals)
    pt2(i, :) = sm(tvals, svals(i), b);
 
end
 
surf_plot_tor(pt, svals, tvals, 'V(s)', 'V(t)', 'P(choose t)', pt2);

multithreshold montage

Download the example matlab code























































Numbered points on brains

This is useful for meta-analysis, or also to view cluster centers from a clusters structure or region object. It also illustrates some of the things you can do with surfaces and addbrain.m. You can also add blobs to the surfaces using cluster_surf, and then put numbers on top of them.

Download the data and script.

cd('/Users/tor/Downloads/ROI_cluster_numbers_montage_demo')
load roi_sorted
 
% get coordinates for each cluster center
xyz = cat(1, r71_sorted.mm_center);
 
% Get region number and convert to text cell
num = (1:length(r71_sorted))';
num = num2cell(num); %Alternate:  num = mat2cell(num, ones(length(num), 1), 1);
num = cellfun(@num2str, num, 'UniformOutput', 0);
 
%% Montage of slices
plot_points_on_montage(xyz, 'text', num, 'color', [.2 .2 1], 'sagittal', 'slice_range', [-10 10], 'solid', 'spacing', 4, 'close_enough', 4, 'onerow', 'points');
hh = findobj(gcf, 'Type', 'text'); set(hh, 'Fontsize', 14, 'FontWeight', 'b');
 
plot_points_on_montage(xyz, 'text', num, 'color', [.2 .2 1], 'axial', 'slice_range', [-40 40], 'solid', 'spacing', 8, 'close_enough', 8, 'onerow', 'points');
hh = findobj(gcf, 'Type', 'text'); set(hh, 'Fontsize', 14, 'FontWeight', 'b');

%% Surface
[axishan, pointhan, surfhan] = plot_points_on_surface2(xyz, {'b'}, ones(size(num)), num, 'nospheres');
hh = findobj(gcf, 'Type', 'text'); set(hh, 'Fontsize', 18, 'FontWeight', 'b');
 
%% Subcortical surface
% NOTE: you need 3dHeadUtilityLite on your matlab path.
create_figure('subcortex');
DB = struct('xyz', xyz, 'x', xyz(:, 1), 'y', xyz(:, 2), 'z', xyz(:, 3));
[cl, pointhan, surfhan] = plot_points_on_subcortex(DB,'limbic', {'ro'}, ones(size(num)), num);
 
shan = addbrain('hires left');
set(shan, 'FaceColor', [.5 .5 .5], 'FaceAlpha', 1);
 
view(120, 20)
lightRestoreSingle
set(cat(2, surfhan{:}), 'FaceAlpha', .3);
hh = findobj(gcf, 'Type', 'text', 'color', 'r'); set(hh, 'Fontsize', 18, 'FontWeight', 'b');
lighting gouraud

















































Plot with separate lines between points

The core function for this is sepplot.m (in repository, /SCN_Core_Support/Visualization_functions/)

Example code:

x = 1:5; % x values
y = [32 40 55 84 130]; % mean
e = [6 6 6 6 6]; % standard error of the mean
 
create_figure(y_axis);
set(gcf, 'Position', [1   512   268   194]);
col = [0.3333    0.6588    1.0000];
markercol = col-.2;
 
h = errorbar(x, y, e, 'o', 'color', 'k', 'linewidth', 1.5, 'markersize', 7, 'markerfacecolor', col);
hold on;
sepplot(x, y, .75, 'color', col, 'linewidth', 2);
errorbar_width(h, x, [0 0]);
 
set(gca, 'xlim', [.5 5.5], 'linewidth', 1.5);
 
% because of a weird error when pdf is saved, I'm using try and catch.
try
    pagesetup(gcf);
    saveas(gcf, 'example_sepplot.pdf');
catch
    pagesetup(gcf);
    saveas(gcf, 'example_sepplot.pdf');
end
A bar plot function with some useful optional inputs

bar_wani.m (in repository, /SCN_Core_Support/Visualization_functions/)

Example code:

% data
y = [-0.6518   -0.6934   -0.5417   -0.6496   -0.5946   -0.3839
    1.1511    0.9090    1.1681    1.2892    0.9346    1.1383];
e = [0.3226    0.2936    0.3080    0.3203    0.3368    0.3167
    0.4026    0.4088    0.4012    0.5586    0.3734    0.4257];
p = [0.0433    0.0182    0.0785    0.0426    0.0775    0.2255
    0.0042    0.0262    0.0036    0.0210    0.0123    0.0075];
 
col =  [0    0.1157    0.2686
    0.1157    0.2765    0.4725
    0.4843    0.1157    0.1078
    0.3667    0.4765    0.1353
    0.2765    0.1902    0.3824
    0.0922    0.4216    0.5118
    0.7941    0.3235   0];
 
% draw
h = bar_wani(y, e, .8, 'colors', col, 'errbar_width', [0 0], 'ast', p, 'ylim', [-2.5 2.5], 'ytick', -2:2, 'ast_adj_x', 0, 'ast_adj_y_neg', .15);
set(gca, 'ytickLabel', num2str(get(gca, 'ytick')'));
set(h, 'position', [1   531   399   169]);
 
savename = 'example_barwani.pdf';
 
try
    pagesetup(h);
    saveas(h, savename);
catch
    pagesetup(h);
    saveas(h, savename);   
end
Display of voxel pattern maps

roi_contour_map.m (in repository, /SCN_Core_Support/Visualization_functions/)

The images you would need for the example below (dACC_*_pattern_sl6mm.nii). example_data.zip

Example code:

mask{1} = 'dACC_hw_pattern_sl6mm.nii';
mask{2} = 'dACC_rf_pattern_sl6mm.nii';
for i = 1:2, cl{i} = region(mask{i}); end
info = roi_contour_map([cl{1} cl{2}], 'cluster', 'use_same_range', 'colorbar'); 

Other example output (S2 in NPS: axial view [z = 16] with a significance outline in red):

dat = fmri_data(which('weights_NSF_grouppred_cvpcr.img'));
dat1 = fmri_data(which('weights_NSF_grouppred_cvpcr_FDR05.img'));
 
dat_sig = statistic_image;
dat_sig.dat = dat.dat;
dat_sig.sig = dat1.dat ~=0;
dat_sig.volInfo = dat.volInfo;
 
x = [23 73];
y = [-50 2]; 
z = [7 21];
 
vox = voxel2mm(dat_sig.volInfo.xyzlist', dat_sig.volInfo.mat);
vox = vox';
idx1 = vox(:,2)> y(1) & vox(:,2)< y(2);
idx2 = vox(:,1)> x(1) & vox(:,1)< x(2);
idx3 = vox(:,3)> z(1) & vox(:,3)< z(2);
 
idx = idx1 & idx2 & idx3;
 
dat = dat_sig;
dat.dat = dat.dat(idx);
dat.sig = dat.sig(idx);
dat.removed_voxels = ~idx;
 
info = roi_contour_map(dat, 'xyz', 3, 'coord', 16, 'sig');
help/core/figure_gallery.txt · Last modified: 2016/08/19 18:00 (external edit)
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0