Code for stimuli generation