@@ -40,13 +40,14 @@ function Needles_OpeningFcn(hobj, evt, h, varargin)
40
40
h.fcn.Update_Slices = @Update_Slices ;
41
41
h.fcn.Update_txt_electrodes = @Update_txt_electrodes ;
42
42
h.fcn.Update_Electrodes = @electrodes_update ;
43
- h.fcn.Load_Atlas = @menu_file_loadatlas_Callback ;
43
+ h.fcn.Load_Atlas = @load_atlas ;
44
44
% wrap-up and save in handles
45
45
guidata(hobj , h );
46
46
varargout{1 } = h .output ;
47
47
48
48
49
49
function load_atlas(h , atlas_label )
50
+ % possible labels: 'allen50', 'ibl50', 'dsurqe', 'waxholm'
50
51
cmap = ' bone' ;
51
52
switch true
52
53
case startsWith(atlas_label , ' ibl' )
@@ -96,7 +97,7 @@ case strcmp(atlas_label, 'dsurqe')
96
97
97
98
% Create all the objects depending on the contrast axes
98
99
h.im_phy = imagesc(bc .xscale , bc .zscale , D .atlas .vol_image(: ,: ,round(bc .y2i(0 ))), ' Parent' , h .axes_phy );
99
- set(h .axes_phy , ' DataAspectRatio' ,[1 1 1 ], ' NextPlot' , ' add' )
100
+ set(h .axes_phy , ' DataAspectRatio' ,[1 1 1 ], ' NextPlot' , ' add' , ' xdir ' , ' normal ' )
100
101
h.pl_phy_origin = plot(h .axes_phy , 0 ,0 , ' r+' );
101
102
h.pl_phy_xr = plot(h .axes_phy , [bc .xlim NaN 0 0 ], [0 0 NaN bc .ylim ], ' Color' , color_from_index(2 ));
102
103
h.pl_phy_zone = plot(h .axes_phy , NaN , 0 ,' .' ,' MarkerSize' ,4 ,' Color' ,color_from_index(5 ), ' ButtonDownFcn' , @pl_zone_ButtonDownFcn );
@@ -109,8 +110,8 @@ case strcmp(atlas_label, 'dsurqe')
109
110
xlabel(h .axes_phy , ' ML' ), ylabel(h .axes_phy , ' DV' )
110
111
colormap(h .axes_phy , cmap )
111
112
% Create all the objects depending on the label axes
112
- h.im_lab = imagesc(bc .xscale , bc .zscale , D .atlas .vol_labels(: ,: ,round(bc .y2i(0 ))), ' Parent' , h .axes_label );
113
- set(h .axes_label , ' DataAspectRatio' ,[1 1 1 ], ' NextPlot' , ' add' )
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 ' )
114
115
h.pl_lab_origin = plot(h .axes_label , 0 ,0 , ' r+' );
115
116
h.pl_lab_xr = plot(h .axes_label , [bc .xlim NaN 0 0 ], [0 0 NaN bc .ylim ], ' Color' , color_from_index(2 ));
116
117
h.pl_lab_zone = plot(h .axes_label , NaN , 0 ,' .' ,' MarkerSize' ,4 ,' Color' ,color_from_index(5 ), ' ButtonDownFcn' , @pl_zone_ButtonDownFcn );
@@ -126,7 +127,8 @@ case strcmp(atlas_label, 'dsurqe')
126
127
set([h .pl_phy_xr , h .pl_lab_xr , h .pl_phy_zone , h .pl_lab_zone ], ' Visible' , ' Off' )
127
128
set(h .fig_main ,' WindowButtonMotionFcn' , {@fig_main_WindowButtonMotionFcn , h })
128
129
% prevents from re-loading the Atlas for the time being
129
- 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' )
130
132
h.txt_top_apline = text(NaN , NaN , ' ' , ' Parent' , h .axes_top , ' Color' , color_from_index(2 ),' Fontsize' ,12 , ' Fontweight' , ' bold' );
131
133
guidata(h .fig_main , h )
132
134
setappdata(h .fig_main , ' Data' , D )
@@ -159,7 +161,6 @@ function pl_top_electrodes_ButtonDownFcn(hobj, evt, ie)
159
161
set( h .pl_top_current_elec ,' Visible' , ' on' ,...
160
162
' xdata' , D .E .dvmlap_entry(ie ,3 ), ' ydata' , D .E .dvmlap_entry(ie ,2 ))
161
163
drawnow
162
- % get(h.fig_main, 'SelectionType')
163
164
if false && ishandle(h .fig_table_elec )
164
165
get(h .table_elec )
165
166
jUIScrollPane = findjobj(h .table_elec );
@@ -171,11 +172,12 @@ function pl_top_electrodes_ButtonDownFcn(hobj, evt, ie)
171
172
try % FIXME test for other Atlases without cmap
172
173
% this will have to move to a method of Electrode Map
173
174
ie = ie(1 );
174
- f = findobj(' Name' , ' Trajectory' , ' type' , ' figure' );
175
+ f = findobj(' Name' , ' Trajectory' , ' type' , ' figure' , ' tag ' , ' fig_trajectory ' );
175
176
if isempty(f )
176
- f = figure(' Color' , ' w' , ' Position' , [200 , 100 , 380 , 900 ], ' name' , ' Trajectory' , ' menubar' , ' none' , ' toolbar' , ' none' );
177
- h_.ax1 = subplot(5 ,1 ,1 , ' parent' , f );
178
- h_.ax2 = subplot(5 ,1 ,[2 : 5 ], ' parent' , f );
177
+ f = figure(' Color' , ' w' , ' Position' , [200 , 100 , 380 , 900 ], ' name' , ' Trajectory' ,...
178
+ ' menubar' , ' none' , ' toolbar' , ' none' , ' numbertitle' , ' off' , ' tag' , ' fig_trajectory' );
179
+ h_.ax1 = subplot(5 , 1 , 1 , ' parent' , f );
180
+ h_.ax2 = subplot(5 , 1 , [2 : 5 ], ' parent' , f );
179
181
guidata(f , h_ );
180
182
else
181
183
h_ = guidata(f );
@@ -306,12 +308,13 @@ function Update_Labels(hobj, evt, ml_dv)
306
308
307
309
308
310
function Update_Slices(hobj , evt , ap )
311
+ NEAREST_DISTANCE_M = .00015 ;
309
312
D = getappdata(hobj , ' Data' );
310
313
h = guidata(hobj );
311
314
bc = D .atlas .brain_coor ;
312
315
% from the top axis handle line and associated text
313
316
set(h .pl_top_apline , ' Xdata' , ap([1 1 ]));
314
- ytxt = max(bc .xlim ) - diff(bc .xlim )* 0.05 ;
317
+ ytxt = max(bc .xlim ) - diff(bc .xlim ) * 0.05 ;
315
318
set(h .txt_top_apline , ' String' , num2str(ap(1 )*1e3 , ' %6.3f (mm) AP' ), ' Position' , [ap(1 ) ytxt 0 ])
316
319
ap_slice = round(bc .y2i( ap(1 )) );
317
320
% display the coronal slices on the physio and MRI axes
@@ -329,26 +332,16 @@ function Update_Slices(hobj, evt, ap)
329
332
end
330
333
% Find the electrodes from the closest coronal plane
331
334
[d , ie ] = min(abs(ap(1 ) - D .E .dvmlap_entry(: ,3 )));
332
- i1 = abs( D .E .dvmlap_entry(: ,3 ) - D .E .dvmlap_entry(ie ,3 )) < .0003 ;
335
+ i1 = abs( D .E .dvmlap_entry(: ,3 ) - D .E .dvmlap_entry(ie ,3 )) < NEAREST_DISTANCE_M ;
333
336
% Plot Electrodes
334
337
lineplot = @(xyz0 ,xyz1 ,n ) flatten([xyz0(: ,n ) xyz1(: ,n ) xyz1(: ,n ).*NaN ]' );
335
- % plot 10 degres insertions, active shank and full track
336
- % i1 = D.E.esel & ie & abs(D.E.theta) == 10*pi/180;
338
+
337
339
set([h .pl_phy_electrodes(1 ) h .pl_lab_electrodes(1 )],...
338
- ' xdata' , lineplot(D .E .dvmlap_entry (i1 , : ), D .E .dvmlap_tip (i1 , : ),2 ),...
339
- ' ydata' , lineplot(D .E .dvmlap_entry (i1 , : ), D .E .dvmlap_tip (i1 , : ),1 ))
340
+ ' xdata' , lineplot(D .E .site_lowest (i1 ), D .E .site_highest (i1 ),2 ),...
341
+ ' ydata' , lineplot(D .E .site_lowest (i1 ), D .E .site_highest (i1 ),1 ))
340
342
set([h .pl_phy_electrodes_traj(1 ) h .pl_lab_electrodes_traj(1 )],...
341
343
' xdata' , lineplot(D .E .dvmlap_entry(i1 ,: ), D .E .dvmlap_tip(i1 ,: ),2 ),...
342
344
' ydata' , lineplot(D .E .dvmlap_entry(i1 ,: ), D .E .dvmlap_tip(i1 ,: ),1 ))
343
- % plot 20 degres insertions, active shank and full track
344
- % i2 = D.E.esel & ie & abs(D.E.theta) == 20*pi/180;
345
- % set([h.pl_phy_electrodes(2) h.pl_lab_electrodes(2)],...
346
- % 'xdata', lineplot(D.E.xyz0(i2,:), D.E.xyz_(i2,:),1),...
347
- % 'ydata', lineplot(D.E.xyz0(i2,:), D.E.xyz_(i2,:),3))
348
- % set([h.pl_phy_electrodes_traj(2) h.pl_lab_electrodes_traj(2)],...
349
- % 'xdata', lineplot(D.E.xyz_entry(i2,:), D.E.xyz_exit(i2,:),1),...
350
- % 'ydata', lineplot(D.E.xyz_entry(i2,:), D.E.xyz_exit(i2,:),3))
351
-
352
345
353
346
function fig_main_KeyPressFcn(hobj , evt , h )
354
347
h = guidata(h .fig_main );
@@ -418,3 +411,37 @@ function menu_file_dsurqe_Callback(hobj, evt, h)
418
411
function menu_electrode_table_Callback(hobj , evt , h )
419
412
function menu_electrode_load_Callback(hobj , evt , h )
420
413
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