123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- function ISP_MoBi(PTP_name, first_block, last_block, volume)
- %%
- % e.g. ISP_MoBi('S99_O1', 1, 14, 0)
- % call the function as
- % ISP_MoBi(PTP_name, number of the initial block, number of the last block, volume)
- % where...
- % PTP_name --> the participant code which has to be SXX_OXX i.e.
- % participant number followed by the block order
- % first_block and last_block --> first and last block you want to run
- % volume --> volume of the noise played in the earphones (it has been set to zero, since the volume was set manually)
- %%
- addpath('C:\Users\neuro\Desktop\script_mobi_da_commentare\arduino_for_MoBi');
- % initialize forces variable
- %forces = 0;
- % forces.max_force_left = 969.8065;
- % the original function for force estimation estiamted the maximal force for
- % both hands. In the present work we only needed the left one. However we
- % kept the original function as it was and set a mock value for the maximal right hand force.
- % So, within the ISP_MoBi_sequence_MEP and ISP_MoBi_sequence functions there
- % is still code for the right hand estimation which has not been used and does not affect the left hand maximal force estimation.
- % leftover from the original maximal_force script (in the present version
- % the maximal force has been estimated only for the left hand.
- % "forces.max_force_right = 900" works as a place holder).
- forces.max_force_right = 900;
- % from the first to the last block -->
- % set PTP data and file name to be saved after the block run
- % if the block is odd --> present instructions and set the force
- % threshold
- for bl = first_block:last_block
-
- [data_subject,R] = MoBi_save_settings();
-
- cd 'C:\Users\neuro\Desktop\script_mobi_da_commentare'
-
-
- % calculate the TMS thershold only in odd blocks
- if mod(bl,2) == 1
- % show instructions for the researcher (stimulation parameters: current orientation, pulsewave, muscular contraction)
- MoBi_instructions(R(bl,:), data_subject, volume, forces, bl);
-
- % TMS threshold estimation precedure
- TMS4Threshold_MoBi();
- % maximal force estimation of the left hand
- [forces] = ISP_MoBi_sequence_MEP(R(bl,:), data_subject, volume, forces, bl);
- end
-
-
- % actual code for experiment running
- [forces] = ISP_MoBi_sequence(R(bl,:), data_subject, volume, forces, bl);
-
- end
- %%
- % the function outputs the name of the next block and the structure of the
- % session
- function [data_subject,R] = MoBi_save_settings()
-
- % extract and separate both the name and the order of PTP_name
- order_tmp = strsplit(PTP_name, '_');
- % get only the order
- stim_order = order_tmp{2};
-
-
-
- % right hand instruction (always relaxed)
- istruzione_mano_dx = [{'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'}; {'Rilassata'};...
- {'Rilassata'};{'Rilassata'}];
-
-
-
- switch stim_order
-
- % choose the paramters sequence for each order
- case {'O1'}
- stim = [{'Mono_PA'};{'Mono_PA'};...
- {'Mono_AP'};{'Mono_AP'};...
- {'Mono_LM'};{'Mono_LM'};...
- {'Bi_PA_contracted'};{'Bi_PA_contracted'};...
- {'Bi_AP'}; {'Bi_AP'};...
- {'Bi_LM'};{'Bi_LM'};...
- {'Bi_PA'};{'Bi_PA'}];
-
- % choose the state of the left hand
- istruzione_mano_sx = [{'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Contratta'};{'Contratta'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'}; {'Rilassata'};...
- {'Rilassata'};{'Rilassata'}];
-
- case {'O2'}
-
- stim = [{'Mono_AP'};{'Mono_AP'};...
- {'Mono_LM'};{'Mono_LM'};...
- {'Bi_PA_contracted'};{'Bi_PA_contracted'};...
- {'Bi_AP'}; {'Bi_AP'};...
- {'Bi_LM'};{'Bi_LM'};...
- {'Bi_PA'};{'Bi_PA'};...
- {'Mono_PA'};{'Mono_PA'}];
-
-
- istruzione_mano_sx = [{'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Contratta'};{'Contratta'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'}; {'Rilassata'};...
- {'Rilassata'};{'Rilassata'}];
-
- case {'O3'}
- stim = [{'Mono_LM'};{'Mono_LM'};...
- {'Bi_PA_contracted'};{'Bi_PA_contracted'};...
- {'Bi_AP'}; {'Bi_AP'};...
- {'Bi_LM'};{'Bi_LM'};...
- {'Bi_PA'};{'Bi_PA'};...
- {'Mono_PA'};{'Mono_PA'};...
- {'Mono_AP'};{'Mono_AP'}];
-
-
- istruzione_mano_sx = [{'Rilassata'};{'Rilassata'};...
- {'Contratta'};{'Contratta'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'}; {'Rilassata'};...
- {'Rilassata'};{'Rilassata'}];
-
- case {'O4'}
- stim = [{'Bi_PA_contracted'};{'Bi_PA_contracted'};...
- {'Bi_AP'}; {'Bi_AP'};...
- {'Bi_LM'};{'Bi_LM'};...
- {'Bi_PA'};{'Bi_PA'};...
- {'Mono_PA'};{'Mono_PA'};...
- {'Mono_AP'};{'Mono_AP'};...
- {'Mono_LM'};{'Mono_LM'}];
-
-
- istruzione_mano_sx = [ {'Contratta'};{'Contratta'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'}; {'Rilassata'};...
- {'Rilassata'};{'Rilassata'}];
-
-
- case {'O5'}
- stim = [{'Bi_AP'}; {'Bi_AP'};...
- {'Bi_LM'};{'Bi_LM'};...
- {'Bi_PA'};{'Bi_PA'};...
- {'Mono_PA'};{'Mono_PA'};...
- {'Mono_AP'};{'Mono_AP'};...
- {'Mono_LM'};{'Mono_LM'};...
- {'Bi_PA_contracted'};{'Bi_PA_contracted'}];
-
- istruzione_mano_sx = [ {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'}; {'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Contratta'};{'Contratta'}];
-
- case {'O6'}
- stim = [{'Bi_LM'};{'Bi_LM'};...
- {'Bi_PA'};{'Bi_PA'};...
- {'Mono_PA'};{'Mono_PA'};...
- {'Mono_AP'};{'Mono_AP'};...
- {'Mono_LM'};{'Mono_LM'};...
- {'Bi_PA_contracted'};{'Bi_PA_contracted'};...
- {'Bi_AP'}; {'Bi_AP'}];
-
- istruzione_mano_sx = [ {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'}; {'Rilassata'};...
- {'Contratta'};{'Contratta'};...
- {'Rilassata'};{'Rilassata'}];
-
- case {'O7'}
- stim = [{'Bi_PA'};{'Bi_PA'};...
- {'Mono_PA'};{'Mono_PA'};...
- {'Mono_AP'};{'Mono_AP'};...
- {'Mono_LM'};{'Mono_LM'};...
- {'Bi_PA_contracted'};{'Bi_PA_contracted'};...
- {'Bi_AP'}; {'Bi_AP'};...
- {'Bi_LM'};{'Bi_LM'}];
-
- istruzione_mano_sx = [ {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Rilassata'};{'Rilassata'};...
- {'Contratta'};{'Contratta'};...
- {'Rilassata'}; {'Rilassata'};...
- {'Rilassata'};{'Rilassata'}];
-
- end
-
-
-
-
- % R is a table-like matrix containing
- % on the first column --> stimulation type
- % on the second column--> instructions for the left hand
- % relaxation/contraction
- % on the second column--> instructions for the right hand
- % relaxation/contraction (which is always relaxed)
- R = [stim istruzione_mano_sx istruzione_mano_dx];
-
-
-
- % get the date and time so that savings do not overwrite
- hour = clock;
-
- % put together into a string
- hour = strcat(num2str(hour(1)),...
- num2str(hour(2)),...
- num2str(hour(3)),'_',...
- num2str(hour(4)),...
- num2str(hour(5)),...
- num2str(round(hour(6))));
-
-
- % data_subject contains the string corresponding to the name of the block file .mat
- % this info will be used as input into the ISP_MoBi_sequence and MoBi_instructions
- % functions
- data_subject = strcat(PTP_name, '_', R{bl,1}, '_', R{bl,2}, '_', R{bl,3}, '_', num2str(bl), '_', hour, '.mat');
-
- end
- end
|