コード例 #1
0
        public Experiment(
            int[] objIDs,
            int[][] stimSeq,
            int nCal  = 10,
            int nPred = 10,
            float selectionThreshold          = 0.1f,
            UtopiaController utopiaController = null,
            GSM stimulusStateStack            = null,
            params object [] args)
        {
            if (objIDs == null)
            {
                throw new ArgumentNullException("objIDs cannot be null");
            }
            this.objIDs             = objIDs;
            this.stimSeq            = stimSeq;
            this.nCal               = nCal;
            this.nPred              = nPred;
            this.selectionThreshold = selectionThreshold;
            this.utopiaController   = utopiaController;
            this.stimulusStateStack = stimulusStateStack;

            // add the selection threshold (off for cal) to the arguments stack
            this.calargs  = new object[args.Length + 1];
            this.predargs = new object[args.Length + 1];
            for (int i = 0; i < args.Length; i++)
            {
                this.predargs[i + 1] = args[i];
                this.calargs[i + 1]  = args[i];
            }
            this.calargs[0]  = -1.0f;                   // no selection during calibration
            this.predargs[0] = this.selectionThreshold; // selection during prediction
            this.stage       = 0;
        }
コード例 #2
0
 private void init(
     int[][] stimSeq,
     int tgtidx,
     UtopiaController utopiaController,
     GSM stimulusStateStack,
     float selectionThreshold = -1,
     int numframes            = -1,
     int duration             = 4,
     int cueduration          = 1,
     int feedbackduration     = 1,
     int waitduration         = 1,
     int cueframes            = -1,
     int feedbackframes       = -1,
     int waitframes           = -1)
 {
     this.tgtidx             = tgtidx;
     this.stimSeq            = stimSeq;
     this.utopiaController   = utopiaController;
     this.stimulusStateStack = stimulusStateStack;
     this.numframes          = numframes > 0 ? numframes : duration * 60;
     this.cueframes          = cueframes > 0 ? cueframes : cueduration * 60;
     this.feedbackframes     = feedbackframes > 0 ? feedbackframes : feedbackduration * 60;
     this.waitframes         = waitframes > 0 ? waitframes : waitduration * 60;
     this.selectionThreshold = selectionThreshold;
     this.stage = 0;
     Console.WriteLine(String.Format("Cal: tgtidx={0:d}", this.tgtidx));
 }
コード例 #3
0
 public Noisetag(System.IO.TextReader stimFile, UtopiaController utopiaController, GSM stimulusSequenceStack)
 {
     // global flicker stimulus sequence
     this.noisecode = StimSeq.FromString(stimFile);
     //Console.WriteLine(this.noisecode);
     //this.noisecode.convertstimSeq2int();
     //this.noisecode.setStimRate(2);
     // get the stimSeq (as int) from the noisecode
     this.stimSeq = this.convertstimSeq2int(this.noisecode);
     // utopiaController
     this.utopiaController = utopiaController;
     if (this.utopiaController == null)
     {
         // TODO [] : make a singlention for the utopia controller?
         this.utopiaController = new UtopiaController();
     }
     // stimulus state-machine stack
     // Individual stimulus-state-machines track progress in a single
     // stimulus state playback function.
     // Stack allows sequencing of sets of playback functions in loops
     if (stimulusStateMachineStack == null)
     {
         stimulusStateMachineStack = new GSM();
     }
     this.laststate    = new StimulusState(null, null, -1, false);
     this.lastrawstate = new StimulusState(null, null, -1, false);
     this.objIDs       = null;
 }
コード例 #4
0
 public FlickerWithSelection(
     int[][] stimSeq,
     int numframes = 4 * 60,
     int tgtidx    = -1,
     UtopiaController utopiaController = null,
     bool sendEvents = true)
     : base(stimSeq, numframes, tgtidx, sendEvents)
 {
     this.utopiaController = utopiaController;
     Console.WriteLine(" with selection");
 }
コード例 #5
0
ファイル: Noisetag.cs プロジェクト: ldanek/unitymindaffectBCI
        public PredictionPhase(int[] objIDs,
                               int[][] stimSeq,
                               int nTrials = 10,
                               UtopiaController utopiaController = null,
                               GSM stimulusStateStack            = null,
                               params object[] args)
        {
            this.objIDs             = objIDs;
            this.stimSeq            = stimSeq;
            this.nTrials            = nTrials;
            this.utopiaController   = utopiaController;
            this.stimulusStateStack = stimulusStateStack;
            this.args = args;

            this.isRunning = false;
            this.tgti      = 0;
        }
コード例 #6
0
 public bool connect(string host = null, int port = -1, int timeout_ms = 1000)
 {
     if (this.utopiaController == null)
     {
         // use the global controller if none given
         // TODO [] : make a singlention for the utopia controller?
         //if (uc == null) {
         //    // auto-connect the global controller if none given
         //     uc = UtopiaController();
         //    uc.autoconnect();
         // }
         this.utopiaController = new UtopiaController();
     }
     if (this.utopiaController.isConnected())
     {
         return(true);
     }
     this.utopiaController.autoconnect(host, port, timeout_ms);
     return(this.utopiaController.isConnected());
 }
コード例 #7
0
        public PredictionPhase(int[] objIDs,
                               int[][] stimSeq,
                               int nTrials = 10,
                               UtopiaController utopiaController = null,
                               GSM stimulusStateStack            = null,
                               params object [] args)
        {
            if (objIDs == null)
            {
                throw new ArgumentNullException("objIDs cannot be null");
            }
            this.objIDs             = objIDs;
            this.stimSeq            = stimSeq;
            this.nTrials            = nTrials;
            this.utopiaController   = utopiaController;
            this.stimulusStateStack = stimulusStateStack;
            this.args = args;

            this.isRunning = false;
            this.tgti      = 0;
        }
コード例 #8
0
 public SingleTrial(
     int[][] stimSeq,
     int tgtidx,
     UtopiaController utopiaController,
     GSM stimulusStateStack,
     float selectionThreshold = -1,
     int numframes            = -1,
     int duration             = 4,
     int cueduration          = 1,
     int feedbackduration     = 1,
     int waitduration         = 1,
     int cueframes            = -1,
     int feedbackframes       = -1,
     int waitframes           = -1)
 {
     init(stimSeq, tgtidx,
          utopiaController, stimulusStateStack,
          selectionThreshold, numframes,
          duration, cueduration, feedbackduration, waitduration,
          cueframes, feedbackframes, waitframes);
 }
コード例 #9
0
        public SingleTrial(
            int[][] stimSeq,
            int tgtidx,
            UtopiaController utopiaController,
            GSM stimulusStateStack,
            params object [] args)
        {
            //Console.WriteLine("SingleTrial: args "+args.Length); foreach ( object arg in args ) Console.WriteLine(arg);
            // parse / default the variable length args portion
            float selectionThreshold = -1;
            int   numframes          = 400;
            int   duration           = 4;
            int   cueduration        = 1;
            int   feedbackduration   = 1;
            int   waitduration       = 1;
            int   cueframes          = -1;
            int   feedbackframes     = -1;
            int   waitframes         = -1;

            try {
                if (args.Length > 0)
                {
                    selectionThreshold = (float)args[0];
                }
                if (args.Length > 1)
                {
                    numframes = (int)args[1];
                }
                if (args.Length > 2)
                {
                    duration = (int)args[2];
                }
                if (args.Length > 3)
                {
                    cueduration = (int)args[3];
                }
                if (args.Length > 4)
                {
                    feedbackduration = (int)args[4];
                }
                if (args.Length > 5)
                {
                    waitduration = (int)args[5];
                }
                if (args.Length > 6)
                {
                    cueframes = (int)args[6];
                }
                if (args.Length > 7)
                {
                    feedbackframes = (int)args[7];
                }
                if (args.Length > 8)
                {
                    waitframes = (int)args[8];
                }
            }
            catch (NullReferenceException)
            {
                Console.WriteLine("Invalid argument format...");
            } catch (InvalidCastException)
            {
                Console.WriteLine("Invalid argument format...");
            }
            init(stimSeq, tgtidx,
                 utopiaController, stimulusStateStack,
                 selectionThreshold, numframes,
                 duration, cueduration, feedbackduration, waitduration,
                 cueframes, feedbackframes, waitframes);
        }