public static List<TrialGroup> createTrialGroups(List<Trial> trials) throws IncorrectNumberOfTrialsException {
    	List<TrialGroup> trialGroups = new ArrayList<TrialGroup>();
    	
    	while (!trials.isEmpty()) {
    		List<Trial> trialsInThisGroup = new ArrayList<Trial>();
			
    		for (int iTrial = 0; iTrial < Options.TRIALS_PER_GROUP; iTrial++) { //0 to 4
				if (!trials.isEmpty()) {
					trialsInThisGroup.add(trials.remove(0));
				} else {
					//this should not occur: experimenter should make sure the number of trials is a multiple of TRIALS_PER_GROUP
					throw new IncorrectNumberOfTrialsException("Not enough trials left to create group of "+ Options.TRIALS_PER_GROUP + " trials! " +
					"Make sure the numer of trials in " + Options.STIM_FILE +" is a multiple of "+ Options.TRIALS_PER_GROUP +"!");
				}
			}
			trialGroups.add(new TrialGroup(trialsInThisGroup, trialsInThisGroup.get(0).lowLoad));
		}    	
    	return trialGroups;
    }