|
@@ -1,188 +0,0 @@
|
|
|
-function [max_force_left, max_force_right] = ISP_MoBi_get_maximal_force(window, misure_schermo, ifi,s,time_x_avg, estimation_time)
|
|
|
-
|
|
|
-[ifi_af, ifi_as, ifi_nf, ifi_ns] = MoBI_frames_Brescia(ifi, ifi);
|
|
|
-
|
|
|
-[onesec_af, onesec_as, onesec_nf, onesec_ns] = MoBI_frames_Brescia(1, ifi);
|
|
|
-
|
|
|
-
|
|
|
-%% INSTRUCTION FOR FORCE ESTIMATION LEFT SIDE
|
|
|
-
|
|
|
-Screen('FillRect', window, [0 0 0], misure_schermo);
|
|
|
-
|
|
|
-Screen('TextSize', window, 20);
|
|
|
-DrawFormattedText(window, 'al "Via!" premi il sensore SINISTRO più possibile fino allo "stop" ', 'center',...
|
|
|
- 'center', [1 1 1]);
|
|
|
-
|
|
|
-[VBL]=Screen(window, 'Flip', ifi, 1);
|
|
|
-
|
|
|
-
|
|
|
-%% WAIT FOR A KEYBOARD TYPING
|
|
|
-
|
|
|
-KbStrokeWait
|
|
|
-
|
|
|
-
|
|
|
-%% DISPLAY 1, 2, 3, Via!
|
|
|
-
|
|
|
-for p = 1:3
|
|
|
-
|
|
|
- Screen('FillRect', window, [0 0 0], misure_schermo);
|
|
|
-
|
|
|
- Screen('TextSize', window, 80);
|
|
|
- DrawFormattedText(window, num2str(p), 'center',...
|
|
|
- 'center', [1 1 1]);
|
|
|
-
|
|
|
- [VBL]=Screen(window, 'Flip', VBL+onesec_as, 1);
|
|
|
-end
|
|
|
-
|
|
|
-Screen('FillRect', window, [0 0 0], misure_schermo);
|
|
|
-
|
|
|
-Screen('TextSize', window, 80);
|
|
|
-DrawFormattedText(window, 'Via!', 'center',...
|
|
|
- 'center', [1 1 1]);
|
|
|
-
|
|
|
-[VBL]=Screen(window, 'Flip', VBL+onesec_as, 1);
|
|
|
-
|
|
|
-
|
|
|
-estimation_max_force_time = estimation_time;
|
|
|
-
|
|
|
-% wait 0.2 sec after Via! appeared...
|
|
|
-WaitSecs(0.2)
|
|
|
-
|
|
|
-
|
|
|
-%% READ VALUES FROM A0 (FIRST PIN) --> GET MAXIMAL FORCE
|
|
|
-
|
|
|
-for t = 1:round(estimation_max_force_time/ifi_ns); % for the number of refreshes in the estimation time...
|
|
|
-
|
|
|
- % ardunio writes onto the serial port, matlab reads
|
|
|
- tmp_value{t} = MoBi_scrittura(s);
|
|
|
-
|
|
|
- % strsplit the 3 values that are read from the three pins in arduino
|
|
|
- tmp2{t} = (strsplit(tmp_value{t}, '_'));
|
|
|
-
|
|
|
- % convert the reading from sgtring to double type
|
|
|
- sensore_val(t) = str2double(tmp2{t}{1});
|
|
|
-
|
|
|
- % do the process at each refresh rate...
|
|
|
-
|
|
|
- Screen('FillRect', window, [0 0 0], misure_schermo);
|
|
|
- Screen('TextSize', window, 80);
|
|
|
- DrawFormattedText(window, num2str(sensore_val(t)), 'center',...
|
|
|
- 'center', [1 1 1]);
|
|
|
- [VBL]=Screen(window, 'Flip', VBL+ifi_as, 1);
|
|
|
-
|
|
|
-
|
|
|
-end
|
|
|
-
|
|
|
-step =(round(time_x_avg/ifi,0));
|
|
|
-for rng = 1:size(sensore_val,2)-step
|
|
|
-
|
|
|
- sensore_val_avg(rng) = mean(sensore_val(1,rng:rng+step),2);
|
|
|
-
|
|
|
-end
|
|
|
-
|
|
|
-
|
|
|
-% find the maximal value from the recorded series
|
|
|
-max_force_left = max(sensore_val_avg);
|
|
|
-
|
|
|
-% stop recording and show STOP label
|
|
|
-Screen('FillRect', window, [0 0 0], misure_schermo);
|
|
|
-Screen('TextSize', window, 80);
|
|
|
-DrawFormattedText(window, 'Stop', 'center',...
|
|
|
- 'center', [1 1 1]);
|
|
|
-[VBL]=Screen(window, 'Flip', VBL+onesec_as, 1);
|
|
|
-
|
|
|
-% wait befroe going on (we do not care about precision time here)
|
|
|
-WaitSecs(0.5)
|
|
|
-
|
|
|
-
|
|
|
-%% QUESTO VA ELIMINATO
|
|
|
-
|
|
|
-max_force_right = 900;
|
|
|
-% %% INSTRUCTION FOR FORCE ESTIMATION RIGHT SIDE
|
|
|
-% %HideCursor
|
|
|
-%
|
|
|
-% Screen('FillRect', window, [0 0 0], misure_schermo);
|
|
|
-%
|
|
|
-% Screen('TextSize', window, 20);
|
|
|
-% DrawFormattedText(window, 'al "Via!" premi il sensore DESTRO più possibile fino allo "stop" ', 'center',...
|
|
|
-% 'center', [1 1 1]);
|
|
|
-%
|
|
|
-% [VBL]=Screen(window, 'Flip', ifi, 1);
|
|
|
-%
|
|
|
-% %% WAIT FOR A KEYBOARD TYPING
|
|
|
-% KbStrokeWait
|
|
|
-%
|
|
|
-% %% DISPLAY 1, 2, 3, Via!
|
|
|
-% for p = 1:3
|
|
|
-%
|
|
|
-% Screen('FillRect', window, [0 0 0], misure_schermo);
|
|
|
-%
|
|
|
-% Screen('TextSize', window, 80);
|
|
|
-% DrawFormattedText(window, num2str(p), 'center',...
|
|
|
-% 'center', [1 1 1]);
|
|
|
-%
|
|
|
-% [VBL]=Screen(window, 'Flip', VBL+onesec_as, 1);
|
|
|
-% end
|
|
|
-%
|
|
|
-% Screen('FillRect', window, [0 0 0], misure_schermo);
|
|
|
-%
|
|
|
-% Screen('TextSize', window, 80);
|
|
|
-% DrawFormattedText(window, 'Via!', 'center',...
|
|
|
-% 'center', [1 1 1]);
|
|
|
-%
|
|
|
-% [VBL]=Screen(window, 'Flip', VBL+onesec_as, 1);
|
|
|
-%
|
|
|
-%
|
|
|
-% estimation_max_force_time = estimation_time;
|
|
|
-%
|
|
|
-% % wait 1 sec after Via! appeared...
|
|
|
-% WaitSecs(0.2)
|
|
|
-%
|
|
|
-%
|
|
|
-%
|
|
|
-%
|
|
|
-%
|
|
|
-% %% READ VALUES FROM A1 (SECOND PIN) --> GET MAXIMAL FORCE on the RIGHT side
|
|
|
-%
|
|
|
-% for t = 1:round(estimation_max_force_time/ifi_ns); % for the number of refreshes in the estimation time...
|
|
|
-%
|
|
|
-% % ardunio writes onto the serial port, matlab reads
|
|
|
-% tmp_value{t} = MoBi_scrittura(s);
|
|
|
-%
|
|
|
-% % strsplit the 3 values that are read from the three pins in arduino
|
|
|
-% tmp2{t} = (strsplit(tmp_value{t}, '_'));
|
|
|
-%
|
|
|
-% % convert the reading from sgtring to double type
|
|
|
-% sensore_val(t) = str2double(tmp2{t}{2});
|
|
|
-%
|
|
|
-% % do the process at each refresh rate...
|
|
|
-%
|
|
|
-% Screen('FillRect', window, [0 0 0], misure_schermo);
|
|
|
-% Screen('TextSize', window, 80);
|
|
|
-% DrawFormattedText(window, num2str(sensore_val(t)), 'center',...
|
|
|
-% 'center', [1 1 1]);
|
|
|
-% [VBL]=Screen(window, 'Flip', VBL+ifi_as, 1);
|
|
|
-%
|
|
|
-% end
|
|
|
-%
|
|
|
-%
|
|
|
-% step =(round(time_x_avg/ifi,0));
|
|
|
-% for rng = 1:size(sensore_val,2)-step
|
|
|
-%
|
|
|
-% sensore_val_avg(rng) =mean(sensore_val(1,rng:rng+step),2);
|
|
|
-%
|
|
|
-% end
|
|
|
-%
|
|
|
-% % find the maximal value from the recorded series
|
|
|
-% max_force_right = max(sensore_val_avg);
|
|
|
-%
|
|
|
-% % stop recording and show STOP label
|
|
|
-% Screen('FillRect', window, [0 0 0], misure_schermo);
|
|
|
-% Screen('TextSize', window, 80);
|
|
|
-% DrawFormattedText(window, 'Stop', 'center',...
|
|
|
-% 'center', [1 1 1]);
|
|
|
-% [VBL]=Screen(window, 'Flip', VBL+onesec_as, 1);
|
|
|
-% % wait befroe going on (we do not care about precision time here)
|
|
|
-% WaitSecs(0.5)
|
|
|
-
|
|
|
-end
|