private void CenteredDelivery(Stimulus stim, UInt32 begin, UInt32 end) { uint[] duration = new uint[stim.stims_per_sound]; uint[] between = new uint[stim.stims_per_sound]; uint totalTime = 0; for (int i = 0; i < stim.stims_per_sound; i++) { duration[i] = (uint)random.Next((int)stim.dur_min, (int)stim.dur_max); between[i] = (uint)random.Next((int)stim.interval_min, (int)stim.interval_max); totalTime += duration[i] + between[i]; } uint timeMs; if (end - begin > totalTime) { timeMs = begin + ((end - begin) - totalTime) / 2; } else { timeMs = begin - (totalTime - (end - begin)) / 2; } for (int i = 0; i < stim.stims_per_sound; i++) { stim.stimIntervals.Add(new StimulusInterval(stim, timeMs, timeMs + duration[i])); timeMs += duration[i]; timeMs += between[i]; } }
private void DistributedDelivery(Stimulus stim, UInt32 begin, UInt32 end) { uint[] duration = new uint[stim.stims_per_sound]; uint totalDuration = 0; for (int i = 0; i < stim.stims_per_sound; i++) { duration[i] = (uint)random.Next((int)stim.dur_min, (int)stim.dur_max); totalDuration += duration[i]; } uint delay = (uint)random.Next((int)stim.delay_min, (int)stim.delay_max); uint sub = begin + totalDuration + delay; uint between; uint timeMs = begin; if (sub < end) { between = (end - sub) / stim.stims_per_sound; timeMs += delay; } else { between = 0; } for (int i = 0; i < stim.stims_per_sound; i++) { stim.stimIntervals.Add(new StimulusInterval(stim, timeMs, timeMs + duration[i])); timeMs += duration[i]; timeMs += between; } }
private void FrontPairing(Stimulus stim) { int iterations = (int)Math.Min(stim.num_paired_sounds, stim.sound.expSoundIntervals.Count); for (int i = 0; i < iterations; i++) { Interval interval = windowDictionary[stim.stim_sound_window](stim.sound.expSoundIntervals[i]); deliveryDictionary[stim.stim_delivery](stim, interval.begin, interval.end); } }
private void BackDelivery(Stimulus stim, UInt32 begin, UInt32 end) { uint timeMs = end; timeMs -= (uint)random.Next((int)stim.delay_min, (int)stim.delay_max); for (int i = 0; i < stim.stims_per_sound; i++) { uint duration = (uint)random.Next((int)stim.dur_min, (int)stim.dur_max); stim.stimIntervals.Add(new StimulusInterval(stim, timeMs - duration, timeMs)); timeMs -= duration; timeMs -= (uint)random.Next((int)stim.interval_min, (int)stim.interval_max); } }
private void UnpairedPairing(Stimulus stim) { List <SoundInterval> soundIntervals = stim.sound.expSoundIntervals; if (soundIntervals != null) { deliveryDictionary[stim.stim_delivery](stim, soundIntervals[0].begin, soundIntervals[soundIntervals.Count - 1].end); } else { deliveryDictionary[stim.stim_delivery](stim, exp_begin, exp_end); } }
private void RandomDelivery(Stimulus stim, UInt32 begin, UInt32 end) { for (int i = 0; i < stim.stims_per_sound; i++) { StimulusInterval interval; do { uint duration = (uint)random.Next((int)stim.dur_min, (int)stim.dur_max); uint randomStim = (uint)random.Next((int)begin, (int)(end - duration)); interval = new StimulusInterval(stim, randomStim, randomStim + duration); } while (stim.stimIntervals.Exists(a => a.Overlap(interval))); stim.stimIntervals.Add(interval); } }
private void RandomPairing(Stimulus stim) { int iterations = (int)Math.Min(stim.num_paired_sounds, stim.sound.expSoundIntervals.Count); int max = stim.sound.expSoundIntervals.Count; List <int> randomList = new List <int>(iterations); for (int i = 0; i < iterations; i++) { int randomIndex; do { randomIndex = random.Next(max); }while (randomList.Contains(randomIndex)); randomList.Add(randomIndex); Interval interval = windowDictionary[stim.stim_sound_window](stim.sound.expSoundIntervals[randomIndex]); deliveryDictionary[stim.stim_delivery](stim, interval.begin, interval.end); } }
private void RandomSyncedDelivery(Stimulus stim, UInt32 begin, UInt32 end) { Random syncRandom = new Random(randomSeed + begin.GetHashCode() + end.GetHashCode()); List <Interval> bufferIntervals = new List <Interval>(); for (int i = 0; i < stim.stims_per_sound; i++) { StimulusInterval interval; Interval bufferInterval; do { uint duration = (uint)syncRandom.Next((int)(stim.dur_min), (int)(stim.dur_max)); uint buffer = stim.dur_max + stim.interval_min; uint randomStim = ((uint)syncRandom.Next((int)(begin), (int)(end - buffer))); bufferInterval = new Interval(randomStim, randomStim + buffer); interval = new StimulusInterval(stim, randomStim, randomStim + duration); } while (bufferIntervals.Exists(a => a.Overlap(bufferInterval))); stim.stimIntervals.Add(interval); bufferIntervals.Add(bufferInterval); } }
public StimulusInterval(Stimulus stim, uint begin, uint end) : base(begin, end) { this.stim = stim; }
private void ThroughoutDelivery(Stimulus stim, UInt32 begin, UInt32 end) { stim.stimIntervals.Add(new StimulusInterval(stim, begin, end)); }