-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmc_plot_connectome.m
More file actions
84 lines (74 loc) · 2 KB
/
mc_plot_connectome.m
File metadata and controls
84 lines (74 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
function mc_plot_connectome(flatmat,nets,varargin)
invert = 0;
if (nargin>2)
invert = varargin{1};
end
h = [];
if (nargin>3)
h = varargin{2};
end
tri = 0;
if (nargin>4)
tri = varargin{3};
end
labels = [];
if (nargin>5)
labels = varargin{4};
end
%simple plotting function to plot a sorted connectome
[snets,sidx] = sort(nets);
mat = mc_unflatten_upper_triangle(flatmat);
mat = mat + mat';
smat = mat(sidx,sidx);
if (isempty(h))
h = figure;
end
if (tri==1)
smat(tril(ones(size(smat)))==1) = 0;
end
imagesc(smat);
%set(gca,'YDir','normal')
axis square;
%set colorbar
cmx = max(abs(smat(:)));
caxis([-cmx cmx]);
zo = linspace(0,1,33)';
oz = flipud(zo);
zo = zo(1:end-1);
oz = oz(1:end-1);
oo = ones(size(zo));
cmap = [zo zo oo;oo oz oz];
if (invert)
cmap = flipud(cmap);
end
colormap(cmap)
%draw network boundary lines
hold on;
u = unique(snets);
boundaries = cumsum(crosstab(snets));
boundaries = boundaries(1:end-1);
limits = axis;
mn = limits(1);
mx = limits(2);
for i = 1:numel(boundaries)
plot([mn mx],[boundaries(i) boundaries(i)],'k-');
plot([boundaries(i) boundaries(i)],[mn mx],'k-');
end
if (tri==1)
set(gca,'Visible','off');
plot([mn mx],[mn mn],'k-');
plot([mx mx],[mn mx],'k-');
patch([mn mn mx],[mn mx mx],'w','EdgeColor','none','FaceColor',[247 243 247]/255);
plot([mn mx],[mn mx],'k-');
end
if (~isempty(labels))
%calculate center plot points based on nets
xticks([0;boundaries] + diff([0;boundaries;numel(nets)])/2);
xticklabels(labels);
set(gca,'XAxisLocation','top','box','off');
set(gca,'Visible','on');
xtickangle(45);
set(gca,'YTick',[]);
set(gca,'YAxisLocation','right','box','off');
end
hold off;