-
Notifications
You must be signed in to change notification settings - Fork 0
/
ya_plotBrainSurface.m
38 lines (27 loc) · 1.01 KB
/
ya_plotBrainSurface.m
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
function [currFig, patchHandle] = ya_plotBrainSurface(allenAtlasPath, figureColor, brainColor, patchAlphaValue)
if nargin < 2 || isempty(figureColor)
figureColor = 'w';
end
if nargin < 3 || isempty(brainColor)
brainColor = [0.6, 0.6, 0.6];
end
if nargin < 3 || isempty(patchAlphaValue)
patchAlphaValue = 0.1;
end
av = readNPY([allenAtlasPath, filesep, 'annotation_volume_10um_by_index.npy']);
st = ya_loadStructureTree([allenAtlasPath, filesep, 'structure_tree_safe_2017.csv']);
slice_spacing = 10;
currFig = figure('Color', figureColor);
brain = find(strcmp(st.acronym, 'root'));
structure_3d = isosurface(permute(av(1:slice_spacing:end, ...
1:slice_spacing:end, 1:slice_spacing:end) == brain, [3, 1, 2]), 0);
patchHandle = patch('Vertices', structure_3d.vertices*slice_spacing, ...
'Faces', structure_3d.faces, ...
'FaceColor', brainColor, 'EdgeColor', 'none', 'FaceAlpha', patchAlphaValue);
set(gca, 'ZDir', 'reverse')
axis(gca, 'equal');
axis(gca, 'vis3d');
axis(gca, 'off');
camlight;
hold on;
end