Rev | Line | |
---|
[171] | 1 | using System; |
---|
| 2 | using System.Collections.Generic; |
---|
| 3 | using System.Linq; |
---|
| 4 | using System.Text; |
---|
| 5 | |
---|
| 6 | namespace BCMToolbox.Stimuli |
---|
| 7 | { |
---|
| 8 | public class ConsistentExcitator : StimulatorBase |
---|
| 9 | { |
---|
| 10 | public const string CE_INTERVALS = "CE Intervals"; |
---|
| 11 | public const string CE_MAXSTRENGTH = "CE Max Strength"; |
---|
| 12 | public const string CE_MINSTRENGTH = "CE Min Strength"; |
---|
| 13 | public const string CE_WIDTH = "CE Interval Width"; |
---|
| 14 | Random r = new Random(); |
---|
| 15 | |
---|
| 16 | public override string[] GetParameters() |
---|
| 17 | { |
---|
| 18 | return new string[] { |
---|
| 19 | STIMULUS_LENGTH, |
---|
| 20 | STIMULUS_START, |
---|
| 21 | CE_INTERVALS, |
---|
| 22 | CE_MAXSTRENGTH, |
---|
| 23 | CE_MINSTRENGTH, |
---|
| 24 | CE_WIDTH}; |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | protected override void Apply() |
---|
| 28 | { |
---|
| 29 | int intervals = (int)__parameters[CE_INTERVALS]; |
---|
| 30 | int width = (int)__parameters[CE_WIDTH]; |
---|
| 31 | |
---|
| 32 | double maxStrength = GetDouble(__parameters[CE_MAXSTRENGTH]); |
---|
| 33 | double minStrength = GetDouble(__parameters[CE_MINSTRENGTH]); |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | double[] allChannels = new double[this.Bound.Count]; |
---|
| 37 | |
---|
| 38 | int intervalWidth = this.Bound.Count / intervals; |
---|
| 39 | |
---|
| 40 | for (int i = 0; i < intervals; i++) |
---|
| 41 | { |
---|
| 42 | int intervalStart = i * intervalWidth; |
---|
| 43 | intervalStart += (intervalWidth - width) / 2; |
---|
| 44 | for (int j = 0; j < width; j++) |
---|
| 45 | allChannels[intervalStart + j] = r.NextDouble() * (maxStrength-minStrength) + minStrength; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | this.Bound.ApplyInputs(allChannels); |
---|
| 49 | } |
---|
| 50 | } |
---|
| 51 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.