function go=setup
%Setup for identification experiment

global data 

disp(' ')
disp('Welcome to Lizard') %experiment name
disp(' ')

%Get subject number:
ok = 0;
while ~ok
    data.sub = input('Subject number: '); %waits for input from user
    if isequal(size(data.sub),[1 1]) %check that input is a single value (not a vector)
        if data.sub==round(data.sub) && data.sub>0 %check that input is a non-negative integer
            ok = 1; %can move on
        end
    end
    if ok == 0
        disp('Please enter a non-negative integer, or type Ctrl-C to exit')
    end
end

%Get subject status
ok = 0;
while ~ok
    in = input('Enter P if subject is paid, I if from intro psych: ','s'); %waits for text input from user
    if upper(in(1))=='P' %use only first character, converted to upper case
        data.paid = 1; %note that subject is paid
        ok = 1;
    elseif upper(in(1))=='I'
        data.paid = 0; %note that subject is for credit
        ok = 1;
    end
end

%Verify
disp(' ')
disp(['Subject number ' num2str(data.sub)])
if data.paid==1
    disp('Paid')
else
    disp('Credit')
end
answer = input('Is this correct [y/n]? ','s');
if upper(answer(1))~='Y'
    go = -1; %code for main experiment to terminate
    return
end

load SRmaps %datafile with stimulus-response map for subjects in every condition
data.map = SRmaps(mod(data.sub-1,72)+1,:)'; %72 conditions, determined by subject number; data.map(s) gives correct response for stimulus s
data.stim = []; %for storing stimulus sequence
data.resp = []; %for storing response sequence
data.RT = []; %for storing RT sequence
data.aborted = 0; %used for safe data saving when experiment aborted
go = 1; %code for main program to continue