예제 #1
0
        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];
            }
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
 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);
     }
 }
예제 #7
0
        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);
            }
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
 public StimulusInterval(Stimulus stim, uint begin, uint end) : base(begin, end)
 {
     this.stim = stim;
 }
예제 #10
0
 private void ThroughoutDelivery(Stimulus stim, UInt32 begin, UInt32 end)
 {
     stim.stimIntervals.Add(new StimulusInterval(stim, begin, end));
 }