1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
| function varargout = frmExprtmarks(varargin)
% FRMEXPRTMARKS M-file for frmExprtmarks.fig
% FRMEXPRTMARKS, by itself, creates a new FRMEXPRTMARKS or raises the existing
% singleton*.
%
% H = FRMEXPRTMARKS returns the handle to a new FRMEXPRTMARKS or the handle to
% the existing singleton*.
%
% FRMEXPRTMARKS('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in FRMEXPRTMARKS.M with the given input arguments.
%
% FRMEXPRTMARKS('Property','Value',...) creates a new FRMEXPRTMARKS or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before frmExprtmarks_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to frmExprtmarks_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 frmExprtmarks
% Last Modified by GUIDE v2.5 21-Nov-2008 11:54:06
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @frmExprtmarks_OpeningFcn, ...
'gui_OutputFcn', @frmExprtmarks_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 frmExprtmarks is made visible.
function frmExprtmarks_OpeningFcn(hObject, eventdata, handles, varargin)
global copyData nLab expdMarks Nmax Nmrk
% 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 frmExprtmarks (see VARARGIN)
% Choose default command line output for frmExprtmarks
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes frmExprtmarks wait for user response (see UIRESUME)
% 1 2 3 4 5
%hgx=frmExprtmarks(labs, nLab, get(handles.lbFiles,'String'),SelPlots,Nm);
Lall=varargin{1};
nLab=varargin{2};
sc=varargin{1}{nLab};
for k=1:length(Lall)
if strcmp(sc,Lall{k})
Lall(k)=[];
break
end
end
set(handles.lbLabs2copy,'String',Lall);
set(handles.lbTrials2copy,'String',varargin{3});
s=sprintf('Export marker(s) from label %s',sc);
set(handles.txtCopyfrom,'String',s);
plots=varargin{4};
Nmax=varargin{5}; %max number of marker
copyinfo=cell(1,1);
copyData=struct('Plot',[],'Marker',[]);
for npl=1:length(plots)
plud=get(plots(npl),'UserData');
trs=get(handles.lbTrials2copy,'String');
tr=trs{plud.nTr};
for mi=1:length(plud.hG)
mrud=get(plud.hG(mi),'UserData'); %marker's userdata
s=sprintf('Trial %s: Marker ¹%d at %.2f sec.',tr,mrud(4),mrud(2));
if isempty(copyinfo{1})
copyinfo{1}=s;
copyData(1).Plot=plots(npl);
copyData(1).Marker=plud.hG(mi);
else
copyinfo{end+1}=s;
copyData(end+1).Plot=plots(npl);
copyData(end).Marker=plud.hG(mi);
end
end
end
set(handles.lbMarkers,'String',copyinfo)
Nmrk=0; %current 'inner' number of exported markers
lbMarkers_Callback(handles.lbMarkers, eventdata, handles)
uicontrol(handles.lbMarkers);
expdMarks=[]; %structure array of exported markers info
uiwait(hObject);
%-------------------------------------------------------------------
%DELETING the EXPORTED MARKER clicked & information about it
function delXM(src,evnt) %callback function for click on marker, src - the MARKER clicked
global expdMarks hgme
NumMrk=get(src, 'UserData'); %MARKER number
for im=1:length(expdMarks)
if expdMarks(im).Numark==NumMrk
expdMarks(im)=[];
break;
end
end
hgme(find(hgme==src))=[]; %Deleting from hgme array an item with handle=src
if length(expdMarks)==0 %If no exported markers...
set(findobj('Tag','bnSave'),'Enable','off') %make the button save disabled
expdMarks=[];
end
delete(src);
%-------------------------------------------------------------------------
function hp=drawPlot2Exp(Trial, Label, expLabel)
global SmartData dsRaw ChansAdded monitAdded expdMarks hgme
%expLabel - # of Label with exported marker
if Label>=expLabel
Label=Label+1;
end
cellInd=5;
if Label<=dsRaw(1) %Kinematics
ind=1; dsr=0;
elseif Label<=(dsRaw(1)+dsRaw(2)) %EMG
ind=2; dsr=dsRaw(1);
elseif Label<=sum(dsRaw) %Force plate
ind=3; dsr=dsRaw(1)+dsRaw(2);
else %Added channel
BaseChan=find(monitAdded==Label); %Index of 'antiderivative' channel in ChansAdded array
ind=ChansAdded(BaseChan).dtype; %DATA type (1,2,3) of 'antiderivative' channel
cellInd=4;
nChan=ChansAdded(BaseChan).nNchan;
end
Tstart=SmartData{Trial}{7};
T= 1/SmartData{Trial}{1}(ind); % 1/frequency= Period
Ttot=(length(SmartData{Trial}{4}{ind})-1)*T; % Total time
x=Tstart:T:Ttot+Tstart;
%Y-data for plot
if cellInd==5
y=SmartData{Trial}{4}{ind}(:,Label-dsr);
else
y=SmartData{Trial}{4}{ind}(:,nChan);
end
hp=line(x,y, 'Color','k','LineStyle','--');
%draw EXPORTED marker(s) if any
if ~isempty(expdMarks) %is there EXPORTED markers?
hold on
hgme=zeros(length(expdMarks));
ih=0;
clr=[1, 177/255, 100/255];
for im=1:length(expdMarks)
if expdMarks(im).Tr==Trial && expdMarks(im).Lb==Label %is ON THIS plot EXPTD. marker(s)?
ih=ih+1;
ym=get(gca,'YLim');
markers=expdMarks(im).mInfo;
hgme(ih)=hggroup('ButtonDownFcn',@delXM);
plot([markers(1) markers(1)],[markers(2) ym(1)], 'Color',clr, 'HitTest','off','Parent',hgme(ih));
plot(markers(1), markers(2),'o', 'Color',clr, 'HitTest','off','Parent',hgme(ih));
sm=sprintf('%dX',markers(3));
text(markers(1), ym(1),sm,'Color',clr, 'HorizontalAlignment', 'center', 'HitTest','off',...
'VerticalAlignment', 'top','Parent',hgme(ih));
set(hgme(ih),'UserData',expdMarks(im).Numark)
end
end
hgme(ih+1:end)=[];
end
hold off
%-------------------------------------------------------------------------------
% --- Outputs from this function are returned to the command line.
function varargout = frmExprtmarks_OutputFcn(hObject, eventdata, handles)
global Nmax
% 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)
varargout{1}=Nmax; %hObject;
%-----------------------------------------------------------------------
% --- Executes on selection change in lbMarkers.
function lbMarkers_Callback(hObject, eventdata, handles)
global copyData
% hObject handle to lbMarkers (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns lbMarkers contents as cell array
% contents{get(hObject,'Value')} returns selected item from lbMarkers
nInf=get(hObject,'Value');
plData=copyData(nInf).Plot;
plot(get(plData,'XData'),get(plData,'YData'));
hold on
mrk=get(copyData(nInf).Marker,'UserData'); %Marker userdata
hge = hggroup;
ym=get(handles.axes1,'YLim');
%MARKER
plot([mrk(2) mrk(2)],[mrk(3) ym(2)], 'Color','r', 'HitTest','off','Parent',hge);
plot(mrk(2), mrk(3),'or', 'HitTest','off','Parent',hge);
text(mrk(2), ym(2),int2str(mrk(4)),'Color', 'red', 'HorizontalAlignment', 'center', 'HitTest','off',...
'VerticalAlignment', 'bottom','Parent',hge);
hold off
%--------------------------------------------------------------------------
% --- Executes during object creation, after setting all properties.
function lbMarkers_CreateFcn(hObject, eventdata, handles)
% hObject handle to lbMarkers (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox 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 selection change in lbLabs2copy.
function lbLabs2copy_Callback(hObject, eventdata, handles)
global nLab hp hgme
if ishandle(hp)
delete(hp)
end
if ishandle(hgme)
delete(hgme)
end
hp=[]; hgme=[];
hp=drawPlot2Exp(get(handles.lbTrials2copy,'Value'), get(hObject,'Value'), nLab);
%-------------------------------------------------------------------------
% --- Executes during object creation, after setting all properties.
function lbLabs2copy_CreateFcn(hObject, eventdata, handles)
% hObject handle to lbLabs2copy (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox 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 selection change in lbTrials2copy.
function lbTrials2copy_Callback(hObject, eventdata, handles)
global nLab hp hgme
if ishandle(hp)
delete(hp)
end
if ishandle(hgme)
delete(hgme)
end
hp=[]; hgme=[];
hp=drawPlot2Exp(get(hObject,'Value'), get(handles.lbLabs2copy,'Value'), nLab);
%--------------------------------------------------------------------------
% --- Executes during object creation, after setting all properties.
function lbTrials2copy_CreateFcn(hObject, eventdata, handles)
% hObject handle to lbTrials2copy (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox 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 bnExport.
function bnExport_Callback(hObject, eventdata, handles)
global copyData hp expdMarks hgme nLab Nmrk
% hObject handle to bnExport (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if ~ishandle(hp)
return
end
cd=get(handles.lbMarkers,'Value');
mrud=get(copyData(cd).Marker,'UserData'); %'old' marker's userdata
x=get(hp,'XData');
ind=getIndByXdata(x, mrud(2));
y=get(hp,'YData');
yM=y(ind);
xM=x(ind);
ym=get(handles.axes1,'YLim');
%DRAW MARKER
sm=sprintf('%dX',mrud(4));
hold on
%DRAW exported marker
if ishandle(hgme)
hgme(end+1)=hggroup('ButtonDownFcn',@delXM);
else
hgme(1)=hggroup('ButtonDownFcn',@delXM);
end
clr=[1, 177/255, 100/255];
plot([xM xM],[yM ym(1)], 'Color',clr, 'HitTest','off','Parent',hgme(end));
plot(xM, yM,'o','Color',clr, 'HitTest','off','Parent',hgme(end));
text(xM, ym(1),sm,'Color', clr, 'HorizontalAlignment', 'center', 'HitTest','off',...
'VerticalAlignment', 'top','Parent',hgme(end));
hold off
%save EXPORTED marker(s) info in expdMarks structure
Nmrk=Nmrk+1;
set(hgme(end),'UserData',Nmrk)
mInf=[xM yM mrud(4)]; %x,y, marker #
eLb=get(handles.lbLabs2copy,'Value');
if eLb>=nLab
eLb=eLb+1;
end
if isempty(expdMarks)
expdMarks.Tr=get(handles.lbTrials2copy,'Value');
expdMarks.Lb=eLb;
expdMarks.mInfo=mInf;
expdMarks.Numark=Nmrk;
else
expdMarks(end+1).Tr=get(handles.lbTrials2copy,'Value');
expdMarks(end).Lb=eLb;
expdMarks(end).mInfo=mInf;
expdMarks(end).Numark=Nmrk;
end
if ~isempty(expdMarks)
set(handles.bnSave,'Enable','on');
end
%----------------------------------------------------------------
% --- Executes on button press in bnClose.
function bnClose_Callback(hObject, eventdata, handles)
% hObject handle to bnClose (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close
%-----------------------------------------------------------------
% --- Executes on button press in bnSave.
function bnSave_Callback(hObject, eventdata, handles)
global expdMarks Nmax SmartData nLab SelPlots
% hObject handle to bnSave (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ls=get(handles.lbLabs2copy,'String');
for nm=1:length(expdMarks)
nTr=expdMarks(nm).Tr;
if expdMarks(nm).Lb>nLab
nL=expdMarks(nm).Lb-1;
else
nL=expdMarks(nm).Lb;
end
LabNam=ls(nL);
Nmax=Nmax+1;
mInf=expdMarks(nm).mInfo;
mrkInfo=struct('Label',LabNam, 'XY', mInf(1:2),'nMarker',Nmax); %MARKER info
if size(SmartData{nTr},2)<8
SmartData{nTr}{8}=mrkInfo;
else
SmartData{nTr}{8}=[SmartData{nTr}{8} mrkInfo];
end
end
for nm=1:length(expdMarks)
mrkInfo(nm)=struct('Label',LabNam(nm), 'XY', mInf(1:2)(nm),'nMarker',Nmax);
end
[FilName, PathName] = uiputfile({'*.mat','MAT-files (*.mat)'});
Nmax
mrkInfo
SelPlots
expdMarks
mInf
SmartData
SmartData{nTr}{8}
save(fullfile(PathName,FilName),'mrkInfo');
close
%--------------------------------------------------------------
% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: delete(hObject) closes the figure
delete(hObject); |
Partager