Esempio n. 1
0
        private bool[] activeState = null;                      // whether a specific channel is open to clicks (true/active = open to click, false = in refractory period)



        public ClickTranslatorFilter(string filterName)
        {
            // set class version
            base.CLASS_VERSION = CLASS_VERSION;

            // store the filter name
            this.filterName = filterName;

            // initialize the logger and parameters with the filter name
            logger     = LogManager.GetLogger(filterName);
            parameters = ParameterManager.GetParameters(filterName, Parameters.ParamSetTypes.Filter);

            // define the parameters
            parameters.addParameter <bool>(
                "EnableFilter",
                "Enable click translator filter",
                "1");

            parameters.addParameter <bool>(
                "LogDataStreams",
                "Log the filter's intermediate and output data streams. See 'Data' tab for more settings on sample stream logging.",
                "0");

            parameters.addParameter <double[][]>(
                "Translators",
                "Specifies which channels are click-translated, the other channels pass through untouched.\n\nChannel: the channel (1...n) to which click-translation will be applied.\nActivePeriod: Time window of buffer used for determining clicks (in samples or seconds).\nActiveRateThreshold: The threshold above which the average value (of ActivePeriod) in active state should get to send a 'click' and put the channel into inactive state.\nRefractoryPeriod: Time window after click in which no click will be translated (in samples or seconds).",
                "", "", "1,2;0.4s,0.4s;0.5,0.5;3.6s,3.6s", new string[] { "Channel", "ActivePeriod", "ActiveRateThreshold", "RefractoryPeriod" });

            // message
            logger.Info("Filter created (version " + CLASS_VERSION + ")");
        }
Esempio n. 2
0
        private int[] mDirections    = null;                    // the direction in which the threshold is applied


        public ThresholdClassifierFilter(string filterName)
        {
            // set class version
            base.CLASS_VERSION = CLASS_VERSION;

            // store the filter name
            this.filterName = filterName;

            // initialize the logger and parameters with the filter name
            logger     = LogManager.GetLogger(filterName);
            parameters = ParameterManager.GetParameters(filterName, Parameters.ParamSetTypes.Filter);

            // define the parameters
            parameters.addParameter <bool>(
                "EnableFilter",
                "Enable threshold classifier filter",
                "1");

            parameters.addParameter <bool>(
                "LogDataStreams",
                "Log the filter's intermediate and output data streams. See 'Data' tab for more settings on sample stream logging.",
                "0");

            parameters.addParameter <double[][]>  (
                "Thresholding",
                "Specifies which channels are thresholded, the other channels pass through untouched.\n\nChannel: the channel (1...n) to which thresholding will be applied.\nThreshold: the threshold above (>) or under (<) which the channel output will become 1 or 0\nDirection: the direction of the thresholding. If the direction value is negative (<0) then input values smaller than\nthe threshold will result in true; if positive (>= 0) then input values larger than the threshold will result in true.",
                "", "", "1,2;0.45,0.45;1,1", new string[] { "Channel", "Threshold", "Direction" });

            // message
            logger.Info("Filter created (version " + CLASS_VERSION + ")");
        }
Esempio n. 3
0
        private double[][] mBufferWeights = null;                   // matrix with the buffer weights for each channel (1st dimention are the channels; 2nd dimension are the sample weights per channel)

        public TimeSmoothingFilter(string filterName)
        {
            // set class version
            base.CLASS_VERSION = CLASS_VERSION;

            // store the filter name
            this.filterName = filterName;

            // initialize the logger and parameters with the filter name
            logger     = LogManager.GetLogger(filterName);
            parameters = ParameterManager.GetParameters(filterName, Parameters.ParamSetTypes.Filter);

            // define the parameters
            parameters.addParameter <bool>  (
                "EnableFilter",
                "Enable TimeSmoothing Filter",
                "1");

            parameters.addParameter <bool>(
                "LogDataStreams",
                "Log the filter's intermediate and output data streams. See 'Data' tab for more settings on sample stream logging.",
                "0");

            parameters.addParameter <double[][]>  (
                "BufferWeights",
                "Weights corresponding to data buffers (columns correspond to output channels, multiple rows correspond to samples)",
                "", "", "0.7,0.5,0.2,0;0.7,0.5,0.2,0");

            // message
            logger.Info("Filter created (version " + CLASS_VERSION + ")");
        }
Esempio n. 4
0
        public RedistributionFilter(string filterName)
        {
            // set class version
            base.CLASS_VERSION = CLASS_VERSION;

            // store the filter name
            this.filterName = filterName;

            // initialize the logger and parameters with the filter name
            logger     = LogManager.GetLogger(filterName);
            parameters = ParameterManager.GetParameters(filterName, Parameters.ParamSetTypes.Filter);

            // define the parameters
            parameters.addParameter <bool>(
                "EnableFilter",
                "Enable filter",
                "1");

            parameters.addParameter <bool>(
                "LogDataStreams",
                "Log the filter's intermediate and output data streams. See 'Data' tab for more settings on sample stream logging.",
                "0");

            parameters.addParameter <double[][]>  (
                "Redistribution",
                "Specifies which input channels are added together to one or more output channels.\nAlso specifies which weights are applied to the input values before addition\n\nInput: Input channel (1...n)\nOutput: output channel (1...n)\nWeight: Weight applied to input channel value",
                "", "", "1,2;1,2;1,1", new string[] { "Input", "Output", "Weight" });

            // message
            logger.Info("Filter created (version " + CLASS_VERSION + ")");
        }
Esempio n. 5
0
        private RingBuffer[][] mDataBuffers = null;                 // holds the data for each channel (for the size of buffer)


        public NormalizerFilter(string filterName)
        {
            // set class version
            base.CLASS_VERSION = CLASS_VERSION;

            // store the filter name
            this.filterName = filterName;

            // initialize the logger and parameters with the filter name
            logger     = LogManager.GetLogger(filterName);
            parameters = ParameterManager.GetParameters(filterName, Parameters.ParamSetTypes.Filter);

            // define the parameters
            parameters.addParameter <bool>  (
                "EnableFilter",
                "Enable Normalizer Filter",
                "1");

            parameters.addParameter <bool>(
                "LogDataStreams",
                "Log the filter's intermediate and output data streams. See 'Data' tab for more settings on sample stream logging.",
                "0");

            parameters.addParameter <double[]>  (
                "NormalizerOffsets",
                "Normalizer offsets",
                "", "", "0,0");

            parameters.addParameter <double[]>  (
                "NormalizerGains",
                "Normalizer gain values",
                "", "", "1,1");

            parameters.addParameter <int[]>(
                "Adaptation",
                "Adaptation setting per channel: 0 no adaptation, 1 zero mean, 2 zero mean, unit variance",
                "", "", "0,0");

            parameters.addParameter <string[][]>(
                "Buffers",
                "Defines the buffers.\nThe columns correspond to the output channels. The rows allow for one or more buffers per channel.\nInside the cells (for each buffer) it is possible to define expressions which are evaluated during runtime, global variables can be\nused and evaluated (e.g. [feedback] == 1). if an expression is evaluated as true then the sample will be added accordingly to that buffer.\n\nNote the variablenames in the expressions are case-sensitive",
                "", "", "[Feedback] == 1 && [Target] == 1,[Feedback] == 1 && [Target] == 0;[Feedback] == 1 && [Target] == 1,[Feedback] == 1 && [Target] == 0");

            parameters.addParameter <double>(
                "BufferLength",
                "Time window of past data per buffer that enters into statistic",
                "", "", "9s");

            parameters.addParameter <string>(
                "UpdateTrigger",
                "Expression (global variables can be used, e.g. [feedback] == 0) on which the offset and gain will be updated, the trigger will occur when the expression result changes from 0 to 1.\nUse empty string for continues update.\n\nNote the variablenames in the expressions are case-sensitive",
                "", "", "[Feedback]==0");

            // message
            logger.Info("Filter created (version " + CLASS_VERSION + ")");
        }
Esempio n. 6
0
        public KeySequenceFilter(string filterName)
        {
            // set class version
            base.CLASS_VERSION = CLASS_VERSION;

            // store the filter name
            this.filterName = filterName;

            // initialize the logger and parameters with the filter name
            logger     = LogManager.GetLogger(filterName);
            parameters = ParameterManager.GetParameters(filterName, Parameters.ParamSetTypes.Filter);

            // define the parameters
            parameters.addParameter <bool>  (
                "EnableFilter",
                "Enable Normalizer Filter",
                "1");

            parameters.addParameter <bool>(
                "LogDataStreams",
                "Log the filter's intermediate and output data streams. See 'Data' tab for more settings on sample stream logging.",
                "0");

            parameters.addParameter <int>(
                "FilterInputChannel",
                "Channel to take as input (1...n)",
                "1", "", "1");

            parameters.addParameter <double>  (
                "Threshold",
                "The threshold above which a sample will be classified as a 1 before going into the data buffer",
                "", "", "0.5");

            parameters.addParameter <double>  (
                "Proportion",
                "The proportion of samples in the data buffer that needs to be the same as the pre-defined sequence",
                "0", "1", "0.7");

            parameters.addParameter <bool[]>  (
                "Sequence",
                "Sequence activation pattern and amount of samples needed.\nThe pattern is matched chronological order (i.e. the first value in the pattern is matched against the most recent sample)",
                "", "", "1,1,1,1,1,1");

            // message
            logger.Info("Filter created (version " + CLASS_VERSION + ")");
        }
Esempio n. 7
0
        private int sampleIntervalMs = 0;                                               // interval between the samples in milliseconds

        public WindowsSensorsPlugin(string pluginName, string pluginExt)
        {
            // store the plugin name and extension
            this.pluginName = pluginName;
            this.pluginExt  = pluginExt;

            // initialize the logger and parameters with the filter name
            logger     = LogManager.GetLogger(pluginName);
            parameters = ParameterManager.GetParameters(pluginName, Parameters.ParamSetTypes.Plugin);

            // parameters
            parameters.addParameter <bool>(
                "LogDataStreams",
                "Log the plugin's data streams. See 'Data' tab for more settings on data stream logging.",
                "0");

            parameters.addParameter <double>(
                "LogSampleRate",
                "Rate with which plugin samples are logged, in samples per second (hz).\nNote, logging higher than 1000Hz not possible",
                "0", "", "10");

            // initialize Windows Driver Kit (or try to)
            try {
                init_safe();
            } catch (Exception) {
                // flag sensor as unavailabe
                sensorAvailable = false;

                //logger.Warn("Could not load Windows Driver Kit dependency, no sensory input");
            }

            // message
            logger.Info("Plugin created (version " + CLASS_VERSION + ")");

            // start a new thread
            pluginThread      = new Thread(this.run);
            pluginThread.Name = "WindowsSensorsPlugin Run Thread";
            pluginThread.Start();
        }
Esempio n. 8
0
        public AdaptationFilter(string filterName)
        {
            // set class version
            base.CLASS_VERSION = CLASS_VERSION;

            // store the filter name
            this.filterName = filterName;

            // initialize the logger and parameters with the filter name
            logger     = LogManager.GetLogger(filterName);
            parameters = ParameterManager.GetParameters(filterName, Parameters.ParamSetTypes.Filter);

            // define the parameters
            parameters.addParameter <bool>      (
                "EnableFilter",
                "Enable AdaptationFilter",
                "1");

            parameters.addParameter <bool>      (
                "LogDataStreams",
                "Log the filter's intermediate and output data streams. See 'Data' tab for more settings on data stream logging.",
                "0");

            parameters.addParameter <int[]>     (
                "Adaptation",
                "The adaptation type for each incoming channel, use one of the following options:\n0: no adaptation\n1: to initial params\n2: to first samples\n3: to lastest samples (sliding window)\n\nE.g. if there are three incoming channels, then setting this parameter to '0 3 1' would leave the first incoming channel\nunmodified, adapt the second channel to the lastest samples and adapt the third to a fixed mean and standard deviation\n\nNote: make sure that a value exists in this parameter for each incoming channel.",
                "0", "3", "0,0",
                new string[] { "No adaptation",
                               "To initial parameters",
                               "To first samples",
                               "To lastest samples", });

            parameters.addParameter <double[]>  (
                "InitialChannelMeans",
                "The initial channel mean for each incoming channel (only used\nwhen the adaptation parameter for the channel is set to 1).\n\nNote: make sure that a value exists in this parameter for each incoming channel.",
                "", "", "0,0");

            parameters.addParameter <double[]>  (
                "InitialChannelStds",
                "The initial standard deviation for each incoming channel (only used\nwhen the adaptation parameter for the channel is set to 1).\n\nNote: make sure that a value exists in this parameter for each incoming channel.",
                "", "", "1,1");

            parameters.addParameter <int>       (
                "BufferLength",
                "Time window of past data that enters into statistic (in samples or seconds)",
                "0", "", "9s");

            parameters.addParameter <double>       (
                "BufferDiscardFirst",
                "The amount of time at the start where samples should not be put in the channel buffer (in samples or seconds). 0 is off.",
                "0", "", "1s");

            parameters.addParameter <int>       (
                "AdaptationMinimalLength",
                "Length of the buffer that has to be filled before adaptation starts (in samples or seconds)",
                "0", "", "5s");

            parameters.addParameter <double[]>  (
                "ExcludeStdThreshold",
                "The threshold for each incoming channel (on a standard normal distribution) above which a sample will be excluded from buffering\n\nNote: make sure that a value exists in this parameter for each incoming channel.",
                "", "", "2.7,2.7");

            // message
            logger.Info("Filter created (version " + CLASS_VERSION + ")");
        }
Esempio n. 9
0
        public LocalizerTask(bool childApplication)
        {
            // transfer the child application flag
            this.childApplication = childApplication;

            // check if the task is standalone (not a child application)
            if (!this.childApplication)
            {
                // create a parameter set for the task
                parameters = ParameterManager.GetParameters(CLASS_NAME, Parameters.ParamSetTypes.Application);

                // add parameters
                parameters.addParameter <int>(
                    "WindowLeft",
                    "Screen coordinate of application window's left edge",
                    "", "", "0");

                parameters.addParameter <int>(
                    "WindowTop",
                    "Screen coordinate of application window's top edge",
                    "", "", "0");

                parameters.addParameter <int>(
                    "WindowWidth",
                    "Width of application window (fullscreen and 0 will take monitor resolution)",
                    "", "", "800");

                parameters.addParameter <int>(
                    "WindowHeight",
                    "Height of application window (fullscreen and 0 will take monitor resolution)",
                    "", "", "600");

                parameters.addParameter <int>(
                    "WindowRedrawFreqMax",
                    "Maximum display redraw interval in FPS (0 for as fast as possible)",
                    "0", "", "50");

                parameters.addParameter <RGBColorFloat>(
                    "WindowBackgroundColor",
                    "Window background color",
                    "", "", "0");

                parameters.addParameter <string[][]>(
                    "Stimuli",
                    "Stimuli available for use in a stimuli sequence and their corresponding duration in seconds. Stimuli can be either text, images, or sounds, or any combination of these modalities.\n Each row represents a stimulus.",
                    "", "", "Rust;;;10", new string[] { "Text", "Image", "Sound", "Duration [s]" });

                parameters.addParameter <int[]>(
                    "StimuliSequence",
                    "",
                    "Sequence of one or more stimuli.", "", "", "1");

                parameters.addParameter <int>(
                    "NumberOfRepetitions",
                    "Number of times a stimuli sequence will be repeated.",
                    "1", "", "2");

                parameters.addParameter <int>(
                    "FirstSequenceWait",
                    "Amount of time before the first sequence of the task starts.",
                    "0", "", "5s");

                parameters.addParameter <int>(
                    "BetweenSequenceWait",
                    "Amount of time between end of sequence and start of subsequent sequence.",
                    "0", "", "10s");

                parameters.addParameter <string>(
                    "StartText",
                    "Text shown to participant at beginning of task.",
                    "", "", "Task will begin shortly.");

                parameters.addParameter <string>(
                    "WaitText",
                    "Text shown to participant during waiting periods.",
                    "", "", "Wait.");

                parameters.addParameter <string>(
                    "EndText",
                    "Text shown to participant at end of task.",
                    "", "", "Task is finished.");
            }

            // message
            logger.Info("Application " + CLASS_NAME + " created (version " + CLASS_VERSION + ")");
        }
Esempio n. 10
0
        private RingBuffer[] mDataBuffers = null;               // an array of ringbuffers, a ringbuffer for every channel

        public FlexKeySequenceFilter(string filterName)
        {
            // set class version
            base.CLASS_VERSION = CLASS_VERSION;

            // store the filter name
            this.filterName = filterName;

            // initialize the logger and parameters with the filter name
            logger     = LogManager.GetLogger(filterName);
            parameters = ParameterManager.GetParameters(filterName, Parameters.ParamSetTypes.Filter);

            // define the parameters
            parameters.addParameter <bool>(
                "EnableFilter",
                "Enable TimeSmoothing Filter",
                "1");

            parameters.addParameter <bool>(
                "LogDataStreams",
                "Log the filter's intermediate and output data streams. See 'Data' tab for more settings on sample stream logging.",
                "0");

            parameters.addParameter <int>(
                "ClickInputChannel",
                "Channel of which clicks are used as input.",
                "1", "", "1");

            parameters.addParameter <int>(
                "AmountOfClicks",
                "Amount of clicks required to create wake-up-call.",
                "1", "", "11");

            parameters.addParameter <int>(
                "MinimumClickInterval",
                "Minimal interval between clicks (in samples or seconds) for clicks to be counted towards the amount required to create wake-up call.",
                "0", "", "6s");

            parameters.addParameter <int>(
                "MaximumClickInterval",
                "Maximal interval between clicks (in samples or seconds) for clicks to be counted towards the amount required to create wake-up call.",
                "0", "", "10s");

            parameters.addParameter <double>(
                "ClickRate",
                "Rate (between 0 and 1) of amount of well-timed clicks required to create wake-up call.",
                "0", "", "0.9");

            parameters.addParameter <bool>(
                "CheckMeanAndStd",
                "In addition to requiring clicks to fulfill above requirements, also require mean and sd of seperate channel to fulfill requirements in order to create wake-up call.",
                "1");

            parameters.addParameter <int>(
                "MeanAndStdInputChannel",
                "Channel of which mean and sd are used as input (only if CheckMeanAndStd checkbox is ticked).",
                "1", "", "1");

            parameters.addParameter <double>(
                "MeanThreshold",
                "Mean threshold used in determining if wake-up call is created (only if CheckMeanAndStd checkbox is ticked).",
                "", "", "0");

            parameters.addParameter <int>(
                "MeanDirection",
                "Direction in which the mean is compared to the MeanThreshold. If negative, mean should be below MeanThreshold to count towards create wake-up call, otherwise should be above threshold (only if CheckMeanAndStd checkbox is ticked).",
                "", "", "1");

            parameters.addParameter <double>(
                "StdThreshold",
                "Sd threshold used in determining if wake-up call is created (only if CheckMeanAndStd checkbox is ticked).",
                "", "", "1");

            parameters.addParameter <int>(
                "StdDirection",
                "Direction in which the sd is compared to the StdThreshold. If negative, sd should be below StdThreshold to count towards create wake-up call, otherwise should be above threshold (only if CheckMeanAndStd checkbox is ticked).",
                "", "", "-1");

            // message
            logger.Info("Filter created (version " + CLASS_VERSION + ")");
        }