-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbrainBlobBrowser.m
executable file
·550 lines (446 loc) · 23.2 KB
/
brainBlobBrowser.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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
% brainBlobBrowser() - Called by std_dipoleDensity(). Provides interactive
% environment to browse probabilistic dipole density.
% History
% 10/02/2018 Makoto. Modified. Unit = character, FontName = default. Initializes the cursor to the peak voxel when plotted.
% 03/06/2017 Makoto. Modified.
% 12/02/2014 Makoto and Luca. Created.
% Copyright (C) 2014, Makoto Miyakoshi and Luca Pion-Tonachini. SCCN,INC,UCSD
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
function varargout = brainBlobBrowser(varargin)
% BRAINBLOBBROWSER MATLAB code for brainBlobBrowser.fig
%
% Example:
% brainBlobBrowser('data', rand(91,109,91), 'color', 'red')
%
% Input:
% 'data' - input data. Size must be [91 109 91]
% 'color' - color scheme in plot. ['red'|'blue'|'green'|'magenta'|'blue-green'|'purple-green']
% 'mri' - mri data
%
% BRAINBLOBBROWSER, by itself, creates a new BRAINBLOBBROWSER or raises the existing
% singleton*.
%
% H = BRAINBLOBBROWSER returns the handle to a new BRAINBLOBBROWSER or the handle to
% the existing singleton*.
%
% BRAINBLOBBROWSER('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in BRAINBLOBBROWSER.M with the given input arguments.
%
% BRAINBLOBBROWSER('Property','Value',...) creates a new BRAINBLOBBROWSER or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before brainBlobBrowser_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to brainBlobBrowser_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help brainBlobBrowser
% Last Modified by GUIDE v2.5 06-Mar-2017 15:15:38
% Begin initialization code - DO NOT EDIT
gui_Singleton = 0;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @brainBlobBrowser_OpeningFcn, ...
'gui_OutputFcn', @brainBlobBrowser_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before brainBlobBrowser is made visible.
function brainBlobBrowser_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to brainBlobBrowser (see VARARGIN)
% this uses Christian's function
userInput = hlp_varargin2struct(varargin);
% add spm8 to the path
% addpath /data/projects/makoto/Tools/spm8
% check input
if ~isfield(userInput, 'data')
error('No input data provided.')
% disp(sprintf('\n\nNo input data.'));
% disp('SupraMarginal_L will be shown for demo. ')
% disp('The input data must be 91x109x91 of 2x2x2 voxels, ranges -88:92, -128:90, -74:108')
% % load AAL-segmented brain from nii (ComeOnJohnAshburner)
% tmpAAL = spm_vol('/data/projects/makoto/Tools/spm8/toolbox/wfu_pickatlas/MNI_atlas_templates/aal_MNI_V4.nii');
% Vols = zeros(numel(tmpAAL),1);
% for j=1:numel(tmpAAL),
% tot = 0;
% for i=1:tmpAAL(1).dim(3),
% img = spm_slice_vol(tmpAAL(j),spm_matrix([0 0 i]),tmpAAL(j).dim(1:2),0);
% pileimg(:,:,i) = img;
% end;
% end
% handles.cubeAAL = pileimg;
% handles.roiAAL = handles.cubeAAL==63; % SupraMarginal_L
% handles.inputData = smooth3(handles.roiAAL, 'gaussian', [7 7 7]);
else
if isequal(size(userInput.data),[91 109 91])
handles.inputData = userInput.data;
else
error('Invalid input data.')
end
end
if ~isfield(userInput, 'mri')
dipfitdefs;
load('-mat', template_models(1).mrifile); % load mri variable
else
if isequal(size(userInput.mri),[91 109 91])
mri = userInput.mri;
else
error('Invalid input data.')
end
end
% read MNI template header
% hdr = spm_read_hdr('/data/projects/makoto/Tools/spm8/canonical/single_subj_T1.nii');
handles.dimension = [91 109 91];
% handles.voxelSize = hdr.dime.pixdim(2:4);
% handles.origin = [0 0 0];% if any(handles.origin); error('Origin is not [0 0 0].'); end
% http://imaging.mrc-cbu.cam.ac.uk/imaging/FormatAnalyze
% Note that if the Origin is set to 0 0 0, then SPM routines will assume that the origin is in fact the central voxel of the image.
% handles.dimensionInMillimeter = [-(handles.dimension.*handles.voxelSize)/2; (handles.dimension.*handles.voxelSize)/2];
%handles.currentPointer = [46 64 37];
inputData1D = handles.inputData(:);
[~,maxIdx] = max(inputData1D);
[x,y,z] = ind2sub(size(handles.inputData), maxIdx);
handles.currentPointer = [x y z];
% Note that origine in voxel space is [46 64 37]
%set(handles.axialXSlider,'Value', 46)
set(handles.axialXSlider,'Value', x)
set(handles.axialXSlider,'Min', 1)
set(handles.axialXSlider,'Max', handles.dimension(1))
%set(handles.axialYSlider,'Value', 64)
set(handles.axialYSlider,'Value', y)
set(handles.axialYSlider,'Min', 1)
set(handles.axialYSlider,'Max', handles.dimension(2))
%set(handles.sagittalYSlider,'Value', 64)
set(handles.sagittalYSlider,'Value', y)
set(handles.sagittalYSlider,'Min', 1)
set(handles.sagittalYSlider,'Max', handles.dimension(2))
%set(handles.coronalZSlider,'Value', 37)
set(handles.coronalZSlider,'Value', z)
set(handles.coronalZSlider,'Min', 1)
set(handles.coronalZSlider,'Max', handles.dimension(3))
% load SPM single-subject T1 from nii (ComeOnJohnAshburner)
% tmpT1 = spm_vol('/data/projects/makoto/Tools/spm8/canonical/single_subj_T1.nii');
% V.mat - a 4x4 affine transformation matrix mapping from
% voxel coordinates to real world coordinates.
handles.affinMat = mri.transform; % don't forget to add the last '1' after the voxel coordinate!
% handles.affinMat = tmpT1.mat; % don't forget to add the last '1' after the voxel coordinate!
handles.affinMat(1,1) = handles.affinMat(1,1)*-1; % non-radiological convention
handles.affinMat(1,4) = handles.affinMat(1,4)*-1; % non-radiological convention
Vols = zeros(numel(mri),1);
for j=1:numel(mri),
tot = 0;
for i=1:mri(1).dim(3),
% img = spm_slice_vol(tmpT1(j),spm_matrix([0 0 i]),tmpT1(j).dim(1:2),0);
img = mri.anatomy(:,:,i);
pileimg(:,:,i) = img;
end;
end
handles.cubeT1 = pileimg;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Connect to anatomical info. %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Show report on the brainBlobBrowser GUI
currentPointerInRealWorld = handles.affinMat*[handles.currentPointer';1];
% Obtain non-zero value coordinate
[structures, probabilities] = std_dipoleDensity_eeg_lookup_talairach([currentPointerInRealWorld(1)*-1, currentPointerInRealWorld(2), currentPointerInRealWorld(3)], mean(userInput.clusterStd)*1);
% First, display in the comman window.
reportString = userInput.clusterReport;
reportString = sprintf([reportString 'Dipole Density Peak: [%2.0f %2.0f %2.0f]'], currentPointerInRealWorld(1)*-1, currentPointerInRealWorld(2), currentPointerInRealWorld(3));
reportString = sprintf([reportString '\n\nProbabilitic labels\n(confusion sphere diameter = mean SD):']);
for roiIdx = 1:length(structures)
reportString = sprintf([reportString '\n%s %0.3f'], structures{roiIdx}, probabilities(roiIdx));
end
disp(reportString)
% Second, display in the GUI.
if length(structures) <= 12
set(handles.clusterReportText, 'String', sprintf(reportString))
else
reportString = userInput.clusterReport;
reportString = sprintf([reportString 'Dipole Density Peak: [%2.0f %2.0f %2.0f]'], currentPointerInRealWorld(1)*-1, currentPointerInRealWorld(2), currentPointerInRealWorld(3));
reportString = sprintf([reportString '\n\nProbabilitic labels\n(confusion sphere diameter = mean SD):']);
for roiIdx = 1:10
reportString = sprintf([reportString '\n%s %0.3f'], structures{roiIdx}, probabilities(roiIdx));
end
reportString = sprintf([reportString '\n\nThe list is too long.\nSee the command window for the rest.']);
set(handles.clusterReportText, 'String', sprintf(reportString))
end
% define color map
if ~isfield(userInput,'color')
handles.cmap = colormap(jet(195-74));
handles.cmap(1,:) = 0;
disp(sprintf('\n\nNo color specified.'));
disp('Color scheme is jet.')
else
handles.cmap = colormap(hot(200));
handles.cmap = handles.cmap(75:195,:);
if strcmp(userInput.color, 'red')
disp('Color scheme is red.')
elseif strcmp(userInput.color, 'blue')
handles.cmap = handles.cmap(:, [3 2 1]);
disp('Color scheme is blue.')
elseif strcmp(userInput.color, 'green')
handles.cmap = handles.cmap(:, [2 1 3]);
disp('Color scheme is blue.')
elseif strcmp(userInput.color, 'magenta')
handles.cmap = handles.cmap(:, [1 3 2]);
disp('Color shceme is magenta')
elseif strcmp(userInput.color, 'blue-green')
handles.cmap = handles.cmap(:, [3 1 2]);
disp('Color shceme is blue-green')
elseif strcmp(userInput.color, 'purple-blue')
handles.cmap = handles.cmap(:, [2 3 1]);
disp('Color shceme is purple-blue')
else
error('Unsupported color.')
end
end
% Choose default command line output for brainBlobBrowser
handles.output = hObject;
% update data
handles = prepare_dens(handles);
handles.alpha = .4;
% update handles
guidata(hObject, handles);
% draw maps
drawAxial( hObject, eventdata, handles)
drawSagittal(hObject, eventdata, handles)
drawCoronal( hObject, eventdata, handles)
% Set color bar.
axes(handles.colorbarAxes)
colorbarMax = max(userInput.data(:));
colorbarData = [colorbarMax:-colorbarMax/127:0]';
imagesc(colorbarData)
yTicks = [0:length(colorbarData)/8:length(colorbarData)];
yTicks(1) = 1;
yTickLabels = round([colorbarMax:-colorbarMax/(length(yTicks)-1):0]*100000)/100000;
set(handles.colorbarAxes, 'XTick', [], 'YAxisLocation', 'right', 'YTick', yTicks, 'YTickLabel', yTickLabels)
% Clarify the ambibuity of color scale. 10/02/2018 Makoto.
set(get(handles.colorbarAxes, 'title'), 'string', sprintf('Probabilistic dipole density\n(per voxel)'),...
'HorizontalAlignment', 'left', 'Position', [0.5 -2 0], 'FontWeight', 'normal', 'FontName', 'default')
% Change the figure title on the top bar.
set(gcf, 'name', 'BrainiBlobBrowser--std_dipoleDensity()')
% draw colorbar
% colorbarHandle = colorbar(handles.sagittalAxes, 'EastOutside');
% set(colorbarHandle, 'Ticks', [])
% warning('off','MATLAB:colorbar:DeprecatedV6Argument');
% colormap(handles.cmap); % probably...
% set(handles.axes4, 'YTick', [1 200], 'YTickLabel', {'0' handles.maxdens})
% set(handles.axes4, 'YTick', [1 200], 'YTickLabel', {'1' num2str(userInput.normCoeff)})
% UIWAIT makes brainBlobBrowser wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = brainBlobBrowser_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function [handles maxdens] = prepare_dens(handles)
handles.maxdens = max(handles.inputData(:));
% ncolors = size(handles.cmap,1);
% handles.inputData(~handles.inputData) = nan;
%
% handles.inputData = round((handles.inputData)/(handles.maxdens)*(ncolors-1))+1; % project desnity image into the color space: [1:ncolors]
% handles.inputData( find(handles.inputData > ncolors) ) = ncolors;
% handles.inputData( find(handles.inputData < 1)) = 1; % added by Makoto
% % newprob3d = zeros(size(handles.inputData,1), size(handles.inputData,2), size(handles.inputData,3), 3);
%
% % outOfBrainMask = find(isnan(handles.inputData)); % place NaNs in a mask, NaNs are assumed for points outside the brain
% % handles.inputData(outOfBrainMask) = 1;
handles.inputData = handles.inputData./max(handles.inputData(:));
% handles.inputData(isnan(handles.inputData)) = 0;
% tmp = handles.cmap(handles.inputData,1); newprob3d(:,:,:,1) = reshape(tmp, size(handles.inputData));
% tmp = handles.cmap(handles.inputData,2); newprob3d(:,:,:,2) = reshape(tmp, size(handles.inputData));
% tmp = handles.cmap(handles.inputData,3); newprob3d(:,:,:,3) = reshape(tmp, size(handles.inputData));
% --- Executes on slider movement.
function axialYSlider_Callback(hObject, eventdata, handles)
% hObject handle to axialYSlider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.currentPointer(2) = round(get(hObject,'Value'));
set(handles.sagittalYSlider, 'Value', get(handles.axialYSlider,'Value'));
% update handles
guidata(hObject, handles);
drawCoronal( hObject, eventdata, handles)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function axialYSlider_CreateFcn(hObject, eventdata, handles)
% hObject handle to axialYSlider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on slider movement.
function axialXSlider_Callback(hObject, eventdata, handles)
% hObject handle to axialXSlider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.currentPointer(1) = round(get(hObject,'Value'));
% update handles
guidata(hObject, handles);
drawSagittal( hObject, eventdata, handles)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function axialXSlider_CreateFcn(hObject, eventdata, handles)
% hObject handle to axialXSlider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on slider movement.
function coronalZSlider_Callback(hObject, eventdata, handles)
% hObject handle to coronalZSlider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.currentPointer(3) = round(get(hObject,'Value'));
% update handles
guidata(hObject, handles);
drawAxial( hObject, eventdata, handles)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function coronalZSlider_CreateFcn(hObject, eventdata, handles)
% hObject handle to coronalZSlider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function drawAxial(hObject, eventdata, handles)
% Select the background brain MRI slice.
currentZ = handles.currentPointer(3);
tmpT1Slice = rot90(handles.cubeT1(:,:,currentZ)); % rotate to frontal-up
tmpT1SliceColor = repmat(tmpT1Slice, [1 1 3]);
axes(handles.axialAxes);
% Overlay the density blob.
inputDataSlice = squeeze(rot90(handles.inputData(:,:,currentZ)));
inputDataSlice_colorIdx = round(inputDataSlice*(195-75));
inputDataSlice_colorIdx(inputDataSlice_colorIdx==0)=1;
inputDataSliceR = reshape(handles.cmap(inputDataSlice_colorIdx,1), size(inputDataSlice_colorIdx));
inputDataSliceG = reshape(handles.cmap(inputDataSlice_colorIdx,2), size(inputDataSlice_colorIdx));
inputDataSliceB = reshape(handles.cmap(inputDataSlice_colorIdx,3), size(inputDataSlice_colorIdx));
inputDataSliceColor = cat(3, inputDataSliceR, inputDataSliceG, inputDataSliceB);
image(handles.alpha*inputDataSliceColor + (1 - handles.alpha)*tmpT1SliceColor);
set(gca,'XTickLabel', '', 'YTickLabel', '')
currentPointerInRealWorld = handles.affinMat*[handles.currentPointer';1];
set(handles.coordinateZText, 'String', num2str(currentPointerInRealWorld(3)), 'FontSize', 16);
drawCrossHair(hObject, eventdata, handles)
function drawSagittal(hObject, eventdata, handles)
% Select the background brain MRI slice.
currentX = handles.currentPointer(1);
tmpT1Slice = rot90(squeeze(handles.cubeT1(currentX,:,:))); % rotate to frontal-up
tmpT1SliceColor = repmat(tmpT1Slice, [1 1 3]);
axes(handles.sagittalAxes);
% Overlay the density blob.
inputDataSlice = rot90(squeeze(handles.inputData(currentX,:,:)));
inputDataSlice_colorIdx = round(inputDataSlice*(195-75));
inputDataSlice_colorIdx(inputDataSlice_colorIdx==0)=1;
inputDataSliceR = reshape(handles.cmap(inputDataSlice_colorIdx,1), size(inputDataSlice_colorIdx));
inputDataSliceG = reshape(handles.cmap(inputDataSlice_colorIdx,2), size(inputDataSlice_colorIdx));
inputDataSliceB = reshape(handles.cmap(inputDataSlice_colorIdx,3), size(inputDataSlice_colorIdx));
inputDataSliceColor = cat(3, inputDataSliceR, inputDataSliceG, inputDataSliceB);
inputDataSliceColor = cat(3, inputDataSliceR, inputDataSliceG, inputDataSliceB);
image(handles.alpha*inputDataSliceColor + (1 - handles.alpha)*tmpT1SliceColor);
set(gca,'XTickLabel', '', 'YTickLabel', '')
currentPointerInRealWorld = handles.affinMat*[handles.currentPointer';1];
set(handles.coordinateXText, 'String', num2str(currentPointerInRealWorld(1)*-1), 'FontSize', 16);
axes(handles.sagittalAxes);
% originalPosition = get(gca, 'position');
% colorbarHandle = colorbar;
% set(colorbarHandle, 'Box', 'off', 'YTick', [])
% set(gca, 'position', originalPosition)
drawCrossHair(hObject, eventdata, handles)
function drawCoronal(hObject, eventdata, handles)
% Select the background brain MRI slice.
currentY = handles.currentPointer(2);
tmpT1Slice = rot90(squeeze(handles.cubeT1(:,currentY,:))); % rotate to frontal-up
tmpT1SliceColor = repmat(tmpT1Slice, [1 1 3]);
axes(handles.coronalAxes);
% Overlay the density blob.
inputDataSlice = rot90(squeeze(handles.inputData(:,currentY,:)));
inputDataSlice_colorIdx = round(inputDataSlice*(195-75));
inputDataSlice_colorIdx(inputDataSlice_colorIdx==0)=1;
inputDataSliceR = reshape(handles.cmap(inputDataSlice_colorIdx,1), size(inputDataSlice_colorIdx));
inputDataSliceG = reshape(handles.cmap(inputDataSlice_colorIdx,2), size(inputDataSlice_colorIdx));
inputDataSliceB = reshape(handles.cmap(inputDataSlice_colorIdx,3), size(inputDataSlice_colorIdx));
inputDataSliceColor = cat(3, inputDataSliceR, inputDataSliceG, inputDataSliceB);
inputDataSliceColor = cat(3, inputDataSliceR, inputDataSliceG, inputDataSliceB);
image(handles.alpha*inputDataSliceColor + (1 - handles.alpha)*tmpT1SliceColor);
set(gca,'XTickLabel', '', 'YTickLabel', '')
currentPointerInRealWorld = handles.affinMat*[handles.currentPointer';1];
set(handles.coordinateYText, 'String', num2str(currentPointerInRealWorld(2)), 'FontSize', 16);
drawCrossHair(hObject, eventdata, handles)
% --- Executes on slider movement.
function sagittalYSlider_Callback(hObject, eventdata, handles)
% hObject handle to sagittalYSlider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.currentPointer(2) = round(get(hObject,'Value'));
set(handles.axialYSlider, 'Value', get(handles.sagittalYSlider,'Value'));
% update handles
guidata(hObject, handles);
drawCoronal( hObject, eventdata, handles)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function sagittalYSlider_CreateFcn(hObject, eventdata, handles)
% hObject handle to sagittalYSlider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function drawCrossHair(hObject, eventdata, handles)
lineHandles = findobj(gcf, 'Type', 'line');
delete(lineHandles);
axes(handles.coronalAxes)
hold on
line([handles.currentPointer(1) handles.currentPointer(1)], [0 handles.dimension(3)], 'color', [1 1 1]);
line([0 handles.dimension(1)], [handles.dimension(3)-handles.currentPointer(3) handles.dimension(3)-handles.currentPointer(3)], 'color', [1 1 1]);
hold off
axes(handles.axialAxes)
hold on
line([handles.currentPointer(1) handles.currentPointer(1)], [0 handles.dimension(2)], 'color', [1 1 1]);
line([0 handles.dimension(1)], [handles.dimension(2)-handles.currentPointer(2) handles.dimension(2)-handles.currentPointer(2)], 'color', [1 1 1]);
hold off
axes(handles.sagittalAxes)
hold on
line([handles.currentPointer(2) handles.currentPointer(2)], [0 handles.dimension(3)], 'color', [1 1 1]);
line([0 handles.dimension(2)], [handles.dimension(3)-handles.currentPointer(3) handles.dimension(3)-handles.currentPointer(3)], 'color', [1 1 1]);
hold off