Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function varargout = ICP(varargin)
- % ICP MATLAB code for ICP.fig
- % ICP, by itself, creates a new ICP or raises the existing
- % singleton*.
- %
- % H = ICP returns the handle to a new ICP or the handle to
- % the existing singleton*.
- %
- % ICP('CALLBACK',hObject,eventData,handles,...) calls the local
- % function named CALLBACK in ICP.M with the given input arguments.
- %
- % ICP('Property','Value',...) creates a new ICP or raises the
- % existing singleton*. Starting from the left, property value pairs are
- % applied to the GUI before ICP_OpeningFcn gets called. An
- % unrecognized property name or invalid value makes property application
- % stop. All inputs are passed to ICP_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 ICP
- % Last Modified by GUIDE v2.5 29-Mar-2012 13:21:31
- % Begin initialization code - DO NOT EDIT
- gui_Singleton = 1;
- gui_State = struct('gui_Name', mfilename, ...
- 'gui_Singleton', gui_Singleton, ...
- 'gui_OpeningFcn', @ICP_OpeningFcn, ...
- 'gui_OutputFcn', @ICP_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 ICP is made visible.
- function ICP_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 ICP (see VARARGIN)
- % Choose default command line output for ICP
- handles.output = hObject;
- % Update handles structure
- guidata(hObject, handles);
- % UIWAIT makes ICP wait for user response (see UIRESUME)
- % uiwait(handles.figure1);
- % --- Outputs from this function are returned to the command line.
- function varargout = ICP_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;
- % --- Executes on slider movement.
- function slider1_Callback(hObject, eventdata, handles)
- % hObject handle to slider1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % 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 slider1_CreateFcn(hObject, eventdata, handles)
- % hObject handle to slider1 (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 button press in Evaluate.
- function Evaluate_Callback(hObject, eventdata, handles)
- % hObject handle to Evaluate (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- axes1.hObject = plot(handles.ICP2);xlabel('Degrees');ylabel('Probability');
- zoom on
- % Hint: get(hObject,'Value') returns toggle state of Evaluate
- % --- Executes on selection change in popupmenu1.
- function popupmenu1_Callback(hObject, eventdata, handles)
- % hObject handle to popupmenu1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- V = get(handles.popupmenu1,'value');
- switch V
- case 1
- axes1.hObject = plot(handles.ICP);xlabel('Samples');ylabel('Pressure (mmHg)');
- zoom on
- case 2
- axes1.hObject = plot(handles.ICP2);xlabel('Samples');ylabel('Pressure (mmHg)');
- zoom on
- case 3
- m = 3;
- Fs = 100;
- X.first = handles.ICP(1:end/m);
- X.second = handles.ICP(length(X.first)+1:end*2/m);
- N = length(X.second);
- FICPs = fftshift(fft(X.second));
- f = (0:N-1)/N*Fs-Fs/2;
- axes1.hObject = plot(f(N/2+10:end),abs(FICPs(N/2+10:end)));
- axis([0 5 0 2.5*10^5])
- ylabel('Amplitude')
- xlabel('Frequency (Hz)')
- zoom on
- end
- % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from popupmenu1
- % --- Executes during object creation, after setting all properties.
- function popupmenu1_CreateFcn(hObject, eventdata, handles)
- % hObject handle to popupmenu1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: popupmenu controls usually have a white background on Windows.
- % See ISPC and COMPUTER.
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes on button press in ekgfilter.
- function ekgfilter_Callback(hObject, eventdata, handles)
- % hObject handle to ekgfilter (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Filter out the noise from Carotis arterie
- N = 10; % Order
- Fc1 = 1; % First Cutoff Frequency
- Fc2 = 1.8; % Second Cutoff Frequency
- Fs = 100; % Sampling frequency
- % Construct an FDESIGN object and call its BUTTER method.
- notch = fdesign.bandstop('N,F3dB1,F3dB2', N, Fc1, Fc2, Fs);
- Hd = design(notch, 'butter');
- handles.ICP = filter(Hd,handles.ICP);
- guidata(hObject,handles)
- % Hint: get(hObject,'Value') returns toggle state of ekgfilter
- % --- Executes on button press in MAfilter.
- function MAfilter_Callback(hObject, eventdata, handles)
- % hObject handle to MAfilter (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hint: get(hObject,'Value') returns toggle state of MAfilter
- % --- Executes on button press in baseline.
- function baseline_Callback(hObject, eventdata, handles)
- % hObject handle to baseline (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hint: get(hObject,'Value') returns toggle state of baseline
- % --- Executes during object creation, after setting all properties.
- function axes1_CreateFcn(hObject, eventdata, handles)
- % hObject handle to axes1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: place code in OpeningFcn to populate axes1
- % --- Executes on button press in Spike.
- function Spike_Callback(hObject, eventdata, handles)
- % hObject handle to Spike (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- handles.ICP2 = handles.ICP;
- hh = find(handles.ICP == 100);
- hh(end+1) = hh(end)+5;
- g = median(handles.ICP(hh(1)-100):handles.ICP(hh(1)-1));
- for i = 2:length(hh)-1
- if hh(i+1)-hh(i)>1
- g = mean(handles.ICP(hh(i)+1:hh(i)+100));
- end
- handles.ICP2(hh(i))=g;
- end
- guidata(hObject,handles)
- % Hint: get(hObject,'Value') returns toggle state of Spike
- % --- Executes on button press in import.
- function import_Callback(hObject, eventdata, handles)
- % hObject handle to import (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- [filename1,filepath1]=uigetfile({'*.mat*','.mat files only'},...
- 'Select ICP Data File');
- cd(filepath1)
- data=load(filename1);
- handles.ICP = data.ICP;
- guidata(hObject,handles) %Gemmer vores loadede ICP data, i handle
- %Laver en pop-up input box til at angive dag/nat
- prompt = {'Dag til nat:','Nat til dag'};
- dlg_title = 'Input fra logbog';
- num_lines = 2;
- def = {'auto','auto'};
- answer = inputdlg(prompt,dlg_title,num_lines,def);
- % --- Executes on selection change in popupmenu2.
- function popupmenu2_Callback(hObject, eventdata, handles)
- % hObject handle to popupmenu2 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from popupmenu2
- V = get(handles.popupmenu2,'value');
- switch V
- case 1
- axes2.hObject = plot(handles.ICP);xlabel('Samples');ylabel('Pressure (mmHg)');
- zoom on
- case 2
- axes2.hObject = plot(handles.ICP2);xlabel('Samples');ylabel('Pressure (mmHg)');
- zoom on
- case 3
- m = 3;
- Fs = 100;
- X.first = handles.ICP(1:end/m);
- X.second = handles.ICP(length(X.first)+1:end*2/m);
- N = length(X.second);
- FICPs = fftshift(fft(X.second));
- f = (0:N-1)/N*Fs-Fs/2;
- axes2.hObject = plot(f(N/2+10:end),abs(FICPs(N/2+10:end)));
- axis([0 5 0 2.5*10^5])
- ylabel('Amplitude')
- xlabel('Frequency (Hz)')
- zoom on
- end
- % --- Executes during object creation, after setting all properties.
- function popupmenu2_CreateFcn(hObject, eventdata, handles)
- % hObject handle to popupmenu2 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: popupmenu controls usually have a white background on Windows.
- % See ISPC and COMPUTER.
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function axes4_CreateFcn(hObject, eventdata, handles)
- % hObject handle to axes4 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: place code in OpeningFcn to populate axes4
Add Comment
Please, Sign In to add comment