Guest User

Untitled

a guest
Jul 17th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.00 KB | None | 0 0
  1. function varargout = ICP(varargin)
  2. % ICP MATLAB code for ICP.fig
  3. % ICP, by itself, creates a new ICP or raises the existing
  4. % singleton*.
  5. %
  6. % H = ICP returns the handle to a new ICP or the handle to
  7. % the existing singleton*.
  8. %
  9. % ICP('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in ICP.M with the given input arguments.
  11. %
  12. % ICP('Property','Value',...) creates a new ICP or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before ICP_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to ICP_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.  
  23. % Edit the above text to modify the response to help ICP
  24.  
  25. % Last Modified by GUIDE v2.5 29-Mar-2012 13:21:31
  26.  
  27. % Begin initialization code - DO NOT EDIT
  28. gui_Singleton = 1;
  29. gui_State = struct('gui_Name', mfilename, ...
  30. 'gui_Singleton', gui_Singleton, ...
  31. 'gui_OpeningFcn', @ICP_OpeningFcn, ...
  32. 'gui_OutputFcn', @ICP_OutputFcn, ...
  33. 'gui_LayoutFcn', [] , ...
  34. 'gui_Callback', []);
  35. if nargin && ischar(varargin{1})
  36. gui_State.gui_Callback = str2func(varargin{1});
  37. end
  38.  
  39. if nargout
  40. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  41. else
  42. gui_mainfcn(gui_State, varargin{:});
  43. end
  44. % End initialization code - DO NOT EDIT
  45.  
  46.  
  47. % --- Executes just before ICP is made visible.
  48. function ICP_OpeningFcn(hObject, eventdata, handles, varargin)
  49. % This function has no output args, see OutputFcn.
  50. % hObject handle to figure
  51. % eventdata reserved - to be defined in a future version of MATLAB
  52. % handles structure with handles and user data (see GUIDATA)
  53. % varargin command line arguments to ICP (see VARARGIN)
  54. % Choose default command line output for ICP
  55. handles.output = hObject;
  56.  
  57. % Update handles structure
  58. guidata(hObject, handles);
  59.  
  60. % UIWAIT makes ICP wait for user response (see UIRESUME)
  61. % uiwait(handles.figure1);
  62.  
  63.  
  64. % --- Outputs from this function are returned to the command line.
  65. function varargout = ICP_OutputFcn(hObject, eventdata, handles)
  66. % varargout cell array for returning output args (see VARARGOUT);
  67. % hObject handle to figure
  68. % eventdata reserved - to be defined in a future version of MATLAB
  69. % handles structure with handles and user data (see GUIDATA)
  70.  
  71. % Get default command line output from handles structure
  72. varargout{1} = handles.output;
  73.  
  74.  
  75. % --- Executes on slider movement.
  76. function slider1_Callback(hObject, eventdata, handles)
  77. % hObject handle to slider1 (see GCBO)
  78. % eventdata reserved - to be defined in a future version of MATLAB
  79. % handles structure with handles and user data (see GUIDATA)
  80.  
  81. % Hints: get(hObject,'Value') returns position of slider
  82. % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  83.  
  84.  
  85. % --- Executes during object creation, after setting all properties.
  86. function slider1_CreateFcn(hObject, eventdata, handles)
  87. % hObject handle to slider1 (see GCBO)
  88. % eventdata reserved - to be defined in a future version of MATLAB
  89. % handles empty - handles not created until after all CreateFcns called
  90.  
  91. % Hint: slider controls usually have a light gray background.
  92. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  93. set(hObject,'BackgroundColor',[.9 .9 .9]);
  94. end
  95.  
  96.  
  97. % --- Executes on button press in Evaluate.
  98. function Evaluate_Callback(hObject, eventdata, handles)
  99. % hObject handle to Evaluate (see GCBO)
  100. % eventdata reserved - to be defined in a future version of MATLAB
  101. % handles structure with handles and user data (see GUIDATA)
  102.  
  103. axes1.hObject = plot(handles.ICP2);xlabel('Degrees');ylabel('Probability');
  104. zoom on
  105.  
  106. % Hint: get(hObject,'Value') returns toggle state of Evaluate
  107.  
  108.  
  109. % --- Executes on selection change in popupmenu1.
  110. function popupmenu1_Callback(hObject, eventdata, handles)
  111. % hObject handle to popupmenu1 (see GCBO)
  112. % eventdata reserved - to be defined in a future version of MATLAB
  113. % handles structure with handles and user data (see GUIDATA)
  114. V = get(handles.popupmenu1,'value');
  115. switch V
  116. case 1
  117. axes1.hObject = plot(handles.ICP);xlabel('Samples');ylabel('Pressure (mmHg)');
  118. zoom on
  119. case 2
  120. axes1.hObject = plot(handles.ICP2);xlabel('Samples');ylabel('Pressure (mmHg)');
  121. zoom on
  122. case 3
  123. m = 3;
  124. Fs = 100;
  125. X.first = handles.ICP(1:end/m);
  126. X.second = handles.ICP(length(X.first)+1:end*2/m);
  127. N = length(X.second);
  128. FICPs = fftshift(fft(X.second));
  129. f = (0:N-1)/N*Fs-Fs/2;
  130. axes1.hObject = plot(f(N/2+10:end),abs(FICPs(N/2+10:end)));
  131. axis([0 5 0 2.5*10^5])
  132. ylabel('Amplitude')
  133. xlabel('Frequency (Hz)')
  134. zoom on
  135. end
  136.  
  137. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
  138. % contents{get(hObject,'Value')} returns selected item from popupmenu1
  139.  
  140.  
  141. % --- Executes during object creation, after setting all properties.
  142. function popupmenu1_CreateFcn(hObject, eventdata, handles)
  143. % hObject handle to popupmenu1 (see GCBO)
  144. % eventdata reserved - to be defined in a future version of MATLAB
  145. % handles empty - handles not created until after all CreateFcns called
  146.  
  147. % Hint: popupmenu controls usually have a white background on Windows.
  148. % See ISPC and COMPUTER.
  149. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  150. set(hObject,'BackgroundColor','white');
  151. end
  152.  
  153.  
  154. % --- Executes on button press in ekgfilter.
  155. function ekgfilter_Callback(hObject, eventdata, handles)
  156. % hObject handle to ekgfilter (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.  
  160. % Filter out the noise from Carotis arterie
  161. N = 10; % Order
  162. Fc1 = 1; % First Cutoff Frequency
  163. Fc2 = 1.8; % Second Cutoff Frequency
  164. Fs = 100; % Sampling frequency
  165. % Construct an FDESIGN object and call its BUTTER method.
  166. notch = fdesign.bandstop('N,F3dB1,F3dB2', N, Fc1, Fc2, Fs);
  167. Hd = design(notch, 'butter');
  168. handles.ICP = filter(Hd,handles.ICP);
  169. guidata(hObject,handles)
  170.  
  171. % Hint: get(hObject,'Value') returns toggle state of ekgfilter
  172.  
  173.  
  174. % --- Executes on button press in MAfilter.
  175. function MAfilter_Callback(hObject, eventdata, handles)
  176. % hObject handle to MAfilter (see GCBO)
  177. % eventdata reserved - to be defined in a future version of MATLAB
  178. % handles structure with handles and user data (see GUIDATA)
  179.  
  180. % Hint: get(hObject,'Value') returns toggle state of MAfilter
  181.  
  182.  
  183. % --- Executes on button press in baseline.
  184. function baseline_Callback(hObject, eventdata, handles)
  185. % hObject handle to baseline (see GCBO)
  186. % eventdata reserved - to be defined in a future version of MATLAB
  187. % handles structure with handles and user data (see GUIDATA)
  188.  
  189.  
  190. % Hint: get(hObject,'Value') returns toggle state of baseline
  191.  
  192. % --- Executes during object creation, after setting all properties.
  193. function axes1_CreateFcn(hObject, eventdata, handles)
  194. % hObject handle to axes1 (see GCBO)
  195. % eventdata reserved - to be defined in a future version of MATLAB
  196. % handles empty - handles not created until after all CreateFcns called
  197.  
  198. % Hint: place code in OpeningFcn to populate axes1
  199.  
  200.  
  201.  
  202. % --- Executes on button press in Spike.
  203. function Spike_Callback(hObject, eventdata, handles)
  204. % hObject handle to Spike (see GCBO)
  205. % eventdata reserved - to be defined in a future version of MATLAB
  206. % handles structure with handles and user data (see GUIDATA)
  207. handles.ICP2 = handles.ICP;
  208. hh = find(handles.ICP == 100);
  209. hh(end+1) = hh(end)+5;
  210. g = median(handles.ICP(hh(1)-100):handles.ICP(hh(1)-1));
  211. for i = 2:length(hh)-1
  212.  
  213. if hh(i+1)-hh(i)>1
  214.  
  215. g = mean(handles.ICP(hh(i)+1:hh(i)+100));
  216. end
  217.  
  218. handles.ICP2(hh(i))=g;
  219.  
  220. end
  221. guidata(hObject,handles)
  222. % Hint: get(hObject,'Value') returns toggle state of Spike
  223.  
  224.  
  225. % --- Executes on button press in import.
  226. function import_Callback(hObject, eventdata, handles)
  227. % hObject handle to import (see GCBO)
  228. % eventdata reserved - to be defined in a future version of MATLAB
  229. % handles structure with handles and user data (see GUIDATA)
  230. [filename1,filepath1]=uigetfile({'*.mat*','.mat files only'},...
  231. 'Select ICP Data File');
  232. cd(filepath1)
  233. data=load(filename1);
  234.  
  235. handles.ICP = data.ICP;
  236. guidata(hObject,handles) %Gemmer vores loadede ICP data, i handle
  237.  
  238. %Laver en pop-up input box til at angive dag/nat
  239. prompt = {'Dag til nat:','Nat til dag'};
  240. dlg_title = 'Input fra logbog';
  241. num_lines = 2;
  242. def = {'auto','auto'};
  243. answer = inputdlg(prompt,dlg_title,num_lines,def);
  244.  
  245.  
  246.  
  247.  
  248. % --- Executes on selection change in popupmenu2.
  249. function popupmenu2_Callback(hObject, eventdata, handles)
  250. % hObject handle to popupmenu2 (see GCBO)
  251. % eventdata reserved - to be defined in a future version of MATLAB
  252. % handles structure with handles and user data (see GUIDATA)
  253.  
  254. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
  255. % contents{get(hObject,'Value')} returns selected item from popupmenu2
  256. V = get(handles.popupmenu2,'value');
  257. switch V
  258. case 1
  259. axes2.hObject = plot(handles.ICP);xlabel('Samples');ylabel('Pressure (mmHg)');
  260. zoom on
  261. case 2
  262. axes2.hObject = plot(handles.ICP2);xlabel('Samples');ylabel('Pressure (mmHg)');
  263. zoom on
  264. case 3
  265. m = 3;
  266. Fs = 100;
  267. X.first = handles.ICP(1:end/m);
  268. X.second = handles.ICP(length(X.first)+1:end*2/m);
  269. N = length(X.second);
  270. FICPs = fftshift(fft(X.second));
  271. f = (0:N-1)/N*Fs-Fs/2;
  272. axes2.hObject = plot(f(N/2+10:end),abs(FICPs(N/2+10:end)));
  273. axis([0 5 0 2.5*10^5])
  274. ylabel('Amplitude')
  275. xlabel('Frequency (Hz)')
  276. zoom on
  277. end
  278.  
  279.  
  280. % --- Executes during object creation, after setting all properties.
  281. function popupmenu2_CreateFcn(hObject, eventdata, handles)
  282. % hObject handle to popupmenu2 (see GCBO)
  283. % eventdata reserved - to be defined in a future version of MATLAB
  284. % handles empty - handles not created until after all CreateFcns called
  285.  
  286. % Hint: popupmenu controls usually have a white background on Windows.
  287. % See ISPC and COMPUTER.
  288. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  289. set(hObject,'BackgroundColor','white');
  290. end
  291.  
  292.  
  293. % --- Executes during object creation, after setting all properties.
  294. function axes4_CreateFcn(hObject, eventdata, handles)
  295. % hObject handle to axes4 (see GCBO)
  296. % eventdata reserved - to be defined in a future version of MATLAB
  297. % handles empty - handles not created until after all CreateFcns called
  298.  
  299. % Hint: place code in OpeningFcn to populate axes4
Add Comment
Please, Sign In to add comment