You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: ga2.m
    path of file: ./repos/CanlabCore/CanlabCore/OptimizeDesign11/GA2
    
    the code of the file until where you have to start completion: function [evtonsets,X,bestp,meff,origvec] = ga2(gensize,numgen,conditions,mspec,varargin)
%[evtonsets,X,bestp,meff,origvec] = ga2(gensize,numgen,conditions,mspec,[nooverlap])
%
% everything in conditions should be in number of frames (TRs), not seconds
% model_setup_ui.m automatically creates the correct format
%
% optional last argument is a 1 or 0.  1 Constrains the events so that
% events of different trials do not overlap.
%
% recommen
    
function [t,sc] = get_tonsetinfo(conditions)
% get list of onset times to match paramvec
% this contains info needed to see if one trial is impinging on the previous one, based on the length
% so it saves a vector, t, of the minimum times in TRs that each paramvec can have
% this value is compared, for each onset vector in paramvec, to the difference among onset times (trial length)
% to make sure no trial length is less than the minimum.
%
% t has first row = min, 2nd = max, 3rd = trial onsets (1) or subpart (0)

ind = 1;
for i = 1:length(conditions)
    if size(conditions(i).onsets,2) == 2   % variable range of trial onsets
        tmp = sum(conditions(i).onsets);
        t(1,ind) = tmp(1);
        t(2,ind) = tmp(2);
        t(3,ind) = 1;
        ind = ind + 1;
    end