PageRenderTime 30ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/FSB/dev/fsb_functional_map.m

https://code.google.com/
MATLAB | 919 lines | 407 code | 144 blank | 368 comment | 28 complexity | 39ef4af6e4f307723885de4adf9d7bc3 MD5 | raw file
Possible License(s): GPL-2.0, BSD-2-Clause
  1. function fsb_functional_map(idat,inparg,sandbox)
  2. % FSB: Draw a functional map into separate figure
  3. %
  4. % EXAMPLE:
  5. % fsb_functional_map(idat,inparg)
  6. %
  7. % INPUT:
  8. % idat: 3D image data
  9. % inparg: input argument struct with fields
  10. % inparg.newmap: Should a new figure be drawn (1)
  11. % inparg.map_txt: Title of figure
  12. % inparg.nscal: Should the image be scaled (1)
  13. % inparg.hoverlay: High resolution overlay (1)
  14. % inparg.calcorr: Should maps be shown (1)
  15. % inparg.corparam: Correlation threshold
  16. % inparg.probparam: Probability threshold
  17. % inparg.rc : Which map should be shown?
  18. % correlation (1)
  19. % probability (0)
  20. %
  21. %
  22. % OUTPUT:
  23. % functional map overlaid on structural/diagnostical images
  24. %
  25. % CALLED BY:
  26. % fsb_diag.m
  27. %
  28. % NOTES:
  29. % in development, needs to be better cleaned and commented
  30. % inparg and Map structs are overlapping
  31. % Updated 091110:
  32. % Image intensities and slices can now be selected with sliders
  33. %
  34. % Copyright 2010 MPI for Biological Cybernetics
  35. % Author: Steffen Stoewer
  36. % License:GNU GPL, no express or implied warranties
  37. %
  38. % $Revision 1.0
  39. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  40. if nargin<3;
  41. sandbox = [];
  42. end
  43. %~~~~~~~~~~~~~~~~~~
  44. % initate variables
  45. %~~~~~~~~~~~~~~~~~~
  46. % try
  47. % inparg.alpha_value = 0.5;
  48. % inparg.thr_high2 = inparg.thr_high*2;
  49. % catch
  50. % inparg.thr_high2 = max(idat(:))*2;
  51. % inparg.thr_high = max(idat(:));
  52. % inparg.alpha_value = 0.5;
  53. % end
  54. idat2 = idat;
  55. if ~isfield(inparg,'slicemin')
  56. inparg.slicemin = 1;
  57. inparg.slice_low = inparg.slicemin;
  58. end
  59. if ~isfield(inparg,'slicemax')
  60. inparg.slicemax = size(idat,3);
  61. inparg.slice_high = inparg.slicemax;
  62. end
  63. if ~isfield(inparg,'thr_high')
  64. if inparg.hoverlay==1;
  65. inparg.thr_high = round(nanmax(inparg.hidat(:)));
  66. else
  67. inparg.thr_high = round(nanmax(idat(:)));
  68. end
  69. end
  70. inparg.alpha_value = 0.5;
  71. inparg.thr_high2 = inparg.thr_high*2;
  72. if ~isfield(inparg,'thr_low')
  73. if inparg.hoverlay==1;
  74. inparg.thr_low = round(nanmin(inparg.hidat(:)));
  75. else
  76. inparg.thr_low = round(nanmin(idat(:)));
  77. end
  78. end
  79. if inparg.maptypenum ==4 || inparg.maptypenum == 5
  80. if ~isfield(inparg,'noiseplot');
  81. inparg.noiseplot = [7 7 size(idat,3)];
  82. inparg.noise_origin = [3 3];
  83. inparg.hnoise = 4;
  84. end
  85. % if size(idat,1)>3
  86. % idat = mean(idat,4);
  87. % end
  88. noise = single(inparg.idat(inparg.noise(1):inparg.noise(2),inparg.noise(3):inparg.noise(4),end-3:end,:)); % Left to do: take only higher slices
  89. noise = noise(:);
  90. disp(['noise size = ' num2str(size(noise,1)) ' voxel']);
  91. inparg.noisemean = round(nanmean(noise*100))/100;
  92. inparg.noisemax = round(nanmax(noise*100))/100;
  93. inparg.noisestd = round(nanstd(noise*100))/100;
  94. end
  95. if ~isfield(inparg,'colormap');
  96. inparg.colormap = 1;
  97. end
  98. if ~isfield(inparg,'rot_slice');
  99. inparg.rot_slice = 0;
  100. end
  101. % figure(302);
  102. % plot(noise);
  103. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  104. % Check for screen size
  105. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  106. scrsz = get(0,'ScreenSize');
  107. if inparg.newmap == 1;
  108. slicemap = figure;
  109. % set(slicemap,'Name','Activation Map','Position',[10 80 scrsz(3)-20 scrsz(4)-160] );
  110. set(slicemap,'Name',inparg.map_txt,'Position',[10 80 scrsz(3)-20 scrsz(4)-160] );
  111. else
  112. slicemap = figure(103);
  113. set(slicemap,'Name',inparg.map_txt);
  114. end
  115. clf;
  116. %~~~~~~~~~~~~~~~~~~
  117. % Initiate Figure
  118. %~~~~~~~~~~~~~~~~~~
  119. slider_GUI = figure(301);
  120. figure(slider_GUI); clf;
  121. set(slider_GUI,'Position',[150,150,270,330],...
  122. 'Resize','off','Toolbar','none','MenuBar','none',...
  123. 'NumberTitle','off','Name','Display slices toolbox');
  124. %~~~~~~~~~~~~~~~~~~
  125. % Noise area
  126. %~~~~~~~~~~~~~~~~~~
  127. h_noise = uibuttongroup('visible','off','Position',[0.01 0.75 0.99 .25]);
  128. u1 = uicontrol('Style','Radio','String','Area 1',...
  129. 'pos',[5 30 100 30],'parent',h_noise,'HandleVisibility','off');
  130. u2 = uicontrol('Style','Radio','String','Area 2',...
  131. 'pos',[5 1 100 30],'parent',h_noise,'HandleVisibility','off');
  132. u3 = uicontrol('Style','Radio','String','Area 3',...
  133. 'pos',[100 30 100 30],'parent',h_noise,'HandleVisibility','off');
  134. u4 = uicontrol('Style','Radio','String','Area 4',...
  135. 'pos',[100 1 100 30],'parent',h_noise,'HandleVisibility','off');
  136. u5 = uicontrol('Style','Radio','String','Area 5',...
  137. 'pos',[200 30 100 30],'parent',h_noise,'HandleVisibility','off');
  138. u6 = uicontrol('Style','Radio','String','None',...
  139. 'pos',[200 1 100 30],'parent',h_noise,'HandleVisibility','off');
  140. set(h_noise,'SelectionChangeFcn',@noise_area_Callback);
  141. temp_selob = eval(['u' num2str(inparg.hnoise)]);
  142. set(h_noise,'SelectedObject',temp_selob);
  143. set(h_noise,'Visible','off');
  144. rot_slice = uicontrol('Style','checkbox',...
  145. 'String','Rotate',...
  146. 'Position',[5,230,60,15],...
  147. 'Callback',{@rotate_Callback});
  148. %~~~~~~~~~~~~~~~~~~
  149. % Show Noise values
  150. %~~~~~~~~~~~~~~~~~~
  151. if inparg.hnoise<6
  152. uicontrol('Style','text',...
  153. 'String','Noise AVG',...
  154. 'Position',[5,210,60,15]);
  155. uicontrol('Style','text',...
  156. 'String',num2str(inparg.noisemean),...
  157. 'Position',[75,210,40,15]);
  158. uicontrol('Style','text',...
  159. 'String','SD',...
  160. 'Position',[115,210,30,15]);
  161. uicontrol('Style','text',...
  162. 'String',num2str(inparg.noisestd),...
  163. 'Position',[145,210,40,15]);
  164. uicontrol('Style','text',...
  165. 'String','Max',...
  166. 'Position',[185,210,30,15]);
  167. uicontrol('Style','text',...
  168. 'String',num2str(inparg.noisemax),...
  169. 'Position',[220,210,30,15]);
  170. end
  171. %~~~~~~~~~~~~~~~~~~~~
  172. % Overlay menu
  173. %~~~~~~~~~~~~~~~~~~~~
  174. h_pred_text = uicontrol('Style','text',...
  175. 'String','Predictor',...
  176. 'Position',[70,230,50,15]);
  177. h_pred = uicontrol('Style','Edit',...
  178. 'Position',[120,230,30,15],...
  179. 'String',num2str(inparg.hrf_pred),...
  180. 'TooltipString','Edit and preview high threshold',...
  181. 'Callback',{@edit_predictor_Callback});
  182. text_threshold = uicontrol('Style','text','String','Threshold : ',...
  183. 'Position',[160,230,60,13]);
  184. h_threshold = uicontrol('Style','edit','String',num2str(inparg.corparam),...
  185. 'Position',[220,230,40,13],...
  186. 'TooltipString','Select map threshold',...
  187. 'Callback',{@Map_threshold_edit_Callback});
  188. text_tsfx = uicontrol('Style','text',...
  189. 'String','Scale x',...
  190. 'Position',[5,160,35,15]);
  191. h_tsfx = uicontrol('Style','Edit',...
  192. 'Position',[40,160,30,15],...
  193. 'String',num2str(inparg.tsfx),...
  194. 'TooltipString','Edit and preview high threshold',...
  195. 'Callback',{@edit_overlay_Callback});
  196. text_tsfy = uicontrol('Style','text',...
  197. 'String','Scale y',...
  198. 'Position',[70,160,35,15]);
  199. h_tsfy = uicontrol('Style','Edit',...
  200. 'Position',[105,160,30,15],...
  201. 'String',num2str(inparg.tsfy),...
  202. 'TooltipString','Edit and preview high threshold',...
  203. 'Callback',{@edit_overlay_Callback});
  204. text_shiftx = uicontrol('Style','text',...
  205. 'String','Shift x',...
  206. 'Position',[135,160,35,15]);
  207. h_shiftx = uicontrol('Style','Edit',...
  208. 'Position',[170,160,30,15],...
  209. 'String',num2str(inparg.shiftx),...
  210. 'TooltipString','Edit and preview high threshold',...
  211. 'Callback',{@edit_overlay_Callback});
  212. text_shifty = uicontrol('Style','text',...
  213. 'String','Shift y',...
  214. 'Position',[200,160,30,15]);
  215. h_shifty = uicontrol('Style','Edit',...
  216. 'Position',[235,160,30,15],...
  217. 'String',num2str(inparg.shifty),...
  218. 'TooltipString','Edit and preview high threshold',...
  219. 'Callback',{@edit_overlay_Callback});
  220. %~~~~~~~~~~~~~~~~~~~~
  221. % Rayleigh menu
  222. %~~~~~~~~~~~~~~~~~~~~
  223. h_rayleigh = uicontrol('Style','Radiobutton','String','Rayleigh',...
  224. 'Position',[5,185,70,15],...
  225. 'TooltipString','Do Rayleigh correction for SNR maps',...
  226. 'Callback',{@rayleigh_correction_Callback});
  227. %~~~~~~~~~~~~~~~~~~~~
  228. % Color menu
  229. %~~~~~~~~~~~~~~~~~~~~
  230. % uicontrol('Style','text','String','Color',...
  231. % 'Position',[1,137,50,15]);
  232. uicontrol('Style','popupmenu',...
  233. 'String',{'Gray','Hot','Jet','HSV','Cool','Lines','Copper','Flag','Prism','Bone'},...
  234. 'Position',[90,180,50,25],...
  235. 'Value',inparg.colormap,...
  236. 'TooltipString','Select a color scheme for display',...
  237. 'Callback',{@Colormap_Selection_Callback});
  238. %~~~~~~~~~~~~~~~~~~
  239. % Replicate diagnostics here
  240. %~~~~~~~~~~~~~~~~~~
  241. uicontrol('Style','popupmenu',...
  242. 'String',{'Scaninfo','Plot slices','Voxel Time Course','SNR Map',...
  243. 'ROI SNR Map','CV Map','TN Map','STD Map','Z-score Map','Special Map',...
  244. 'AB Map','Ghost Map','Noise Time Course','Sandmap'},...
  245. 'Value',inparg.maptypenum,...
  246. 'Position',[170,180,80,25],...
  247. 'TooltipString','Select diagnostic method here',...
  248. 'Callback',{@Slice_Display_Callback});
  249. %~~~~~~~~~~~~~~~~~~
  250. % Sliders
  251. %~~~~~~~~~~~~~~~~~~
  252. uicontrol('Style','Text','String','Map Transparency',...
  253. 'Position',[5,140,250,15]);
  254. h_adjust_alpha = uicontrol('Style','Slider',...
  255. 'Position',[5,125,250,15],...
  256. 'Min',0,'Max',1,'Value',inparg.alpha_value,...
  257. 'SliderStep',[0.01 0.1],...
  258. 'TooltipString','Select and preview transparency',...
  259. 'Callback',{@adjust_slice_Callback});
  260. uicontrol('Style','Text','String','Slice Low',...
  261. 'Position',[5,80,250,15]);
  262. uicontrol('Style','Text','String','Slice High',...
  263. 'Position',[5,110,250,15]);
  264. h_adjust_lim_slice_low = uicontrol('Style','Slider',...
  265. 'Position',[5,65,200,15],...
  266. 'Min',inparg.slice_low,'Max',inparg.slice_high,'Value',inparg.slice_low,...
  267. 'SliderStep',[0.01 0.1],...
  268. 'TooltipString','Select and preview low threshold',...
  269. 'Callback',{@adjust_slice_Callback});
  270. h_adjust_lim_slicenum_low = uicontrol('Style','Edit',...
  271. 'Position',[205,65,50,15],...
  272. 'String',num2str(inparg.slice_low),...
  273. 'TooltipString','Edit and preview high threshold',...
  274. 'Callback',{@edit_lim_Callback});
  275. h_adjust_lim_slice_high = uicontrol('Style','Slider',...
  276. 'Position',[5,95,200,15],...
  277. 'Min',inparg.slice_low,'Max',inparg.slice_high,'Value',inparg.slice_high,...
  278. 'SliderStep',[0.01 0.1],...
  279. 'TooltipString','Select and preview high threshold',...
  280. 'Callback',{@adjust_slice_Callback});
  281. h_adjust_lim_slicenum_high = uicontrol('Style','Edit',...
  282. 'Position',[205,95,50,15],...
  283. 'String',num2str(inparg.slice_high),...
  284. 'TooltipString','Edit and preview high threshold',...
  285. 'Callback',{@edit_lim_Callback});
  286. uicontrol('Style','Text','String','Low',...
  287. 'Position',[5,20,250,15]);
  288. uicontrol('Style','Text','String','High',...
  289. 'Position',[5,50,250,15]);
  290. h_adjust_lim_slid_low = uicontrol('Style','Slider',...
  291. 'Position',[5,5,200,15],...
  292. 'Min',inparg.thr_low,'Max',inparg.thr_high,'Value',inparg.thr_low,...
  293. 'SliderStep',[0.01 0.1],...
  294. 'TooltipString','Select and preview low threshold',...
  295. 'Callback',{@adjust_slice_Callback});
  296. h_adjust_lim_num_low = uicontrol('Style','Edit',...
  297. 'Position',[205,5,50,15],...
  298. 'String',num2str(inparg.thr_low),...
  299. 'TooltipString','Edit and preview high threshold',...
  300. 'Callback',{@edit_lim_Callback});
  301. h_adjust_lim_slid_high = uicontrol('Style','Slider',...
  302. 'Position',[5,35,200,15],...
  303. 'Min',inparg.thr_low,'Max',inparg.thr_high2,'Value',inparg.thr_high,...
  304. 'SliderStep',[0.01 0.1],...
  305. 'TooltipString','Select and preview high threshold',...
  306. 'Callback',{@adjust_slice_Callback});
  307. h_adjust_lim_num_high = uicontrol('Style','Edit',...
  308. 'Position',[205,35,50,15],...
  309. 'String',num2str(inparg.thr_high),...
  310. 'TooltipString','Edit and preview high threshold',...
  311. 'Callback',{@edit_lim_Callback});
  312. figure(103);
  313. display_image(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg);
  314. %fsb_map_browser(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg);
  315. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  316. % Subfunctions
  317. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  318. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  319. % Main plotting function
  320. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  321. function display_image(idat,thr_low,thr_high,inparg)
  322. if inparg.hoverlay == 1;
  323. set(h_tsfx,'Visible','on')
  324. set(h_tsfy,'Visible','on')
  325. set(h_shiftx,'Visible','on')
  326. set(h_shifty,'Visible','on')
  327. set(text_tsfx,'Visible','on')
  328. set(text_tsfy,'Visible','on')
  329. set(text_shiftx,'Visible','on')
  330. set(text_shifty,'Visible','on')
  331. else
  332. set(h_tsfx,'Visible','off')
  333. set(h_tsfy,'Visible','off')
  334. set(h_shiftx,'Visible','off')
  335. set(h_shifty,'Visible','off')
  336. set(text_tsfx,'Visible','off')
  337. set(text_tsfy,'Visible','off')
  338. set(text_shiftx,'Visible','off')
  339. set(text_shifty,'Visible','off')
  340. end
  341. if inparg.maptypenum == 4
  342. set(h_noise,'Visible','on');
  343. else
  344. set(h_noise,'Visible','off');
  345. end
  346. if inparg.calcorr == 1;
  347. set(h_pred_text,'Visible','on');
  348. set(h_pred,'Visible','on')
  349. set(h_threshold,'Visible','on')
  350. set(text_threshold,'Visible','on')
  351. else
  352. set(h_pred_text,'Visible','off');
  353. set(h_pred,'Visible','off')
  354. set(h_threshold,'Visible','off')
  355. set(text_threshold,'Visible','off')
  356. end
  357. if inparg.rc == 99
  358. Map.rc=99;
  359. end
  360. fsb_map_browser(idat,thr_low,thr_high,inparg)
  361. end
  362. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  363. % Map threshold callback
  364. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  365. function Map_threshold_edit_Callback(source,eventdata)
  366. inparg.corparam = str2num(get(h_threshold,'string'));
  367. %corparams = sprintf('%1.4f',Map.corparam);
  368. % set(h_calcorrelation2_slid,'Value');
  369. % set(h_probability_slid,'String',probstring);
  370. disp([' Map threshold ' num2str(inparg.corparam) ]);
  371. display_image(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg)
  372. end
  373. %
  374. % % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  375. % % Check for number of slices
  376. % % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  377. %
  378. % figure(103); clf;
  379. % dim = size(idat);
  380. %
  381. % if size(dim,2)>2
  382. % nslices = dim(3);
  383. % else
  384. % nslices = 1;
  385. % end
  386. %
  387. % %~~~~~~~~~~~~~
  388. % % Calculate mean, std, min, max images for colormap
  389. % %~~~~~~~~~~~~~
  390. %
  391. % imean = mean(idat,4);
  392. % meanimage = mean(imean(:));
  393. % stdimage = std(imean(:));
  394. % minimage = min(imean(:));
  395. % maximage = meanimage+5*stdimage;
  396. % maximage2 = max(imean(:));
  397. %
  398. % if maximage2<maximage ;
  399. % maximage = maximage2;
  400. % end
  401. %
  402. % if inparg.nscal == 1
  403. % maximage = meanimage-0.5*meanimage;
  404. % end
  405. %
  406. % if thr_low==1 && thr_high==maximage2
  407. % clims = [minimage maximage];
  408. % else
  409. % clims = [thr_low thr_high];
  410. % end
  411. %
  412. % axis off;
  413. %
  414. % % ~~~~~~~~~~~~~~~~~~~~~~~~
  415. % % Figure out necessary size of plots
  416. % % ~~~~~~~~~~~~~~~~~~~~~~~~
  417. % size1 = ceil(sqrt(size(idat,3)));
  418. % size2 = round(sqrt(size(idat,3)));
  419. %
  420. % while nslices == size1*size2 % If it does not fit, use a bigger size
  421. % size2 = size2+1;
  422. % end
  423. %
  424. % % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  425. % % Go through slices and plot data
  426. % % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  427. % figure (slicemap);
  428. %
  429. % for x= 1:nslices+1;
  430. % h(x) = subplot(size1,size2,x);
  431. % cla;
  432. % end
  433. %
  434. % for x= 1:nslices
  435. %
  436. % p(x,:) = get(h(x), 'position');
  437. % set(h(x), 'position', [((p(x,1)-0.115)*1.2) ((p(x,2)-0.055)*1.085) (p(x,3)*1.4) (p(x,4)*1.3)]);
  438. %
  439. % if inparg.rot_slice == 0;
  440. % slicedata = idat(:,:,x);
  441. % else
  442. % slicedata = flipud(idat(:,:,x)');
  443. % end
  444. %
  445. % if inparg.hoverlay==1;
  446. % if inparg.rot_slice == 0;
  447. % slicedata = inparg.hidat(:,:,x);
  448. % else
  449. % slicedata = flipud(inparg.hidat(:,:,x)');
  450. % end
  451. % end
  452. %
  453. % subplot(h(x));
  454. % try
  455. % imagesc(slicedata,[thr_low thr_high]);
  456. % catch
  457. % disp('Image data only zeros, aborting...')
  458. % end
  459. % if inparg.maptypenum==4
  460. % %~~~~~~~~~~~~~~~~~~~~~~~
  461. % % Plot SNR Noise area
  462. % %~~~~~~~~~~~~~~~~~~~~~~~
  463. % set(h_noise,'Visible','on');
  464. % if ~isfield(inparg,'noisetd')
  465. % noisetd = [size(idat,3)-3 size(idat,3)];
  466. % else
  467. % noisetd = inparg.noisetd;
  468. % end
  469. %
  470. % if x>noisetd(1)&&x<=noisetd(2)
  471. % noiseborder = [inparg.noise(1),inparg.noise(3),inparg.noise(4)-inparg.noise(3),inparg.noise(2)-inparg.noise(1)];
  472. % noiseborder(noiseborder==0)=1;
  473. % %rectangle('Position',[inparg.noise_origin(1),inparg.noise_origin(2),inparg.noiseplot(1),inparg.noiseplot(2)],'EdgeColor','g');
  474. % rectangle('Position',noiseborder,'EdgeColor','g');
  475. % end
  476. % end
  477. % %~~~~~~~~~~~~~~~~~~~~~~~
  478. % % Plot slice number
  479. % %~~~~~~~~~~~~~~~~~~~~~~~
  480. %
  481. % hold on;
  482. % axis off;
  483. % axis xy;
  484. %
  485. % % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  486. % % Check if activation map needs to be overlaid
  487. % % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  488. % if inparg.calcorr ==1
  489. %
  490. % if inparg.rot_slice == 0;
  491. % Map.z = (squeeze(inparg.dummy(:,:,x,inparg.hrf_pred)));
  492. % else
  493. % Map.z = flipud(squeeze(inparg.dummy(:,:,x,inparg.hrf_pred)'));
  494. % end
  495. % Map.corparam = inparg.corparam;
  496. % Map.probparam = inparg.probparam;
  497. % Map.rc = inparg.rc;
  498. %
  499. % Map = fsb_colmap(Map);
  500. %
  501. % % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  502. % % Check if map needs to be overlaid on high-res brain
  503. % % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  504. % if inparg.hoverlay == 1;
  505. % set(h_tsfx,'Visible','on')
  506. % set(h_tsfy,'Visible','on')
  507. % set(h_shiftx,'Visible','on')
  508. % set(h_shifty,'Visible','on')
  509. % if inparg.rot_slice==0
  510. % Map.slice_data = inparg.slicez_data;
  511. % else
  512. % Map.slice_data = flipud(inparg.slicez_data');
  513. % end
  514. % Map.tsfx = inparg.tsfx;
  515. % Map.tsfy = inparg.tsfy;
  516. % Map.shiftx = inparg.shiftx;
  517. % Map.shifty = inparg.shifty;
  518. % Map = fsb_map_overlay(Map);
  519. %
  520. % else
  521. % set(h_tsfx,'Visible','off')
  522. % set(h_tsfy,'Visible','off')
  523. % set(h_shiftx,'Visible','off')
  524. % set(h_shifty,'Visible','off')
  525. % end
  526. % % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  527. % % Plot overlay
  528. % % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  529. % plot_z1 = image(Map.zm);
  530. % Map.tzi = single(Map.tzi)*inparg.alpha_value;
  531. % set (plot_z1,'AlphaData',Map.tzi);
  532. % hold off;
  533. %
  534. % if x>1;
  535. % subplot(h(x-1));
  536. %
  537. % end
  538. %
  539. % end
  540. % end
  541. %
  542. % % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  543. % % Plot color bars
  544. % % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  545. %
  546. % p(x+1,:) = get(h(x+1), 'position');
  547. % set(h(x+1), 'position', [((p(x+1,1)-0.115)*1.2) ((p(x+1,2)-0.055)*1.085) (p(x+1,3)*1.4) (p(x+1,4)*1.15)]);
  548. %
  549. % hold on;
  550. % subplot(h(x+1));
  551. %
  552. % imagesc(idat(:,:,1),clims);
  553. % colorbar('location','West');
  554. % axis off; cla;
  555. %
  556. % if inparg.calcorr ==1
  557. % h(x+1) = subplot(size1,size2,x+1);
  558. % p(x+1,:) = get(h(x+1), 'position');
  559. % set(h(x+1), 'position', [((p(x+1,1)-0.05)*1.2) ((p(x+1,2)-0.055)*1.085) (p(x+1,3)*0.12) (p(x+1,4)*1.3)]);
  560. % try
  561. % cm2 = flipud(Map.cm);
  562. % cm2 = repmat(cm2,[1 1 2]);
  563. % cm2 = permute(cm2,[1 3 2]);
  564. % image(cm2);
  565. % set(gca,'YTick',1:25:101);
  566. % set(gca,'YTickLabel',[1 0.5 0 -0.5 -1],'FontSize',10);
  567. % set(gca,'XTickLabel',' ');
  568. % catch
  569. % cla;
  570. % end
  571. % else
  572. % axis off; cla;
  573. % end
  574. %
  575. % % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  576. % % This is for simultaneous display of colorbars for the map and the
  577. % % underlying image - more work to be done
  578. % %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  579. %
  580. % % h(x+2) = subplot(size1,size2,x+2);
  581. % % p(x+2,:) = get(h(x+2), 'position');
  582. % % set(h(x+2), 'position', [((p(x+1,1)-0.115)*1.2) ((p(x+1,2)-0.055)*1.085) (p(x+1,3)*1.4) (p(x+1,4)*1.3)]);
  583. % % % hold on;
  584. % % imagesc(idat(:,:,1)',clims);
  585. % % colorbar;
  586. % % axis off; cla;
  587. %
  588. % %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  589. % % Plot additional information
  590. % %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  591. %
  592. % if x<19 && inparg.calcorr == 1
  593. % try
  594. % subplot(size1,size2,x+2); axis off;
  595. % text(0.2,0.9,'Map thresholds:');
  596. % text(0.2,0.7,inparg.corrstring);
  597. % text(0.2,0.5,inparg.probstring);
  598. % catch
  599. % disp(['Map thresholds:' inparg.corrstring inparg.probstring]);
  600. % end
  601. % end
  602. %
  603. % end
  604. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  605. % Rotation handling
  606. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  607. function rotate_Callback(source,eventdata)
  608. if (get(rot_slice,'Value') == get(rot_slice,'Max'))
  609. inparg.rot_slice = 1;
  610. else
  611. inparg.rot_slice = 0;
  612. end
  613. display_image(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg)
  614. %fsb_map_browser(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg)
  615. end
  616. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  617. % Colormap handling
  618. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  619. function Colormap_Selection_Callback(source,eventdata)
  620. str = get(source,'String');
  621. val = get(source,'Value');
  622. colormap(str{val});
  623. inparg.colormap = val;
  624. %figure(113); colormap(str{val});
  625. figure(103); colormap(str{val});
  626. end
  627. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  628. % Colormap handling
  629. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  630. function edit_predictor_Callback(source,eventdata)
  631. str = get(source,'String');
  632. %val = get(source,'Value');
  633. %inparg.hrf_pred = str(val);
  634. inparg.hrf_pred = str2double(str);
  635. display_image(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg)
  636. end
  637. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  638. % set thresholds
  639. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  640. function adjust_slice_Callback(source,eventdata)
  641. slicemax = floor(get(h_adjust_lim_slice_high,'Value'));
  642. slicemin = floor(get(h_adjust_lim_slice_low,'Value'));
  643. if slicemax<=slicemin
  644. slicemax = slicemin+1;
  645. end
  646. inparg.slicemax = slicemax;
  647. inparg.slicemin = slicemin;
  648. inparg.alpha_value = get(h_adjust_alpha,'Value');
  649. thr_high = floor(get(h_adjust_lim_slid_high,'Value'));
  650. thr_low = floor(get(h_adjust_lim_slid_low,'Value'));
  651. if thr_high<=thr_low
  652. thr_high = thr_low+1;
  653. end
  654. inparg.thr_high = thr_high;
  655. inparg.thr_low = thr_low;
  656. set(h_adjust_lim_num_high,'String',num2str(inparg.thr_high));
  657. set(h_adjust_lim_num_low,'String',num2str(inparg.thr_low));
  658. set(h_adjust_lim_slicenum_high,'String',num2str(inparg.slicemax));
  659. set(h_adjust_lim_slicenum_low,'String',num2str(inparg.slicemin));
  660. display_image(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg)
  661. %fsb_map_browser(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg)
  662. end
  663. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  664. % edit threshold manually
  665. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  666. function edit_lim_Callback(source,eventdata)
  667. thr_high = get(h_adjust_lim_num_high,'String');
  668. thr_low = get(h_adjust_lim_num_low,'String');
  669. slice_high = get(h_adjust_lim_slicenum_high,'String');
  670. slice_low = get(h_adjust_lim_slicenum_low,'String');
  671. inparg.thr_high = str2double(thr_high);
  672. inparg.thr_low = str2double(thr_low);
  673. inparg.slicemax = str2double(slice_high);
  674. inparg.slicemin = str2double(slice_low);
  675. set(h_adjust_lim_slid_high,'Value',inparg.thr_high);
  676. set(h_adjust_lim_slid_low,'Value',inparg.thr_low);
  677. set(h_adjust_lim_slice_high,'Value',inparg.slicemax);
  678. set(h_adjust_lim_slice_low,'Value',inparg.slicemin);
  679. display_image(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg)
  680. %fsb_map_browser(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg)
  681. end
  682. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  683. % Do rayleigh correction if desired
  684. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  685. function rayleigh_correction_Callback(source,eventdata)
  686. % added the 0.655 factor to account for Rayleigh distribution
  687. % 021110 see also
  688. % http://www.revisemri.com/questions/equip_qa/measuring_snr
  689. if (get(h_rayleigh,'Value') == get(h_rayleigh,'Max')) ;
  690. idat = 0.655.*idat2;
  691. else
  692. idat = idat2;
  693. end
  694. display_image(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg)
  695. %fsb_map_browser(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg)
  696. end
  697. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  698. % redefine noise area
  699. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  700. function noise_area_Callback(source,eventdata)
  701. str = get(h_noise, 'SelectedObject');
  702. noise_a = get(str,'String');
  703. noise_a = noise_a(end);
  704. noise_a = str2double(noise_a);
  705. switch noise_a
  706. case 1 % Noise area front left
  707. inparg.noiseplot = [10 10 size(idat,3)];
  708. inparg.noise_origin = [3 3];
  709. inparg.noise = [3 10 3 10];
  710. inparg.hnoise = 1;
  711. inparg.noisetd = [size(idat,3)-3 size(idat,3)];
  712. case 2 % Noise area back left
  713. inparg.noiseplot = [7 7 size(idat,3)];
  714. inparg.noise_origin = [size(idat,1)-10 3];
  715. inparg.noise = [size(idat,1)-10 size(idat,2)-3 3 10];
  716. inparg.hnoise = 2;
  717. inparg.noisetd = [size(idat,3)-3 size(idat,3)];
  718. case 3 % Noise area side
  719. inparg.noiseplot = [3 size(idat,2)-3];
  720. inparg.noise_origin = [3 3];
  721. inparg.noise = [3 size(idat,2)-3 3 3];
  722. inparg.hnoise = 3;
  723. inparg.noisetd = [size(idat,3)-3 size(idat,3)];
  724. case 4 % Noise area front
  725. inparg.noiseplot = [size(idat,2)-3 3];
  726. inparg.noise_origin = [3 3];
  727. inparg.noise = [3 3 3 size(idat,2)-3];
  728. inparg.hnoise = 4;
  729. inparg.noisetd = [size(idat,3)-3 size(idat,3)];
  730. case 5 % Noise area ROI
  731. inparg.hnoise = 5;
  732. inparg.noise_origin(1) = inparg.slice_n(2)-inparg.roi;
  733. inparg.noise_origin(2) = inparg.slice_n(1)-inparg.roi;
  734. inparg.noiseplot(1) = inparg.roi*2;
  735. inparg.noiseplot(2) = inparg.roi*2;
  736. inparg.noise = [inparg.slice_n(2)-inparg.roi inparg.slice_n(2)+inparg.roi inparg.slice_n(1)-inparg.roi inparg.slice_n(1)+inparg.roi];
  737. inparg.noisetd = [inparg.slice_n(3)-inparg.roi inparg.slice_n(3)+inparg.roi];
  738. case 6 % No noise area
  739. inparg.hnoise = 6;
  740. end
  741. fsb_diag(inparg.idat,inparg.imean,sandbox,inparg);
  742. %display_image(idat(:,:,slicemin:slicemax),thr_low,thr_high,inparg)
  743. end
  744. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  745. % Diagnostics
  746. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  747. function Slice_Display_Callback(source, eventdata)
  748. try
  749. str = get(source, 'String');
  750. val = get(source,'Value');
  751. inparg.maptype = str{val};
  752. Map.maptype = inparg.maptype;
  753. catch
  754. inparg.maptype = 'Plot slices';
  755. Map.maptype = inparg.maptype;
  756. end
  757. % reset threshold values
  758. inparg.maptype = Map.maptype;
  759. idat = inparg.idat;
  760. imean = inparg.imean;
  761. inparg = rmfield(inparg, 'slicemin');
  762. fsb_diag(idat,imean,sandbox,inparg);
  763. end
  764. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  765. % Edit overlay fit
  766. %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  767. function edit_overlay_Callback(source,eventdata)
  768. inparg.tsfx = str2num(get(h_tsfx,'String'));
  769. inparg.tsfy = str2num(get(h_tsfy,'String'));
  770. inparg.shiftx = str2num(get(h_shiftx,'String'));
  771. inparg.shifty = str2num(get(h_shifty,'String'));
  772. display_image(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg)
  773. %fsb_map_browser(idat(:,:,inparg.slicemin:inparg.slicemax),inparg.thr_low,inparg.thr_high,inparg)
  774. end
  775. end