function DataB=organizeData_makeParameters(presinfo,g,Schedule,DataB)
%keyboard;
for h = 1:length(presinfo(g).pres_log.indices.index_Question_you) % this should equate to the number of trials, as all trials of a Question You in them. h is thus a trial Nr index
    
    % s index of answers
    check_next_line_you = true;
    a_you = 0;
    check_next_line_other = true;
    a_other = 0;
    
    % Question self
    while check_next_line_you % Check following lines for response self, which is 1 or two until you find it
        if ~(strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Question_you(h)+ a_you), '1') ||  strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Question_you(h)+ a_you), '2'))
            check_next_line_you = true;
            a_you = a_you+1;
        else
            check_next_line_you = false;
        end
    end
    
    
    % Question other
    while check_next_line_other %Check following lines for response other, which is 1 or two until you find it
        if ~(strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Question_other(h)+ a_other), '1') ||  strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Question_other(h)+ a_other), '2'))
            check_next_line_other = true;
            a_other = a_other+1;
        else
            check_next_line_other = false;
        end
    end
    
    % Store presinfocome per participant
    presinfo(g).pres_log.indices.index_Answer_you(h) = presinfo(g).pres_log.indices.index_Question_you(h) + a_you;
    presinfo(g).pres_log.indices.index_Answer_other(h) = presinfo(g).pres_log.indices.index_Question_other(h) + a_other;
    presinfo(g).pres_log.timing.Answer_you = presinfo(g).pres_log.time(presinfo(g).pres_log.indices.index_Answer_you);
    presinfo(g).pres_log.timing.Answer_other = presinfo(g).pres_log.time(presinfo(g).pres_log.indices.index_Answer_other);
    %keyboard;
    % Compute participants' answers for question self
    if strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Question_you(h)), 'Question_you_bluered')
        redfirst_self(h)=0;
        if strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Answer_you(h)), '1')
            redchoice_self(h)=0;
        elseif strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Answer_you(h)), '2')
            redchoice_self(h)=1;
        elseif strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Answer_you(h)), '3')
            redchoice_self(h)=nan;
        end
    elseif strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Question_you(h)), 'Question_you_redblue')
        redfirst_self(h)=1;
        if strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Answer_you(h)), '1')
            redchoice_self(h)=1;
        elseif strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Answer_you(h)), '2')
            redchoice_self(h)=0;
        elseif strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Answer_you(h)), '3')
            redchoice_self(h)=nan;
        end
    end
    
    % Compute participants' answers for question other
    if strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Question_other(h)), 'Question_other_bluered')
        presinfo(g).pres_log.answer.other.redfirst(h) = 0;
        redfirst_other(h)= 0;
        if strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Answer_other(h)), '1')
            redchoice_other(h)= 0;
        elseif strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Answer_other(h)), '2')
            redchoice_other(h)= 1;
            
        elseif strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Answer_other(h)), '3')
            redchoice_other(h)= nan;
        end
    elseif strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Question_other(h)), 'Question_other_redblue')
        redfirst_other(h)= 1;
        if strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Answer_other(h)), '1')
            redchoice_other(h)= 1;
        elseif strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Answer_other(h)), '2')
            redchoice_other(h)= 0;
        elseif strcmp(presinfo(g).pres_log.codes(presinfo(g).pres_log.indices.index_Answer_other(h)), '3')
           redchoice_other(h)= nan;
            
        end
    end
    
    % Compute correctness of answer for question self
    redcorrect(h)=Schedule(g).MainSchedule.OverallEvidence(h) < 0;
    %This only works because there is only two responses and thus if red
    %wasn't chosen when not correct choice they automatically were correct
    %and when it wasn't chosen when it was correct they are automatically
    %incorrect.
    if (redchoice_self(h) == redcorrect(h))
        correct_self(h) = 1;
    elseif (redchoice_self(h) ~= redcorrect(h))
       correct_self(h) = 0;
    end
    
    otherredcorrect(h)=Schedule(g).MainSchedule.OtherEvidence(h) < 0;
    % Compute correctness of answer for question other
    if redchoice_other(h) == otherredcorrect(h)
        correct_other(h) = 1;
    elseif redchoice_other(h) ~= otherredcorrect(h)
        correct_other(h) = 0;
    end
    
end


     
% find trials where an agent ability rating was requested and store in matrix
for t = 1:length(presinfo(g).pres_log.indices.index_Start_ability)
    %find index of closest trial onset (Welcome)
    trial_ability_matrix(t,1) = max(find(presinfo(g).pres_log.indices.index_Welcome(presinfo(g).pres_log.indices.index_Welcome < presinfo(g).pres_log.indices.index_Start_ability(t))));
    %find closest index of end ability rating to  current rating beginning.
    end_ability_index(t,1) = presinfo(g).pres_log.indices.index_End_ability(min(find(presinfo(g).pres_log.indices.index_End_ability > presinfo(g).pres_log.indices.index_Start_ability(t))));
end
%keyboard;
% Store the agent_ID per rating trials in a matrix. These ID's are just
% according to block number!
for d = 1:length(trial_ability_matrix(:,1)) % Indexes all ability ratings
    % because we have 4 agents in equally long blocks we can divide
    % responses to agent ID's equally
    if trial_ability_matrix(d,1) <= length(presinfo(g).pres_log.indices.index_Welcome)/4 % If first 1/4...
        agent_ID(d,1) = 1;
        currentAgentID(1:length(presinfo(g).pres_log.indices.index_Welcome)/4)=1;
    elseif (trial_ability_matrix(d,1) > length(presinfo(g).pres_log.indices.index_Welcome)/4) && (trial_ability_matrix(d,1) <= (length(presinfo(g).pres_log.indices.index_Welcome)/4)*2)
        agent_ID(d,1) = 2;
        currentAgentID(length(presinfo(g).pres_log.indices.index_Welcome)/4+1:(length(presinfo(g).pres_log.indices.index_Welcome)/4)*2)=2;
    elseif (trial_ability_matrix(d,1) > 2*(length(presinfo(g).pres_log.indices.index_Welcome)/4)) && (trial_ability_matrix(d,1) <= (length(presinfo(g).pres_log.indices.index_Welcome)/4)*3)
        agent_ID(d,1) = 3;
        currentAgentID((length(presinfo(g).pres_log.indices.index_Welcome)*2)/4+1:(length(presinfo(g).pres_log.indices.index_Welcome)/4)*3)=3;
    elseif trial_ability_matrix(d,1) > 3*(length(presinfo(g).pres_log.indices.index_Welcome)/4)
        agent_ID(d,1) = 4;
        currentAgentID((length(presinfo(g).pres_log.indices.index_Welcome)*3)/4+1:length(presinfo(g).pres_log.indices.index_Welcome) )=4;
    end
end



%% Agent Rating
% Loop over rating trials
for s = 1:size(agent_ID, 1)
    %Variables for ability rating
    start_count = 5;
    plus_count = 0;
    minus_count = 0;
    check_next_line = false;
    % Compute rating by counting the number of button presses and
    % extracting the final position of the slider
    for l = presinfo(g).pres_log.indices.index_Start_ability(s):end_ability_index(s,1)
        if ~strcmp(presinfo(g).pres_log.codes(l), 'end_ability')  %to marius: Isn't this a bit redundant as we already only use index between end and beginning of rating peroid?
            check_next_line = true;
        else
            check_next_line = false;
        end
        if check_next_line
            if strcmp(presinfo(g).pres_log.codes(l+1), '1')
                minus_count = minus_count +1;
            elseif strcmp(presinfo(g).pres_log.codes(l+1), '2')
                plus_count = plus_count +1;
            end
        end
    end
    % Store in matrix
    agent_rating(s, 1) = start_count + plus_count - minus_count;
    % In case participants pressed a button too often set it to the
    % respective min and max of the rating scale which here means 1 or 10
    if agent_rating(s, 1) <= 1
        agent_rating(s, 1) = 1;
    elseif agent_rating(s, 1) >= 10
        agent_rating(s, 1) = 10;
    end
end

% Store start and end indices of the rating trials in matrix and struct
start_ability_index(:,1) = presinfo(g).pres_log.indices.index_Start_ability;

% Save other indices in Matrix
index_Welcome = presinfo(g).pres_log.indices.index_Welcome;
index_Question_you =  presinfo(g).pres_log.indices.index_Question_you;
index_Question_other =  presinfo(g).pres_log.indices.index_Question_other;
index_Answer_you = presinfo(g).pres_log.indices.index_Answer_you;
index_Answer_other = presinfo(g).pres_log.indices.index_Answer_other;
index_allsamples=presinfo(g).pres_log.indices.index_Screen;
index_Pulses=presinfo(g).pres_log.indices.index_Pulse;


% Extract reaction times for self and other choices
rt_self = presinfo(g).pres_log.time(presinfo(g).pres_log.indices.index_Answer_you) - presinfo(g).pres_log.time(presinfo(g).pres_log.indices.index_Question_you);
rt_other = presinfo(g).pres_log.time(presinfo(g).pres_log.indices.index_Answer_other) - presinfo(g).pres_log.time(presinfo(g).pres_log.indices.index_Question_other);

% Compute chance to answer red/blue per bin of shared information for self and other
evidence_self = (Schedule(g).MainSchedule.OverallEvidence)';
evidence_other = (Schedule(g).MainSchedule.OtherEvidence)';

bluechoice_self = ~redchoice_self;
bluechoice_other = ~redchoice_other;

ev_shared =  Schedule(g).MainSchedule.OtherEvidence;

% First set samples matrix to nan where a sample was occluded
sharedsamples=nan(size(Schedule(g).MainSchedule.AllOscuredsamples,1),Schedule(g).MainSchedule.MaxSampleLength);
sharedsamples(~isnan(Schedule(g).MainSchedule.SampleSignals)')=1;
for r = 1:size(Schedule(g).MainSchedule.AllOscuredsamples, 1)
    sharedsamples(r, Schedule(g).MainSchedule.AllOscuredsamples(r,~isnan(Schedule(g).MainSchedule.AllOscuredsamples(r,:)))) = 0;
end
occluded_samples=zeros(size(Schedule(g).MainSchedule.AllOscuredsamples,1),Schedule(g).MainSchedule.MaxSampleLength);
occluded_samples(sharedsamples==0) = 1;
occluded_samples(isnan(sharedsamples))=nan;
% absolute difference of occluded evidence
evidence_occ(:, 1) = abs(Schedule(g).MainSchedule.OverallEvidence'-Schedule(g).MainSchedule.OtherEvidence'); %note to Marius: Important to not do abs before difference because evidence occ can flip the sign of evidence!
% Signed difference of occluded evidence
evidence_occ_sided(:, 1) = Schedule(g).MainSchedule.OverallEvidence- Schedule(g).MainSchedule.OtherEvidence;
NegativeEvidShared=Schedule(g).MainSchedule.OtherEvidence<0;
NegativeEvidSelf=Schedule(g).MainSchedule.OverallEvidence<0;

for t=1:length(Schedule(g).MainSchedule.OverallEvidence)
    if ~NegativeEvidShared(t)
        evidence_occ_confirmatory(t, 1)= Schedule(g).MainSchedule.OverallEvidence(t)- Schedule(g).MainSchedule.OtherEvidence(t);
    elseif NegativeEvidShared(t)
        evidence_occ_confirmatory(t, 1)= -(Schedule(g).MainSchedule.OverallEvidence(t)- Schedule(g).MainSchedule.OtherEvidence(t));
    end
end
Signals=Schedule(g).MainSchedule.SampleSignals';

for t=1:size(occluded_samples,1)
    occludedSignals(t,1:nansum(occluded_samples(t,:)))=Signals(t,occluded_samples(t,:)==1);
    sharedSignals(t,1:nansum(sharedsamples(t,:))) =Signals(t,sharedsamples(t,:)==1);
end

% make Trialwise Agentabilitylvl vector
for t=1:length(currentAgentID)
    DataB.AgentAbilityLvl(t,g)= Schedule(g).MainSchedule.AgentAblLvL(currentAgentID(t));
end

%Make stacked regressors /vectors for analysis of all Samples together
Samplesstacked=[];SampleNrStacked=[];sharedIDStacked=[];occludedIDStacked=[];occlSamplesstacked=[];sharedSamplesstacked=[];AgentAbilityLvlsstacked=[];
stackedPriorEvidenceShared=[];stackedPriorEvidenceAll=[];OcclSampleNrStacked=[];
for t=1:size(Signals,1)
NrSamples(t,1)=sum(~isnan(Signals(t,:)));
    Samplesstacked      =[Samplesstacked;Signals(t,~isnan(Signals(t,:)))'];
    occludedID=occluded_samples(t,1:NrSamples(t,1))==1;
    sharedID=sharedsamples(t,1:NrSamples(t,1))==1;
    SampleNrStacked     =[SampleNrStacked;(1:NrSamples(t,1))'];
    occlSampletemp=nan(NrSamples(t,1),1);
    occlSampletemp(occludedID)=1:sum(occludedID);
    OcclSampleNrStacked=[OcclSampleNrStacked;occlSampletemp];
    sharedIDStacked     =[sharedIDStacked;sharedID'];
    occludedIDStacked   =[occludedIDStacked;occludedID'];
    occlSamplesstacked  =[occlSamplesstacked;Signals(t,~isnan(Signals(t,:)))'.*occludedID'];
    sharedSamplesstacked=[sharedSamplesstacked;Signals(t,~isnan(Signals(t,:)))'.*sharedID'];
    AgentAbilityLvlsstacked=[AgentAbilityLvlsstacked;repmat(DataB.AgentAbilityLvl(t,g),NrSamples(t,1),1)];
     TrSharedSignals=Signals(t,~isnan(Signals(t,:)))'.*sharedID';
    PrevSharedSignals=[0;TrSharedSignals(1:end-1)];
    PriorShared=cumsum(PrevSharedSignals);
    tempSignals=Signals(t,~isnan(Signals(t,1:end)))';
    PrevSignals=[0;tempSignals(1:end-1)];
    PriorAll=cumsum(PrevSignals);
    stackedPriorEvidenceShared=[stackedPriorEvidenceShared;PriorShared];  
    stackedPriorEvidenceAll   =[stackedPriorEvidenceAll;PriorAll];
    %keyboard;
end
%Save timing
DataB.Subject(g).timings.TimeWelcome=presinfo(g).pres_log.time(index_Welcome);
DataB.Subject(g).timings.TimeQuestionyou=presinfo(g).pres_log.time(index_Question_you);
DataB.Subject(g).timings.TimeQuestionother=presinfo(g).pres_log.time(index_Question_other);
DataB.Subject(g).timings.TimeAnsweryou=presinfo(g).pres_log.time(index_Answer_you);
DataB.Subject(g).timings.TimeAnswerother=presinfo(g).pres_log.time(index_Answer_other);
DataB.Subject(g).timings.TimeAllSamples=presinfo(g).pres_log.time(index_allsamples);
DataB.Subject(g).timings.Pulses=presinfo(g).pres_log.time(index_Pulses);


AllSamples=sharedsamples+occluded_samples;
ind=0;
indexSampleSeparated=nan(size(AllSamples,1),size(AllSamples,2));
indexoccSampleSeparated=nan(size(AllSamples,1),size(AllSamples,2));
indexsharedSampleSeparated=nan(size(AllSamples,1),size(AllSamples,2));

indexoccSampleOnlySeparated=nan(size(AllSamples,1),max(sum(occluded_samples,2)));
indexsharedSampleOnlySeparated=nan(size(AllSamples,1),max(sum(sharedsamples,2)));

for t=1:size(AllSamples,1)
    for s=1:nansum(AllSamples(t,:))
        ind=ind+1;
        indexSampleSeparated(t,s)=index_allsamples(ind);
        if occluded_samples(t,s)==1
            indexoccSampleSeparated(t,s)=index_allsamples(ind);
        elseif sharedsamples(t,s)==1
            indexsharedSampleSeparated(t,s)=index_allsamples(ind);
        end              
    end
    for Oc=1:nansum(occluded_samples(t,:))
     tem=indexoccSampleSeparated(t,~isnan(indexoccSampleSeparated(t,:)));
     indexoccSampleOnlySeparated(t,Oc)=tem(Oc);
    end
    for shar=1:nansum(sharedsamples(t,:))
     tem=indexsharedSampleSeparated(t,~isnan(indexsharedSampleSeparated(t,:)));
     indexsharedSampleOnlySeparated(t,shar)=tem(shar);
    end
    
end

for s=1:size(indexSampleSeparated,2)
    indexsampleslot{s}=indexSampleSeparated(~isnan(indexSampleSeparated(:,s)),s);
    indexsampleslotocc{s}=indexoccSampleSeparated(~isnan(indexoccSampleSeparated(:,s)),s);
    indexsampleslotshared{s}=indexsharedSampleSeparated(~isnan(indexsharedSampleSeparated(:,s)),s);
    DataB.Subject(g).timings.sampleslot{s}      =      presinfo(g).pres_log.time(indexsampleslot{s});
    DataB.Subject(g).timings.sampleslotocc{s}   =      presinfo(g).pres_log.time(indexsampleslotocc{s});
    DataB.Subject(g).timings.sampleslotshared{s}=      presinfo(g).pres_log.time(indexsampleslotshared{s});    
end

for s=1:size(indexoccSampleOnlySeparated,2)
 index=   indexoccSampleOnlySeparated(~isnan(indexoccSampleOnlySeparated(:,s)),s);
DataB.Subject(g).timings.samplesseparateoccOnly   =      presinfo(g).pres_log.time(index);
end

for s=1:size(indexsharedSampleOnlySeparated,2)
 index=   indexsharedSampleOnlySeparated(~isnan(indexsharedSampleOnlySeparated(:,s)),s);
DataB.Subject(g).timings.samplesseparatesharedOnly   =      presinfo(g).pres_log.time(index);
end



% Save presinfoput in matrix format for DataB

 
%% Save data for participant g
disp(['Saving organized Data for ParticipantID:' presinfo(g).SubjectIDs{g}  ' and number:' num2str(g) ])
% Participant behaviour
% Self
DataB.Subject(g).decision.self.redfirst = redfirst_self;
DataB.Subject(g).decision.self.redchoice =  redchoice_self;
DataB.Subject(g).decision.self.correct = correct_self ;
DataB.Subject(g).decision.self.redcorrect=redcorrect;
% Other
DataB.Subject(g).decision.other.redfirst = redfirst_other;
DataB.Subject(g).decision.other.redchoice = redchoice_other;
DataB.Subject(g).decision.other.correct =  correct_other;
DataB.Subject(g).decision.other.redcorrect = otherredcorrect;
% Presentation log variables
DataB.Subject(g).time = presinfo(g).pres_log.time;
DataB.Subject(g).codes = presinfo(g).pres_log.codes;
DataB.Subject(g).event = presinfo(g).pres_log.event_type;
DataB.Subject(g).reaction_time.self = rt_self;
DataB.Subject(g).reaction_time.other = rt_other ;
% Agent rating
DataB.Subject(g).agent_rating.agent_ID = agent_ID;
DataB.Subject(g).agent_rating.trial = trial_ability_matrix;
DataB.Subject(g).agent_rating.score = agent_rating;
% Indices
DataB.Subject(g).indices.welcome = presinfo(g).pres_log.indices.index_Welcome;
DataB.Subject(g).indices.screen = presinfo(g).pres_log.indices.index_Screen;
DataB.Subject(g).indices.question_you = presinfo(g).pres_log.indices.index_Question_you;
DataB.Subject(g).indices.answer_you = presinfo(g).pres_log.indices.index_Answer_you;
DataB.Subject(g).indices.question_other= presinfo(g).pres_log.indices.index_Question_other;
DataB.Subject(g).indices.answer_other = presinfo(g).pres_log.indices.index_Answer_other;
DataB.Subject(g).indices.start_ability = presinfo(g).pres_log.indices.index_Start_ability;
DataB.Subject(g).indices.end_ability = presinfo(g).pres_log.indices.index_End_ability;
% Evidence
DataB.Subject(g).evidence.shared = evidence_other;
DataB.Subject(g).evidence.occluded = evidence_occ;
DataB.Subject(g).evidence.total = evidence_other + evidence_occ;
% Sanity Check to see whether both agree as they should
if DataB.Subject(g).evidence.total ~= Schedule(g).MainSchedule.OverallEvidence;keyboard;end
% Subject and schedule information
DataB.Subject(g).ID = presinfo(g).SubjectIDs{g};
DataB.ID{g} = presinfo(g).SubjectIDs{g};
DataB.Subject(g).schedule.MainSchedule.rating_trials = trial_ability_matrix;

%% Make Struct for data in matrix format
% Agent rating
DataB.agent_rating.start_ability_index(:,g) = start_ability_index;
DataB.agent_rating.end_ability_index(:,g) = end_ability_index;
DataB.agent_rating.trialnr(:,g) = trial_ability_matrix;
DataB.agent_rating.ID(:,g) = agent_ID;
DataB.agent_rating.score(:,g) = agent_rating;
DataB.agent_rating.AbilityLvls(:,g)=Schedule(g).MainSchedule.AgentAblLvL;
%keyboard;
%Behavioural Data All participants in one matrix
DataB.decision.self.redchoice(:,g) = redchoice_self;
DataB.decision.other.redchoice(:,g) = redchoice_other;
DataB.decision.self.redfirst_self(:,g) =  redfirst_self;
DataB.decision.other.redfirst_other(:,g) =  redfirst_other;
DataB.decision.other.correct(:,g) = correct_other;
DataB.decision.self.correct(:,g) = correct_self;
DataB.decision.self.reaction_time(:,g) = rt_self;
DataB.decision.other.reaction_time(:,g) = rt_other;
DataB.currentAgentID(:,g)=currentAgentID;


DataB.occluded_samples(:,:,g)=occluded_samples;
DataB.sharedsamples(:,:,g)=sharedsamples;

%Signals
DataB.occludedSignals(:,:,g)=occludedSignals;
DataB.sharedSignals(:,:,g)=sharedSignals;
DataB.Signals(:,:,g)=Signals;

DataB.stacked{g}.Samples=Samplesstacked;
DataB.stacked{g}.SampleNr=SampleNrStacked;
DataB.stacked{g}.OcclSampleNr=OcclSampleNrStacked;
DataB.stacked{g}.sharedID=sharedIDStacked;
DataB.stacked{g}.occludedID=occludedIDStacked;
DataB.stacked{g}.occlSamples=occlSamplesstacked;
DataB.stacked{g}.sharedSamples=sharedSamplesstacked;
DataB.stacked{g}.AgentAbilitylvl=AgentAbilityLvlsstacked;
DataB.stacked{g}.stackedPriorEvidenceAll =stackedPriorEvidenceAll ;
DataB.stacked{g}.stackedPriorEvidenceShared =stackedPriorEvidenceShared ;
 


%Evidence
DataB.evidence.occluded(:,g) = evidence_occ;
DataB.evidence.occluded_sided(:,g) = evidence_occ_sided;
DataB.evidence.evidence_occ_confirmatory(:,g) = evidence_occ_confirmatory;
DataB.evidence.NegativeEvidShared(:,g)=NegativeEvidShared;
DataB.evidence.NegativeEvidSelf(:,g)=NegativeEvidSelf;
DataB.evidence.Overall(:,g)=Schedule(g).MainSchedule.OverallEvidence';
DataB.evidence.Other(:,g)=Schedule(g).MainSchedule.OtherEvidence;

% Indices
DataB.presinfoput.indices.welcome = index_Welcome;
DataB.presinfoput.indices.question_you = index_Question_you;
DataB.presinfoput.indices.question_other= index_Question_other;
DataB.presinfoput.indices.answer_you = index_Answer_you;
DataB.presinfoput.indices.answer_other = index_Answer_other;
DataB.Schedules=Schedule;
%Sort Agents By ability level
for Alvls=1:length(unique(DataB.agent_rating.AbilityLvls(:,g)))
    AgentIndex{Alvls}=(DataB.agent_rating.AbilityLvls(:,g)==Alvls);
    AgentIDs{Alvls}=find(AgentIndex{Alvls});
    for a=1:sum(AgentIndex{Alvls})
        index=DataB.agent_rating.ID(:,g)==AgentIDs{Alvls}(a);
        DataB.agent_rating.AbilityspecAgents{Alvls}(:,a,g)=DataB.agent_rating.score(index,g);
    end
end
%keyboard
