Exemple #1
0
            private static ITemporalPattern Parse(string expression)
            {
                var strArray = expression.Contains(',') ? expression.Split(',') : new[] { expression };

                if (strArray.IsEmpty())
                {
                    throw new ArgumentException(expression);
                }
                var patterns = new ITemporalPattern[strArray.Length];

                for (var i = 0; i < strArray.Length; i++)
                {
                    var subExp = strArray[i];
                    patterns[i] = subExp.Contains('~') ? (ITemporalPattern)TimeVaryingCosinusoidalPattern.Parse(subExp) : CosinusoidalPattern.Parse(subExp);
                }
                switch (patterns.Length)
                {
                case 0:
                    return(null);

                case 1:
                    return(patterns[0]);

                default:
                    return(new CompositeTemporalPattern <ITemporalPattern>(patterns));
                }
            }
        public SsvepTestWindow(Session session)
        {
            // ReSharper disable once LocalizableElement
            Text = "SSVEP";
            SuspendLayout();
            ControlBox      = false;
            IsFullscreen    = true;
            DoubleBuffered  = false;
            FormBorderStyle = FormBorderStyle.None;
            WindowState     = FormWindowState.Maximized;
            ResumeLayout(true);

            Load   += Window_OnLoaded;
            KeyUp  += Window_OnKeyUp;
            Resize += Window_OnResize;
            this.HideCursorInside();

            _session    = session;
            _experiment = (SsvepExperiment)session.Experiment;
            _markable   = session.StreamerCollection.FindFirstOrDefault <IMarkable>();

            _paradigm = _experiment.Config.Test.Paradigm;
            _blocks   = new Block[(int)_experiment.Config.Gui.BlockLayout.Volume];
            var patternMultiplier = _paradigm.GetParadigmPatternMultiplier();

            for (var i = 0; i < _blocks.Length; i++)
            {
                _blocks[i].Size              = new RawVector2(_experiment.Config.Gui.BlockSize.Width, _experiment.Config.Gui.BlockSize.Height);
                _blocks[i].BorderWidth       = (float)_experiment.Config.Gui.BlockBorder.Width * (float)GraphicsUtils.Scale;
                _blocks[i].FixationPointSize = _experiment.Config.Gui.BlockFixationPoint.Size * (float)GraphicsUtils.Scale;
                var patterns = new ITemporalPattern[patternMultiplier];
                for (var j = 0; j < patternMultiplier; j++)
                {
                    patterns[j] = _experiment.Config.Test.Patterns[i * patternMultiplier + j];
                }
                _blocks[i].Patterns = patterns.All(Functions.IsNull) ? null : patterns;
                _blocks[i].UpdateGeometries();
            }

            _stageProgram = _experiment.CreateStagedProgram(session);
            _stageProgram.StageChanged += StageProgram_StageChanged;

            /* Type conversion */
            _backgroundColor         = _experiment.Config.Gui.BackgroundColor.ToSdColor().ToSdx();
            _fontColor               = _experiment.Config.Gui.BackgroundColor.ToSdColor().Inverted().ToSdx();
            _blockBorderColor        = _experiment.Config.Gui.BlockBorder.Color.ToSdColor().ToSdx();
            _blockNormalColor        = _experiment.Config.Gui.BlockColors[0].ToSdColor().ToSdx();
            _blockFlashingColor      = _experiment.Config.Gui.BlockColors[1].ToSdColor().ToSdx();
            _blockFixationPointColor = _experiment.Config.Gui.BlockFixationPoint.Color.ToSdColor().ToSdx();
        }
Exemple #3
0
            private static ITemporalPattern[] ParseMultiple(string expression)
            {
                var strArray = expression.Contains(';') ? expression.Split(';') : new[] { expression };

                if (strArray.IsEmpty())
                {
                    return(EmptyArray <ITemporalPattern> .Instance);
                }
                var schemes = new ITemporalPattern[strArray.Length];

                for (var i = 0; i < strArray.Length; i++)
                {
                    schemes[i] = Parse(strArray[i].Trim());
                }
                return(schemes);
            }