forked from mbussonn/analyse_response_function
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI_intracellular_response_function_v2.m
More file actions
executable file
·652 lines (504 loc) · 24.3 KB
/
GUI_intracellular_response_function_v2.m
File metadata and controls
executable file
·652 lines (504 loc) · 24.3 KB
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
function varargout = GUI_intracellular_response_function_v2(varargin)
% GUI_INTRACELLULAR_RESPONSE_FUNCTION_V2 MATLAB code for GUI_intracellular_response_function_v2.fig
% GUI_INTRACELLULAR_RESPONSE_FUNCTION_V2, by itself, creates a new GUI_INTRACELLULAR_RESPONSE_FUNCTION_V2 or raises the existing
% singleton*.
%
% H = GUI_INTRACELLULAR_RESPONSE_FUNCTION_V2 returns the handle to a new GUI_INTRACELLULAR_RESPONSE_FUNCTION_V2 or the handle to
% the existing singleton*.
%
% GUI_INTRACELLULAR_RESPONSE_FUNCTION_V2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_INTRACELLULAR_RESPONSE_FUNCTION_V2.M with the given input arguments.
%
% GUI_INTRACELLULAR_RESPONSE_FUNCTION_V2('Property','Value',...) creates a new GUI_INTRACELLULAR_RESPONSE_FUNCTION_V2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUI_intracellular_response_function_v2_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GUI_intracellular_response_function_v2_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 axes_response to help GUI_intracellular_response_function_v2
% Last Modified by GUIDE v2.5 04-Dec-2013 00:33:33
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI_intracellular_response_function_v2_OpeningFcn, ...
'gui_OutputFcn', @GUI_intracellular_response_function_v2_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 GUI_intracellular_response_function_v2 is made visible.
function GUI_intracellular_response_function_v2_OpeningFcn(hObject, eventdata, handles, varargin) %#ok<*INUSL>
% 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 GUI_intracellular_response_function_v2 (see VARARGIN)
% Choose default command line output for GUI_intracellular_response_function_v2
handles.output = hObject;
%set the default path
handles.dir='E:\Science\data\response_function\oocytes\2013-06-10';
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUI_intracellular_response_function_v2 wait for user axes_response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GUI_intracellular_response_function_v2_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;
function edit_particle_diameter_Callback(hObject, eventdata, handles) %#ok<*DEFNU>
% hObject handle to edit_particle_diameter (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,'String') returns contents of edit_particle_diameter as text
% str2double(get(hObject,'String')) returns contents of edit_particle_diameter as a double
handles=display_current_data(handles);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function edit_particle_diameter_CreateFcn(hObject, eventdata, handles) %#ok<*INUSD>
% hObject handle to edit_particle_diameter (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit 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
% --------------------------------------------------------------------
function load_menu_Callback(hObject, eventdata, handles)
% hObject handle to load_menu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function edit_response_prefactor_Callback(hObject, eventdata, handles)
% hObject handle to edit_response_prefactor (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,'String') returns contents of edit_response_prefactor as text
% str2double(get(hObject,'String')) returns contents of edit_response_prefactor as a double
handles=display_current_data(handles);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function edit_response_prefactor_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_response_prefactor (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit 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
% --------------------------------------------------------------------
function load_folder_Callback(hObject, eventdata, handles)
% hObject handle to load_folder (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.dir=uigetdir(handles.dir,'Give me the base directory of the response data');
folders=dir([handles.dir]);
folders(1:2)=[];
folders(find([folders.isdir]==0))=[];
handles.folders=folders;
handles.current_folder=1;
set(handles.edit_dataset,'String','1');
handles.current_path=folders(handles.current_folder);
set(handles.dataset_slider,'Value',1);
set(handles.dataset_slider,'Max',length(folders));
set(handles.dataset_slider,'Min',1);
set(handles.dataset_slider,'SliderStep',[1,1]/(length(folders)-1));
%Here I make sure that the collected response strcuture is empty
handles.corrected_response=[];
handles=load_current_folder(handles);
guidata(hObject, handles);
%--------------------
function handles=load_current_folder(handles)
%This function loads the data in the current folder
handles.current_folder=str2num(get(handles.edit_dataset,'String'));
folders=handles.folders;
%now I read all the response folders and populate the listbox
folders_p=dir([handles.dir,filesep,folders(handles.current_folder).name,filesep,'multiple_run_series*']);
set(handles.listbox_passive,'String',{folders_p.name});
handles.folders_p=folders_p;
%now I read all the fluctuations folders and populate the listbox
folders_a=dir([handles.dir,filesep,folders(handles.current_folder).name,filesep,'response_function*']);
set(handles.listbox_active,'String',{folders_a.name});
handles.folders_a=folders_a;
%Finally I define the first datasets and load these as current data
set(handles.listbox_passive,'Value',1);
set(handles.listbox_active,'Value',1);
handles=load_current_dataset(handles);
function handles=load_current_dataset(handles)
%Here I will take the datasets marked in the listboxes and load the actual
%data. After that I will directly display them
%load the active response
folders=handles.folders;
folders_a=handles.folders_a;
folders_p=handles.folders_p;
act_data_a=get(handles.listbox_active,'Value');
act_data_p=get(handles.listbox_passive,'Value');
load_active=[handles.dir,filesep,folders(handles.current_folder).name,filesep,folders_a(act_data_a).name];
try
load_passive=[handles.dir,filesep,folders(handles.current_folder).name,filesep,folders_p(act_data_p).name];
end
[f,alphax,alphay,trap_stiff,slopes,act_trap]=process_response_function_folder(load_active);
handles.response_f=f;
handles.response_x=alphax;
handles.response_y=alphay;
handles.trap_stiff=trap_stiff;
handles.slopes=slopes;
handles.act_trap=act_trap;
%now I will either load the fluctuations that was saved with the active
%microrheology, or I will take the fluctuations from the passive
%microrheology folder
if isempty(handles.folders_p)
load([load_active,filesep,'histogram_results.mat']);
handles.psd_f=fl(1,2:end);
handles.psd_x=pxl;
handles.psd_y=pyl;
else
[fluct,fl,psdxy,psdxy_std]=process_fluctuation_folder_v3(load_passive); %#ok<NASGU,ASGLU>
handles.psd_f=fl(1,:);
handles.psd_x=psdxy(1,:);
handles.psd_y=psdxy(2,:);
end
handles.particle_diameter=str2num(get(handles.edit_particle_diameter,'String'))*1e-6;
handles.response_prefactor=str2num(get(handles.edit_response_prefactor,'String'));
handles=display_current_data(handles);
%--------------------
function handles=display_current_data(handles)
%This function displays the data in the current folder
handles.particle_diameter=str2num(get(handles.edit_particle_diameter,'String'))*1e-6;
handles.response_prefactor=str2num(get(handles.edit_response_prefactor,'String'));
if not(isfield(handles , 'response_function_dirrection'))
handles.response_function_dirrection = 'X';
end
if handles.response_function_dirrection == 'X'
response_xory =handles.response_x;
elseif handles.response_function_dirrection == 'Y'
response_xory =handles.response_y;
else
throw('unknown direction')
end
%Now I check if there is a correction to be applied
corr_value=get(handles.listbox_correction,'Value')-1;
%if correction required, directly apply it on the xory response
if corr_value==0
elseif corr_value==1
%now I correct using the scan
handles.response_xory=response_xory;
[response_xory,freq]=correct_response_scan(handles);
elseif corr_value==2
[response_xory,freq]=correct_response_hf(handles);
%now I correct using the high frequency
else
throw('unknown correction')
end
psd_x=handles.psd_x(handles.act_trap,:);
axes(handles.axes_response)
loglog(handles.response_f,abs(handles.response_prefactor * imag(response_xory)));
hold on
loglog(handles.psd_f,abs(pi.*handles.psd_f./4e-21.*psd_x));
hold off
ylabel('Response in [m/N]')
xlabel('f in [Hz]')
axes(handles.axes_shear_modulus);
eta=1./(3*pi*handles.particle_diameter*2*pi*handles.response_f.*handles.response_prefactor .* abs(imag(response_xory)));
loglog(handles.response_f,eta);
hold on
G=1./(6*pi*handles.particle_diameter*handles.response_prefactor .* ((response_xory)));
loglog(handles.response_f,abs(real(G)),'+r-');
loglog(handles.response_f,abs(imag(G)),'or-');
loglog([100:1000],[100:1000].^.75*.1);
legend('viscosity','real(G)','img(G)','x^3/4')
xlabel('f in [Hz]')
ylabel('G in Pa (o dissipative, + elastic)')
hold off
%create dataset to save
folders=handles.folders;
if get(handles.checkbox1,'Value')==1
folders=handles.folders;
folders_a=handles.folders_a;
act_data_a=get(handles.listbox_active,'Value');
load_active=[handles.dir,filesep,folders(handles.current_folder).name,filesep,folders_a(act_data_a).name];
load([load_active,filesep,'histogram_results.mat']);
handles.psd_fa=fl(1,2:end);
handles.psd_xa=pxl;
handles.psd_ya=pyl;
axes(handles.axes_response)
hold on
loglog(handles.psd_fa,abs(pi.*handles.psd_fa./4e-21.*handles.psd_xa),'r');
hold off
ylabel('Response in [m/N]')
xlabel('f in [Hz]')
end
save_data.particle_diameter=handles.particle_diameter;
save_data.response_prefactor=handles.response_prefactor;
save_data.response_f=handles.response_f;
save_data.corr_active_response=abs(handles.response_prefactor * imag(response_xory));
save_data.psd_f=handles.psd_f;
save_data.passive_response=abs(pi.*handles.psd_f./4e-21.*psd_x);
save_data.G=G;
save_data.eta=eta;
save_data.base_path=handles.dir;
save_data.folder_path=folders(handles.current_folder).name;
%and now store this structure in the handles.
handles.save_data=save_data;
function edit_dataset_Callback(hObject, eventdata, handles)
% hObject handle to edit_dataset (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,'String') returns contents of edit_dataset as text
% str2double(get(hObject,'String')) returns contents of edit_dataset as a double
set(handles.dataset_slider,'Value',str2num(get(handles.edit_dataset,'String')));
handles=load_current_folder(handles);
handles=display_current_data(handles);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function edit_dataset_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_dataset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit 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 save_current.
function save_current_Callback(hObject, eventdata, handles)
% hObject handle to save_current (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%Here I will save the currently discplayed data in a file that is in the
%current path.
save_data=handles.save_data;
try
corrected_response=handles.corrected_response;
i=length(corrected_response);
corrected_response(i+1)=save_data;
catch
i=0;
corrected_response=save_data;
end
handles.corrected_response=corrected_response;
guidata(hObject, handles);
% --- Executes on slider movement.
function dataset_slider_Callback(hObject, eventdata, handles)
% hObject handle to dataset_slider (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
v=get(handles.dataset_slider,'Value');
set(handles.edit_dataset,'String',num2str(v));
handles=load_current_folder(handles);
handles=display_current_data(handles);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function dataset_slider_CreateFcn(hObject, eventdata, handles)
% hObject handle to dataset_slider (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 selection change in listbox_passive.
function listbox_passive_Callback(hObject, eventdata, handles)
% hObject handle to listbox_passive (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 listbox_passive contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox_passive
handles=load_current_dataset(handles);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function listbox_passive_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox_passive (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 listbox_active.
function listbox_active_Callback(hObject, eventdata, handles)
% hObject handle to listbox_active (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 listbox_active contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox_active
handles=load_current_dataset(handles);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function listbox_active_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox_active (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 checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (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 checkbox1
% --- Executes on button press in save_all.
function save_all_Callback(hObject, eventdata, handles)
% hObject handle to save_all (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
corrected_response=handles.corrected_response;
folders=handles.folders;
[s_file,s_path]=uiputfile([handles.dir,filesep,'*.mat'],'Where should I store the data');
save([s_path,filesep,s_file],'corrected_response');
% --- Executes when selected object is changed in XorY.
function XorY_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in XorY
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object.
case 'radiobuttonX'
handles.response_function_dirrection = 'X';
case 'radiobuttonY'
handles.response_function_dirrection = 'Y';
% Code for when radiobutton2 is selected.
otherwise
throw('got unknown radio button !')
end
guidata(hObject, handles);
% --- Executes on button press in pushbutton_scan.
function pushbutton_scan_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_scan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton_hf.
function pushbutton_hf_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_hf (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on selection change in listbox_correction.
function listbox_correction_Callback(hObject, eventdata, handles)
% hObject handle to listbox_correction (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 listbox_correction contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox_correction
% --- Executes during object creation, after setting all properties.
function listbox_correction_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox_correction (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
% ------------- additional Function-------------
function [response_xory,freq]=correct_response_scan(handles)
%first I need to load the scan data
folders=handles.folders;
folders_a=handles.folders_a;
act_data_a=get(handles.listbox_active,'Value');
load_active=[handles.dir,filesep,folders(handles.current_folder).name,filesep,folders_a(act_data_a).name];
load([load_active,filesep,'scan.mat']);
files=dir([load_active,filesep,'*deformation_response.mat']);
load([load_active,filesep,files(1).name]);
%now I check if we are intrestedin x or y
if handles.response_function_dirrection == 'X'
scan_xory(1,:) =x_scan(1,:); %for some reason here the first row is already in µm
scan_xory(2,:) =x_scan(4,:)./x_scan(8,:);
elseif handles.response_function_dirrection == 'Y'
scan_xory(1,:) =y_scan(2,:);
scan_xory(2,:) =y_scan(6,:)./y_scan(8,:);
else
throw('unknown direction')
end
%now I cut the scan to only show the region between max and min
[v,mins]=min(scan_xory(2,:));
[v,maxs]=max(scan_xory(2,:));
scan=scan_xory(:,min([mins,maxs]):max([mins,maxs]));
%here scan isnot the array that I will use for the interpolation.
%now I have to load each frequency data and realanyze the data
files=dir([load_active,filesep,'*deformation_response.mat']);
for j=1:length(files)
load([load_active,filesep,files(j).name]);
data=squeeze(data);
xy_k=-xy_k;
if handles.response_function_dirrection == 'X'
bead_pos_rel=interp1(scan(2,:),scan(1,:),data(4,:)./data(8,:))
bead_pos_xory=-data(1,:)/cal(5)*1e-6+bead_pos_rel;
% x=-data(1,:)/cal(5)*1e-6+1./(xy_slopes(1).*1e6).*data(4,:)./data(8,:);
Fxory=xy_k(1).bead_pos_rel;
elseif handles.response_function_dirrection == 'Y'
bead_pos_rel=interp1(scan(2,:),scan(1,:),data(6,:)./data(8,:))
bead_pos_xory=-data(2,:)/cal(6)*1e-6+bead_pos_rel;
% x=-data(1,:)/cal(5)*1e-6+1./(xy_slopes(1).*1e6).*data(4,:)./data(8,:);
Fxory=xy_k(2).bead_pos_rel;
end
p=length(x);
alpha_xory=fft(bead_pos_xory)./fft(Fxory);
alpha_xory=alpha_xory(1:p/2+1);
fr=rate/p*([0:p/2]);
%now pick the right value
[a,b]=min(abs(f-fr));
response_xory(j)=alpha_x(b);
freq(j)=f;
end
% ------------- additional Function-------------
function [response_xory,freq]=correct_response_hf(handles)
%first I need to load the scan data
folders=handles.folders;
folders_a=handles.folders_a;
act_data_a=get(handles.listbox_active,'Value');
load_active=[handles.dir,filesep,folders(handles.current_folder).name,filesep,folders_a(act_data_a).name];
%fist I load the hf dataset, then I calculate the prefactor to make the
%effective movement minimal
files=dir([load_active,filesep,'*deformation_response.mat']);
load([load_active,filesep,files(1).name]);
data=squeeze(data);
x_rel=1./(xy_slope(1).*1e6).*data(4,:)./data(8,:);
x_trap=-data(1,:)/cal(5)*1e-6;
%x_rel=x_rel-mean(x_rel);
%x_trap=x_trap-mean(x_trap);
n=0;
for j=0.05:0.05:3
n=n+1;
pf_int(n)=var((1/j*x_rel(1:50)+x_trap(1:50)));
end
[v,pf]=min(pf_int);
pf=0.05*pf
for j=1:length(files)
load([load_active,filesep,files(j).name]);
data=squeeze(data);
[alpha_x,alpha_y, fr]=get_response_AOD(squeeze(data),f,pf*xy_slope,xy_k,cal,s_eff);
if handles.response_function_dirrection == 'X'
alpha_xory=alpha_x;
elseif handles.response_function_dirrection == 'Y'
alpha_xory=alpha_y;
end
p=length(data);
%now pick the right value
[a,b]=min(abs(f-fr));
response_xory(j)=alpha_x(b);
freq(j)=f;
end