Skip to content

Commit 570c082

Browse files
committed
Change of ML direction. 3D display with electrodes.
1 parent ea5a4d6 commit 570c082

File tree

6 files changed

+322
-288
lines changed

6 files changed

+322
-288
lines changed

needles/@BrainAtlas/show.m

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
function h = show(self, h)
22
% display a 3D rendering of the brain
33

4-
5-
fv = isosurface(double(self.vol_labels) , 0.5);
4+
%%
5+
fv = isosurface(double(permute(self.vol_labels, [3, 2, 1])) , 0.5);
66
% in this case the volume is out in pixel unit, convert to SI
77
iorigin = self.brain_coor.iorigin;
8-
iorigin = iorigin([2 1 3]);
8+
iorigin = iorigin([2, 3, 1]);
99
fv.vertices = bsxfun( @minus, fv.vertices, iorigin);
1010
res = self.brain_coor.res;
11-
fv.vertices = fv.vertices.* res([2 1 3]);
11+
fv.vertices = fv.vertices.* res([2, 3, 1]);
1212

1313
if nargin <=1
14-
h.fig_volume = figure('Color','w'); h.ax = gca;
14+
h.fig_volume = figure('Color','w', 'name', ...
15+
'3D brain surface', 'numbertitle', 'off');
16+
h.ax = gca;
1517
end
1618
h.p = patch(fv);
17-
set(h.ax, 'DataAspectRatio',[1 1 1], 'zdir', 'reverse')
18-
xlabel(h.ax, 'x'), ylabel(h.ax, 'y'), zlabel(h.ax, 'z')
19+
set(h.ax, 'DataAspectRatio',[1 1 1], 'zdir', 'reverse', 'xdir', 'normal')
20+
xlabel(h.ax, 'ml'), ylabel(h.ax, 'ap'), zlabel(h.ax, 'dv')
1921
h.p.FaceColor = 'red';
2022
h.p.EdgeColor = 'none';
2123
h.p.FaceAlpha = 0.7;
22-
view([-5,-500,0]);
24+
view(-75, 45)
2325
camlight;
24-
26+
%%
2527
end
2628

needles/ElectrodeArray.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function removeAll(obj)
7373
% not enabled
7474

7575
% Z X Y is DV LR AP
76-
ELEC_LEN = 3.5e-3
76+
ELEC_LEN = 3.5e-3;
7777
a = sind(angles(2)); b = cosd(angles(2));
7878
vec = [a b 0];
7979

needles/Needles.fig

1 Byte
Binary file not shown.

needles/Needles.m

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ case strcmp(atlas_label, 'dsurqe')
8383
bc = D.atlas.brain_coor;
8484
% Create all the objects depending on the top axes
8585
h.im_top = imagesc(bc.yscale, bc.xscale, D.atlas.surf_top', 'Parent', h.axes_top);
86-
set(h.axes_top, 'ydir', 'normal','DataAspectRatio',[1 1 1], 'NextPlot', 'add')
86+
set(h.axes_top, 'ydir', 'reverse','DataAspectRatio',[1 1 1], 'NextPlot', 'add')
8787
set(h.axes_top,'UserData', round(bc.y2i(0))) % WIndow motion callback
8888
xlabel(h.axes_top, 'AP'), ylabel(h.axes_top, 'ML')
8989
colormap(h.axes_top, cmap);
@@ -97,7 +97,7 @@ case strcmp(atlas_label, 'dsurqe')
9797

9898
% Create all the objects depending on the contrast axes
9999
h.im_phy = imagesc(bc.xscale, bc.zscale, D.atlas.vol_image(:,:,round(bc.y2i(0))), 'Parent', h.axes_phy);
100-
set(h.axes_phy, 'DataAspectRatio',[1 1 1], 'NextPlot', 'add', 'xdir', 'reverse')
100+
set(h.axes_phy, 'DataAspectRatio',[1 1 1], 'NextPlot', 'add', 'xdir', 'normal')
101101
h.pl_phy_origin = plot(h.axes_phy, 0,0, 'r+');
102102
h.pl_phy_xr = plot(h.axes_phy, [bc.xlim NaN 0 0], [0 0 NaN bc.ylim], 'Color', color_from_index(2));
103103
h.pl_phy_zone = plot(h.axes_phy, NaN, 0,'.','MarkerSize',4,'Color',color_from_index(5), 'ButtonDownFcn', @pl_zone_ButtonDownFcn);
@@ -110,8 +110,8 @@ case strcmp(atlas_label, 'dsurqe')
110110
xlabel(h.axes_phy, 'ML'), ylabel(h.axes_phy, 'DV')
111111
colormap(h.axes_phy, cmap)
112112
% Create all the objects depending on the label axes
113-
h.im_lab = imagesc(bc.xscale, bc.zscale, D.atlas.vol_labels(:,:,round(bc.y2i(0))), 'Parent', h.axes_label);
114-
set(h.axes_label, 'DataAspectRatio',[1 1 1], 'NextPlot', 'add', 'xdir', 'reverse')
113+
h.im_lab = imagesc(-bc.xscale, bc.zscale, D.atlas.vol_labels(:,:,round(bc.y2i(0))), 'Parent', h.axes_label);
114+
set(h.axes_label, 'DataAspectRatio',[1 1 1], 'NextPlot', 'add', 'xdir', 'normal')
115115
h.pl_lab_origin = plot(h.axes_label, 0,0, 'r+');
116116
h.pl_lab_xr = plot(h.axes_label, [bc.xlim NaN 0 0], [0 0 NaN bc.ylim], 'Color', color_from_index(2));
117117
h.pl_lab_zone = plot(h.axes_label, NaN, 0,'.','MarkerSize',4,'Color',color_from_index(5), 'ButtonDownFcn', @pl_zone_ButtonDownFcn);
@@ -127,7 +127,8 @@ case strcmp(atlas_label, 'dsurqe')
127127
set([h.pl_phy_xr, h.pl_lab_xr, h.pl_phy_zone, h.pl_lab_zone], 'Visible', 'Off')
128128
set(h.fig_main,'WindowButtonMotionFcn', {@fig_main_WindowButtonMotionFcn, h})
129129
% prevents from re-loading the Atlas for the time being
130-
set([h.menu_file_allen50, h.menu_file_dsurqe], 'Enable', 'off')
130+
set(h.menu_file, 'Enable', 'off')
131+
set(h.menu_3d_plot, 'Enable', 'on')
131132
h.txt_top_apline = text(NaN, NaN, '', 'Parent', h.axes_top, 'Color', color_from_index(2),'Fontsize',12, 'Fontweight', 'bold');
132133
guidata(h.fig_main, h)
133134
setappdata(h.fig_main, 'Data', D)
@@ -410,3 +411,37 @@ function menu_file_dsurqe_Callback(hobj, evt, h)
410411
function menu_electrode_table_Callback(hobj, evt, h)
411412
function menu_electrode_load_Callback(hobj, evt, h)
412413
function menu_electrode_write_Callback(hobj, evt, h)
414+
415+
416+
% --------------------------------------------------------------------
417+
function menu_3d_plot_Callback(hobj, evt, h)
418+
h = guidata(h.fig_main);
419+
D = getappdata(h.fig_main, 'Data');
420+
421+
h3d = D.atlas.show();
422+
set(h3d.ax, 'NextPlot', 'add')
423+
pl3d = plot3(h3d.ax, D.E.dvmlap_entry(:,2), D.E.dvmlap_entry(:,3), D.E.dvmlap_entry(:,1), 'k*');
424+
set(h3d.p, 'FaceAlpha', 0.2)
425+
%% now display electrodes
426+
E = D.E;
427+
col = get(gca,'colororder');
428+
try delete(pl), end
429+
ie = find(E.pitch >= 0);
430+
high = E.site_highest(ie);
431+
low = E.site_lowest(ie);
432+
433+
pl(1) = plot3((flatten([high(:,2) low(:,2) ie.*NaN ]')) ,...
434+
(flatten([high(:,3) low(:,3) ie.*NaN ]')), ...
435+
(flatten([high(:,1) low(:,1) ie.*NaN ]')), ...
436+
'color', col(4,:), 'parent', h3d.ax);
437+
set(pl,'linewidth',1.5)
438+
439+
ie = find(E.pitch < 0);
440+
high = E.site_highest(ie);
441+
low = E.site_lowest(ie);
442+
443+
pl(2) = plot3((flatten([high(:,2) low(:,2) ie.*NaN ]')) ,...
444+
(flatten([high(:,3) low(:,3) ie.*NaN ]')), ...
445+
(flatten([high(:,1) low(:,1) ie.*NaN ]')), ...
446+
'color', col(5,:), 'parent', h3d.ax);
447+
set(pl,'linewidth',1.5)

0 commit comments

Comments
 (0)