function varargout = PosturalData_NMFvsPCA_GUI_July2013(varargin)
% POSTURALDATA_NMFVSPCA_GUI_JULY2013 M-file for PosturalData_NMFvsPCA_GUI_July2013.fig
% POSTURALDATA_NMFVSPCA_GUI_JULY2013, by itself, creates a new POSTURALDATA_NMFVSPCA_GUI_JULY2013 or raises the existing
% singleton*.
%
% H = POSTURALDATA_NMFVSPCA_GUI_JULY2013 returns the handle to a new POSTURALDATA_NMFVSPCA_GUI_JULY2013 or the handle to
% the existing singleton*.
%
% POSTURALDATA_NMFVSPCA_GUI_JULY2013('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in POSTURALDATA_NMFVSPCA_GUI_JULY2013.M with the given input arguments.
%
% POSTURALDATA_NMFVSPCA_GUI_JULY2013('Property','Value',...) creates a new POSTURALDATA_NMFVSPCA_GUI_JULY2013 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before PosturalData_NMFvsPCA_GUI_July2013_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to PosturalData_NMFvsPCA_GUI_July2013_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 PosturalData_NMFvsPCA_GUI_July2013
% Last Modified by GUIDE v2.5 02-Jul-2013 13:46:12
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @PosturalData_NMFvsPCA_GUI_July2013_OpeningFcn, ...
'gui_OutputFcn', @PosturalData_NMFvsPCA_GUI_July2013_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 PosturalData_NMFvsPCA_GUI_July2013 is made visible.
function PosturalData_NMFvsPCA_GUI_July2013_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 PosturalData_NMFvsPCA_GUI_July2013 (see VARARGIN)
% Choose default command line output for PosturalData_NMFvsPCA_GUI_July2013
handles.output = hObject;
set(hObject,'toolbar','figure');
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes PosturalData_NMFvsPCA_GUI_July2013 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = PosturalData_NMFvsPCA_GUI_July2013_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;
%***********************************************
% Various initializations & declarations *
%***********************************************
%***********************************************
% Load and Plot the original Data *
%***********************************************
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global DATAsrc DATA_LST checkwalk time nmus ncond ntrials nbins color
% 1 2 3 4 5 6 7 8 9 10 11 12
% red fade red green fade green blue fade blue black gray yellow orange plum lime
color_palette= [255 0 0; 255 150 150; 0 114 54; 153 255 102; 0 0 255; 44 176 207; 0 0 0; 155 155 155; 255 153 0; 255 185 0; 153 51 102; 171 218 77]*(1/255);
color=color_palette([6 1 2 10 11 4 3 5 12 7 8 9 1 10 4 6 11 3 2 5 12],:); %S0052 functional vars (EMGGRFandCOM file)
% Load the data
checkwalk=get(handles.checkbox_walking,'Value');
if checkwalk==1;
load example_walking_data DATAsrc DATA_LST time %eventually modify this to allow user to select a file
else
load example_postural_data DATAsrc DATA_LST
nmus=16; ncond=12; ntrials=5; nbins=4;
% load PDP05P0M_EMG_data_only_begin150ms_nobkg_scaledtowalking DATAsrc DATA_LST
% DATAsrc(14:16,:)=[];
% DATA_LST(:,1:4)=[];
% DATA_LST(14:16,:)=[];
% nmus=13; ncond=12; ntrials=3; nbins=3;
end
%***********************************************
% Plotting the dataset (tuning curves) *
%***********************************************
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global DATAsrc DATA_LST checkwalk time nmus ncond ntrials nbins
if checkwalk==0
% Plot the data (tuning curves)
Data=reshape(DATAsrc',[ntrials ncond nbins nmus]);
elseif checkwalk==1
Data=DATAsrc;
nmus=size(DATAsrc,1);
end
figure
for i=1:nmus
if checkwalk==0 %Plot tuning curves for postural data
%for k=1:nbins %to plot all 4 time bins
for k=3:3 %to plot only one time bin
%subplot(nmus,nbins,((nbins)*i)-(nbins-k)) %to plot all 4 time bins
subplot(4,4,i) %to plot only one time bin
%H=plot(0:30:330',squeeze(Data(:,:,k,i)),'Color','b');
hold on
H=plot(0:30:330',mean(squeeze(Data(:,:,k,i))),'Color','b','MarkerSize',10);
errorbar([0:30:330'],[mean(squeeze(Data(:,:,k,i)))],[std(squeeze(Data(:,:,k,i)))],'Color','b');
set(H,'Clipping','off')
axis([0 330 0 1])
set(gca,'Xtick',[0 90 180 270],'Ytick',[0 1])
if k==3
ylabel(DATA_LST(i,:))
end
end
if i==1, title(['Muscle tuning curves']); end
elseif checkwalk==1 %Plot entire trial for walking data
subplot(8,2,i) %to plot only one time bin
plot(time,DATAsrc(i,:));
ylim([0 1])
xlim([0 time(end)])
ylabel(DATA_LST(i,:))
end
end
orient tall
guidata(hObject, handles); %updates the handles
%***********************************************
% Extract muscle synergies using NMF *
%***********************************************
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global DATAsrc numsyn_nmf synergy_nmf
synergy_nmf={};
[nmus,nconds]=size(DATAsrc);
for s=1:nmus
synergy_nmf(s).nsyn=s; %The number of synergies
[synergy_nmf(s).W,synergy_nmf(s).C,synergy_nmf(s).err,synergy_nmf(s).stdev] = NNMF_stacie_May2013(DATAsrc,s,1);
[synergy_nmf(s).VAFcond, synergy_nmf(s).VAFmus, synergy_nmf(s).VAF]=funur(DATAsrc,synergy_nmf(s).W,synergy_nmf(s).C); %calculate VAF of reconstruction
synergy_nmf(s).RECON = synergy_nmf(s).W*synergy_nmf(s).C;
end
%****choose number of synergies and assign variables to plot
[numsyn_nmf]=choosesyns(DATAsrc,synergy_nmf);
set(handl
- 1
- 2
- 3
- 4
- 5
- 6
前往页