PageRenderTime 33ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/ISCanalysis/ISCanalysis.m

http://isc-toolbox.googlecode.com/
MATLAB | 722 lines | 290 code | 155 blank | 277 comment | 39 complexity | 5be2863a57f94be6521c176fa124247c MD5 | raw file
Possible License(s): BSD-2-Clause
  1. function varargout = ISCanalysis(varargin)
  2. % ISCANALYSIS M-file for ISCanalysis.fig
  3. % ISCANALYSIS, by itself, creates a new ISCANALYSIS or raises the existing
  4. % singleton*.
  5. %
  6. % H = ISCANALYSIS returns the handle to a new ISCANALYSIS or the handle to
  7. % the existing singleton*.
  8. %
  9. % ISCANALYSIS('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in ISCANALYSIS.M with the given input arguments.
  11. %
  12. % ISCANALYSIS('Property','Value',...) creates a new ISCANALYSIS or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before ISCanalysis_OpeningFunction gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to ISCanalysis_OpeningFcn via varargin.
  17. %
  18. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  19. % instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22. % Edit the above text to modify the response to help ISCanalysis
  23. % Last Modified by GUIDE v2.5 01-Sep-2010 14:23:48
  24. % Begin initialization code - DO NOT EDIT
  25. gui_Singleton = 1;
  26. gui_State = struct('gui_Name', mfilename, ...
  27. 'gui_Singleton', gui_Singleton, ...
  28. 'gui_OpeningFcn', @ISCanalysis_OpeningFcn, ...
  29. 'gui_OutputFcn', @ISCanalysis_OutputFcn, ...
  30. 'gui_LayoutFcn', [] , ...
  31. 'gui_Callback', []);
  32. if nargin && ischar(varargin{1})
  33. gui_State.gui_Callback = str2func(varargin{1});
  34. end
  35. if nargout
  36. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  37. else
  38. gui_mainfcn(gui_State, varargin{:});
  39. end
  40. % End initialization code - DO NOT EDIT
  41. % --- Executes just before ISCanalysis is made visible.
  42. function ISCanalysis_OpeningFcn(hObject, eventdata, handles, varargin)
  43. % This function has no output args, see OutputFcn.
  44. % hObject handle to figure
  45. % eventdata reserved - to be defined in a future version of MATLAB
  46. % handles structure with handles and user data (see GUIDATA)
  47. % varargin command line arguments to ISCanalysis (see VARARGIN)
  48. % Choose default command line output for ISCanalysis
  49. handles.output = hObject;
  50. set(gcf,'CloseRequestFcn','ISCclosereq');
  51. handles = initISCanalysis(handles);
  52. handles = setParamFields(handles,handles.Pub);
  53. % Update handles structure
  54. guidata(hObject, handles);
  55. % UIWAIT makes ISCanalysis wait for user response (see UIRESUME)
  56. uiwait(handles.figure1);
  57. % --- Outputs from this function are returned to the command line.
  58. function varargout = ISCanalysis_OutputFcn(hObject, eventdata, handles)
  59. % varargout cell array for returning output args (see VARARGOUT);
  60. % hObject handle to figure
  61. % eventdata reserved - to be defined in a future version of MATLAB
  62. % handles structure with handles and user data (see GUIDATA)
  63. % Get default command line output from handles structure
  64. %varargout{1} = handles.output;
  65. if ~isempty(handles)
  66. varargout{1} = handles.output;
  67. delete(handles.figure1)
  68. end
  69. % --- Executes on button press in checkboxFreq.
  70. function checkboxFreq_Callback(hObject, eventdata, handles)
  71. % hObject handle to checkboxFreq (see GCBO)
  72. % eventdata reserved - to be defined in a future version of MATLAB
  73. % handles structure with handles and user data (see GUIDATA)
  74. % Hint: get(hObject,'Value') returns toggle state of checkboxFreq
  75. if get(hObject,'Value')
  76. set(handles.pushbuttonFreqSett,'Enable','on')
  77. set(handles.editBands,'Enable','on')
  78. set(handles.editTR,'Enable','on')
  79. set(handles.editFreqPerm,'Enable','on')
  80. handles.Pub.nrFreqBands = 3;
  81. else
  82. set(handles.pushbuttonFreqSett,'Enable','off')
  83. set(handles.editBands,'Enable','off')
  84. set(handles.editTR,'Enable','off')
  85. set(handles.editFreqPerm,'Enable','off')
  86. handles.Pub.nrFreqBands = 0;
  87. end
  88. set(handles.editBands,'String',handles.Pub.nrFreqBands)
  89. guidata(hObject, handles);
  90. % --- Executes on button press in checkboxTime.
  91. function checkboxTime_Callback(hObject, eventdata, handles)
  92. % hObject handle to checkboxTime (see GCBO)
  93. % eventdata reserved - to be defined in a future version of MATLAB
  94. % handles structure with handles and user data (see GUIDATA)
  95. if get(hObject,'Value')
  96. set(handles.editWinLen,'Enable','on')
  97. set(handles.editWinStep,'Enable','on')
  98. else
  99. set(handles.editWinLen,'Enable','off')
  100. set(handles.editWinStep,'Enable','off')
  101. end
  102. handles.Pub.winOn = get(hObject,'Value');
  103. guidata(hObject, handles);
  104. % Hint: get(hObject,'Value') returns toggle state of checkboxTime
  105. %set(hObject,'String', str2double(get(hObject,'String'))
  106. function editWinLen_Callback(hObject, eventdata, handles)
  107. % hObject handle to editWinLen (see GCBO)
  108. % eventdata reserved - to be defined in a future version of MATLAB
  109. % handles structure with handles and user data (see GUIDATA)
  110. % Hints: get(hObject,'String') returns contents of editWinLen as text
  111. % str2double(get(hObject,'String')) returns contents of editWinLen as a double
  112. val = ceil(str2double(get(hObject,'String')));
  113. if isnan(val) || val <= 0 || isinf(val)
  114. set(hObject,'String',num2str(handles.Pub.windowSize))
  115. else
  116. handles.Pub.windowSize = val;
  117. set(hObject,'String',num2str(val))
  118. end
  119. guidata(hObject, handles);
  120. % --- Executes during object creation, after setting all properties.
  121. function editWinLen_CreateFcn(hObject, eventdata, handles)
  122. % hObject handle to editWinLen (see GCBO)
  123. % eventdata reserved - to be defined in a future version of MATLAB
  124. % handles empty - handles not created until after all CreateFcns called
  125. % Hint: edit controls usually have a white background on Windows.
  126. % See ISPC and COMPUTER.
  127. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  128. set(hObject,'BackgroundColor','white');
  129. end
  130. function editWinStep_Callback(hObject, eventdata, handles)
  131. % hObject handle to editWinStep (see GCBO)
  132. % eventdata reserved - to be defined in a future version of MATLAB
  133. % handles structure with handles and user data (see GUIDATA)
  134. % Hints: get(hObject,'String') returns contents of editWinStep as text
  135. % str2double(get(hObject,'String')) returns contents of editWinStep as a double
  136. val = ceil(str2double(get(hObject,'String')));
  137. if isnan(val) || val <= 0 || isinf(val)
  138. set(hObject,'String',num2str(handles.Pub.windowStep))
  139. else
  140. handles.Pub.windowStep = val;
  141. set(hObject,'String',num2str(val))
  142. end
  143. guidata(hObject, handles);
  144. % --- Executes during object creation, after setting all properties.
  145. function editWinStep_CreateFcn(hObject, eventdata, handles)
  146. % hObject handle to editWinStep (see GCBO)
  147. % eventdata reserved - to be defined in a future version of MATLAB
  148. % handles empty - handles not created until after all CreateFcns called
  149. % Hint: edit controls usually have a white background on Windows.
  150. % See ISPC and COMPUTER.
  151. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  152. set(hObject,'BackgroundColor','white');
  153. end
  154. % --- Executes on button press in checkboxCor.
  155. function checkboxCor_Callback(hObject, eventdata, handles)
  156. % hObject handle to checkboxCor (see GCBO)
  157. % eventdata reserved - to be defined in a future version of MATLAB
  158. % handles structure with handles and user data (see GUIDATA)
  159. % Hint: get(hObject,'Value') returns toggle state of checkboxCor
  160. if get(hObject,'Value')
  161. set(handles.pushbuttonCorSett,'Enable','on')
  162. else
  163. set(handles.pushbuttonCorSett,'Enable','off')
  164. end
  165. handles.Pub.corOn = get(hObject,'Value');
  166. % handles.Pub.corOn = 1;
  167. % set(hObject,'Value',1);
  168. % set(handles.pushbuttonCorSett,'Enable','on')
  169. guidata(hObject, handles);
  170. % --- Executes on button press in checkboxKen.
  171. function checkboxKen_Callback(hObject, eventdata, handles)
  172. % hObject handle to checkboxKen (see GCBO)
  173. % eventdata reserved - to be defined in a future version of MATLAB
  174. % handles structure with handles and user data (see GUIDATA)
  175. % Hint: get(hObject,'Value') returns toggle state of checkboxKen
  176. handles.Pub.kenOn = get(hObject,'Value');
  177. guidata(hObject, handles);
  178. % --- Executes on button press in checkboxMI.
  179. function checkboxMI_Callback(hObject, eventdata, handles)
  180. % hObject handle to checkboxMI (see GCBO)
  181. % eventdata reserved - to be defined in a future version of MATLAB
  182. % handles structure with handles and user data (see GUIDATA)
  183. handles.Pub.nmiOn = get(hObject,'Value');
  184. guidata(hObject, handles);
  185. % Hint: get(hObject,'Value') returns toggle state of checkboxMI
  186. % --- Executes on button press in checkboxSSI.
  187. function checkboxSSI_Callback(hObject, eventdata, handles)
  188. % hObject handle to checkboxSSI (see GCBO)
  189. % eventdata reserved - to be defined in a future version of MATLAB
  190. % handles structure with handles and user data (see GUIDATA)
  191. % Hint: get(hObject,'Value') returns toggle state of checkboxSSI
  192. handles.Pub.ssiOn = get(hObject,'Value');
  193. guidata(hObject, handles);
  194. % --- Executes on button press in pushbuttonCorSett.
  195. function pushbuttonCorSett_Callback(hObject, eventdata, handles)
  196. % hObject handle to pushbuttonCorSett (see GCBO)
  197. % eventdata reserved - to be defined in a future version of MATLAB
  198. % handles structure with handles and user data (see GUIDATA)
  199. handles.Pub = corrSettings(handles.Pub);
  200. guidata(hObject, handles);
  201. function editTR_Callback(hObject, eventdata, handles)
  202. % hObject handle to editTR (see GCBO)
  203. % eventdata reserved - to be defined in a future version of MATLAB
  204. % handles structure with handles and user data (see GUIDATA)
  205. % Hints: get(hObject,'String') returns contents of editTR as text
  206. % str2double(get(hObject,'String')) returns contents of editTR as a double
  207. val = str2double(get(hObject,'String'));
  208. if isnan(val) || val <= 0
  209. set(hObject,'String',num2str(1/handles.Pub.samplingFrequency))
  210. else
  211. handles.Pub.handles.Pub.samplingFrequency = 1/val;
  212. set(hObject,'String',num2str(val))
  213. end
  214. guidata(hObject, handles);
  215. % --- Executes during object creation, after setting all properties.
  216. function editTR_CreateFcn(hObject, eventdata, handles)
  217. % hObject handle to editTR (see GCBO)
  218. % eventdata reserved - to be defined in a future version of MATLAB
  219. % handles empty - handles not created until after all CreateFcns called
  220. % Hint: edit controls usually have a white background on Windows.
  221. % See ISPC and COMPUTER.
  222. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  223. set(hObject,'BackgroundColor','white');
  224. end
  225. function editBands_Callback(hObject, eventdata, handles)
  226. % hObject handle to editBands (see GCBO)
  227. % eventdata reserved - to be defined in a future version of MATLAB
  228. % handles structure with handles and user data (see GUIDATA)
  229. % Hints: get(hObject,'String') returns contents of editBands as text
  230. % str2double(get(hObject,'String')) returns contents of editBands as a double
  231. val = ceil(str2double(get(hObject,'String')));
  232. if isnan(val) || val < 2 || val > 15
  233. set(hObject,'String',num2str(handles.Pub.nrFreqBands))
  234. else
  235. handles.Pub.nrFreqBands = val;
  236. checkLen(handles.Pub.nrFreqBands)
  237. set(hObject,'String',num2str(val))
  238. end
  239. guidata(hObject, handles);
  240. % --- Executes during object creation, after setting all properties.
  241. function editBands_CreateFcn(hObject, eventdata, handles)
  242. % hObject handle to editBands (see GCBO)
  243. % eventdata reserved - to be defined in a future version of MATLAB
  244. % handles empty - handles not created until after all CreateFcns called
  245. % Hint: edit controls usually have a white background on Windows.
  246. % See ISPC and COMPUTER.
  247. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  248. set(hObject,'BackgroundColor','white');
  249. end
  250. % --- Executes on button press in pushbuttonFreqSett.
  251. function pushbuttonFreqSett_Callback(hObject, eventdata, handles)
  252. % hObject handle to pushbuttonFreqSett (see GCBO)
  253. % eventdata reserved - to be defined in a future version of MATLAB
  254. % handles structure with handles and user data (see GUIDATA)
  255. handles.Pub = freqSettings(handles.Pub);
  256. guidata(hObject, handles);
  257. function editSubj_Callback(hObject, eventdata, handles)
  258. % hObject handle to editSubj (see GCBO)
  259. % eventdata reserved - to be defined in a future version of MATLAB
  260. % handles structure with handles and user data (see GUIDATA)
  261. % Hints: get(hObject,'String') returns contents of editSubj as text
  262. % str2double(get(hObject,'String')) returns contents of editSubj as a double
  263. handles = setSubjectBox(handles);
  264. handles = validateParams(handles,'subj');
  265. guidata(hObject, handles);
  266. % --- Executes during object creation, after setting all properties.
  267. function editSubj_CreateFcn(hObject, eventdata, handles)
  268. % hObject handle to editSubj (see GCBO)
  269. % eventdata reserved - to be defined in a future version of MATLAB
  270. % handles empty - handles not created until after all CreateFcns called
  271. % Hint: edit controls usually have a white background on Windows.
  272. % See ISPC and COMPUTER.
  273. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  274. set(hObject,'BackgroundColor','white');
  275. end
  276. function editDestin_Callback(hObject, eventdata, handles)
  277. % hObject handle to editDestin (see GCBO)
  278. % eventdata reserved - to be defined in a future version of MATLAB
  279. % handles structure with handles and user data (see GUIDATA)
  280. % Hints: get(hObject,'String') returns contents of editDestin as text
  281. % str2double(get(hObject,'String')) returns contents of editDestin as a double
  282. tPath = get(hObject,'String');
  283. handles.Pub.dataDestination = tPath;
  284. guidata(hObject, handles);
  285. % --- Executes during object creation, after setting all properties.
  286. function editDestin_CreateFcn(hObject, eventdata, handles)
  287. % hObject handle to editDestin (see GCBO)
  288. % eventdata reserved - to be defined in a future version of MATLAB
  289. % handles empty - handles not created until after all CreateFcns called
  290. % Hint: edit controls usually have a white background on Windows.
  291. % See ISPC and COMPUTER.
  292. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  293. set(hObject,'BackgroundColor','white');
  294. end
  295. function editTemplates_Callback(hObject, eventdata, handles)
  296. % % hObject handle to editTemplates (see GCBO)
  297. % % eventdata reserved - to be defined in a future version of MATLAB
  298. % % handles structure with handles and user data (see GUIDATA)
  299. %
  300. % % Hints: get(hObject,'String') returns contents of editTemplates as text
  301. % % str2double(get(hObject,'String')) returns contents of editTemplates as a double
  302. %
  303. % tPath = get(hObject,'String');
  304. % handles.Pub.atlasPath = tPath;
  305. % handles.Pub.maskPath = tPath;
  306. % handles = validateParams(handles,'template');
  307. % guidata(hObject, handles);
  308. % --- Executes during object creation, after setting all properties.
  309. function editTemplates_CreateFcn(hObject, eventdata, handles)
  310. % hObject handle to editTemplates (see GCBO)
  311. % eventdata reserved - to be defined in a future version of MATLAB
  312. % handles empty - handles not created until after all CreateFcns called
  313. % Hint: edit controls usually have a white background on Windows.
  314. % See ISPC and COMPUTER.
  315. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  316. set(hObject,'BackgroundColor','white');
  317. end
  318. function editProject_Callback(hObject, eventdata, handles)
  319. % hObject handle to editProject (see GCBO)
  320. % eventdata reserved - to be defined in a future version of MATLAB
  321. % handles structure with handles and user data (see GUIDATA)
  322. tPath = get(hObject,'String');
  323. handles.Pub.dataDescription = tPath;
  324. guidata(hObject, handles);
  325. % Hints: get(hObject,'String') returns contents of editProject as text
  326. % str2double(get(hObject,'String')) returns contents of editProject as a double
  327. % --- Executes during object creation, after setting all properties.
  328. function editProject_CreateFcn(hObject, eventdata, handles)
  329. % hObject handle to editProject (see GCBO)
  330. % eventdata reserved - to be defined in a future version of MATLAB
  331. % handles empty - handles not created until after all CreateFcns called
  332. % Hint: edit controls usually have a white background on Windows.
  333. % See ISPC and COMPUTER.
  334. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  335. set(hObject,'BackgroundColor','white');
  336. end
  337. % --- Executes on selection change in popupmenuSession.
  338. function popupmenuSession_Callback(hObject, eventdata, handles)
  339. % hObject handle to popupmenuSession (see GCBO)
  340. % eventdata reserved - to be defined in a future version of MATLAB
  341. % handles structure with handles and user data (see GUIDATA)
  342. % Hints: contents = get(hObject,'String') returns popupmenuSession contents as cell array
  343. % contents{get(hObject,'Value')} returns selected item from popupmenuSession
  344. val = get(hObject,'Value');
  345. if val <= size(handles.Pub.subjectSource,1)
  346. for h = 1:size(handles.Pub.subjectSource,2)
  347. D{h} = handles.Pub.subjectSource{val,h};
  348. end
  349. set(handles.editSubj,'String',D);
  350. else
  351. set(handles.editSubj,'String',{});
  352. end
  353. guidata(hObject, handles);
  354. % --- Executes during object creation, after setting all properties.
  355. function popupmenuSession_CreateFcn(hObject, eventdata, handles)
  356. % hObject handle to popupmenuSession (see GCBO)
  357. % eventdata reserved - to be defined in a future version of MATLAB
  358. % handles empty - handles not created until after all CreateFcns called
  359. % Hint: popupmenu controls usually have a white background on Windows.
  360. % See ISPC and COMPUTER.
  361. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  362. set(hObject,'BackgroundColor','white');
  363. end
  364. function editNii_Callback(hObject, eventdata, handles)
  365. % hObject handle to editNii (see GCBO)
  366. % eventdata reserved - to be defined in a future version of MATLAB
  367. % handles structure with handles and user data (see GUIDATA)
  368. % Hints: get(hObject,'String') returns contents of editNii as text
  369. % str2double(get(hObject,'String')) returns contents of editNii as a double
  370. % --- Executes during object creation, after setting all properties.
  371. function editNii_CreateFcn(hObject, eventdata, handles)
  372. % hObject handle to editNii (see GCBO)
  373. % eventdata reserved - to be defined in a future version of MATLAB
  374. % handles empty - handles not created until after all CreateFcns called
  375. % Hint: edit controls usually have a white background on Windows.
  376. % See ISPC and COMPUTER.
  377. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  378. set(hObject,'BackgroundColor','white');
  379. end
  380. % --- Executes on button press in pushbuttonRun.
  381. function pushbuttonRun_Callback(hObject, eventdata, handles)
  382. % hObject handle to pushbuttonRun (see GCBO)
  383. % eventdata reserved - to be defined in a future version of MATLAB
  384. % handles structure with handles and user data (see GUIDATA)
  385. handles.Params.PublicParams = handles.Pub;
  386. handles.Params.PrivateParams = handles.Priv;
  387. handles.validFlag = true;
  388. %handles.ParamsValid
  389. %handles.Params
  390. %isequal(handles.ParamsValid,handles.Params)
  391. if ~isequal(handles.ParamsValid,handles.Params)
  392. disp('You must succesfully validate parameters before running the analysis!')
  393. return
  394. end
  395. if handles.validFlag
  396. guidata(hObject, handles);
  397. runAnalysis(handles.Params);
  398. end
  399. % --- Executes on selection change in popupmenuFormat.
  400. function popupmenuFormat_Callback(hObject, eventdata, handles)
  401. % hObject handle to popupmenuFormat (see GCBO)
  402. % eventdata reserved - to be defined in a future version of MATLAB
  403. % handles structure with handles and user data (see GUIDATA)
  404. % Hints: contents = get(hObject,'String') returns popupmenuFormat contents as cell array
  405. % contents{get(hObject,'Value')} returns selected item from popupmenuFormat
  406. switch get(hObject,'Value')
  407. case 1
  408. handles.Pub.fileFormatSubj = 'nii';
  409. case 2
  410. handles.Pub.fileFormatSubj = 'mat';
  411. otherwise
  412. error('Unknown file format!')
  413. end
  414. guidata(hObject, handles);
  415. % --- Executes during object creation, after setting all properties.
  416. function popupmenuFormat_CreateFcn(hObject, eventdata, handles)
  417. % hObject handle to popupmenuFormat (see GCBO)
  418. % eventdata reserved - to be defined in a future version of MATLAB
  419. % handles empty - handles not created until after all CreateFcns called
  420. % Hint: popupmenu controls usually have a white background on Windows.
  421. % See ISPC and COMPUTER.
  422. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  423. set(hObject,'BackgroundColor','white');
  424. end
  425. function editFreqPerm_Callback(hObject, eventdata, handles)
  426. % hObject handle to editFreqPerm (see GCBO)
  427. % eventdata reserved - to be defined in a future version of MATLAB
  428. % handles structure with handles and user data (see GUIDATA)
  429. % Hints: get(hObject,'String') returns contents of editFreqPerm as text
  430. % str2double(get(hObject,'String')) returns contents of editFreqPerm as a double
  431. val = ceil(str2double(get(hObject,'String')));
  432. if isnan(val) || val <= 0 || isinf(val)
  433. set(hObject,'String',num2str(handles.Pub.nrPermutationsZPF))
  434. else
  435. handles.Pub.nrPermutationsZPF = val;
  436. set(hObject,'String',num2str(val))
  437. end
  438. guidata(hObject, handles);
  439. % --- Executes during object creation, after setting all properties.
  440. function editFreqPerm_CreateFcn(hObject, eventdata, handles)
  441. % hObject handle to editFreqPerm (see GCBO)
  442. % eventdata reserved - to be defined in a future version of MATLAB
  443. % handles empty - handles not created until after all CreateFcns called
  444. % Hint: edit controls usually have a white background on Windows.
  445. % See ISPC and COMPUTER.
  446. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  447. set(hObject,'BackgroundColor','white');
  448. end
  449. % --------------------------------------------------------------------
  450. function menuFile_Callback(hObject, eventdata, handles)
  451. % hObject handle to menuFile (see GCBO)
  452. % eventdata reserved - to be defined in a future version of MATLAB
  453. % handles structure with handles and user data (see GUIDATA)
  454. % --------------------------------------------------------------------
  455. function menuOpen_Callback(hObject, eventdata, handles)
  456. % hObject handle to menuOpen (see GCBO)
  457. % eventdata reserved - to be defined in a future version of MATLAB
  458. % handles structure with handles and user data (see GUIDATA)
  459. [FileName,PathName] = uigetfile('*.mat','Open Parameter File');
  460. if FileName ~= 0
  461. try
  462. load(fullfile(PathName,FileName))
  463. handles.Pub = Params.PublicParams;
  464. handles.Priv = Params.PrivateParams;
  465. handles = setParamFields(handles,handles.Pub);
  466. catch
  467. disp(lasterr)
  468. disp('Invalid parameter file.')
  469. return
  470. end
  471. end
  472. guidata(hObject, handles);
  473. % --------------------------------------------------------------------
  474. function menuSave_Callback(hObject, eventdata, handles)
  475. % hObject handle to menuSave (see GCBO)
  476. % eventdata reserved - to be defined in a future version of MATLAB
  477. % handles structure with handles and user data (see GUIDATA)
  478. [file,path] = uiputfile('*.mat','Save Parameter File');
  479. if file ~= 0
  480. Params.PublicParams = handles.Pub;
  481. Params.PrivateParams = handles.Priv;
  482. save(fullfile(path,file),'Params')
  483. end
  484. guidata(hObject, handles);
  485. % --------------------------------------------------------------------
  486. function menuExit_Callback(hObject, eventdata, handles)
  487. % hObject handle to menuExit (see GCBO)
  488. % eventdata reserved - to be defined in a future version of MATLAB
  489. % handles structure with handles and user data (see GUIDATA)
  490. user_response = confCloseModal('Title','Confirm Exit');
  491. switch lower(user_response)
  492. case 'no'
  493. % take no action
  494. case 'yes'
  495. handles.output = handles;
  496. guidata(hObject, handles)
  497. uiresume(handles.figure1)
  498. % delete(handles.figure1)
  499. end
  500. % --- Executes on button press in pushbuttonValid.
  501. function pushbuttonValid_Callback(hObject, eventdata, handles)
  502. % hObject handle to pushbuttonValid (see GCBO)
  503. % eventdata reserved - to be defined in a future version of MATLAB
  504. % handles structure with handles and user data (see GUIDATA)
  505. Params.PublicParams = handles.Pub;
  506. Params.PrivateParams = handles.Priv;
  507. if isfield(handles,'ParamsValid')
  508. if isequal(handles.ParamsValid,Params)
  509. disp(' ')
  510. disp('Parameters already succesfully validated!')
  511. return
  512. end
  513. end
  514. handles = validateDataAndParams(handles);
  515. if handles.validFlag
  516. guidata(hObject, handles);
  517. end
  518. % --- Executes on button press in checkboxTemplate.
  519. function checkboxTemplate_Callback(hObject, eventdata, handles)
  520. % hObject handle to checkboxTemplate (see GCBO)
  521. % eventdata reserved - to be defined in a future version of MATLAB
  522. % handles structure with handles and user data (see GUIDATA)
  523. if get(hObject,'Value')
  524. set(handles.radiobuttonTemplateMNI,'Value',1,'Enable','on')
  525. handles.Pub.useTemplate = 1;
  526. set(handles.editMask,'Enable','on','String',handles.Pub.atlasPath)
  527. % set(handles.editMask,'Enable','off','String','standard')
  528. set(handles.textMask,'Enable','on','String','Directory of standard templates','HorizontalAlignment','Left')
  529. else
  530. set(handles.radiobuttonTemplateMNI,'Value',0,'Enable','off')
  531. handles.Pub.useTemplate = 0;
  532. set(handles.editMask,'Enable','on','String',handles.Pub.atlasPath,'HorizontalAlignment','Left')
  533. set(handles.textMask,'Enable','on','String','Binary mask file name (extension .nii or .mat)')
  534. end
  535. guidata(hObject, handles);
  536. % --- Executes on button press in radiobuttonTemplateMNI.
  537. function radiobuttonTemplateMNI_Callback(hObject, eventdata, handles)
  538. % hObject handle to radiobuttonTemplateMNI (see GCBO)
  539. % eventdata reserved - to be defined in a future version of MATLAB
  540. % handles structure with handles and user data (see GUIDATA)
  541. set(hObject,'Value',1)
  542. % --- Executes on button press in checkboxPhase.
  543. function checkboxPhase_Callback(hObject, eventdata, handles)
  544. % hObject handle to checkboxPhase (see GCBO)
  545. % eventdata reserved - to be defined in a future version of MATLAB
  546. % handles structure with handles and user data (see GUIDATA)
  547. % Hint: get(hObject,'Value') returns toggle state of checkboxPhase
  548. handles.Pub.calcPhase = get(hObject,'Value');
  549. guidata(hObject, handles);
  550. function editMask_Callback(hObject, eventdata, handles)
  551. % hObject handle to editMask (see GCBO)
  552. % eventdata reserved - to be defined in a future version of MATLAB
  553. % handles structure with handles and user data (see GUIDATA)
  554. % Hints: get(hObject,'String') returns contents of editMask as text
  555. % str2double(get(hObject,'String')) returns contents of editMask as a double
  556. handles.Pub.atlasPath = get(hObject,'String');
  557. guidata(hObject, handles);
  558. % --- Executes during object creation, after setting all properties.
  559. function editMask_CreateFcn(hObject, eventdata, handles)
  560. % hObject handle to editMask (see GCBO)
  561. % eventdata reserved - to be defined in a future version of MATLAB
  562. % handles empty - handles not created until after all CreateFcns called
  563. % Hint: edit controls usually have a white background on Windows.
  564. % See ISPC and COMPUTER.
  565. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  566. set(hObject,'BackgroundColor','white');
  567. end