Beispiel #1
0
 private void SetRightStimulus(Stimulus stim)
 {
     right_stimulus.ImageLocation = stim.GetFilename();
     right_stimulus_top.Text      = stim.GetTop().ToString();
     right_stimulus_left.Text     = stim.GetLeft().ToString();
     right_stimulus_width.Text    = stim.GetWidth().ToString();
     right_stimulus_height.Text   = stim.GetHeight().ToString();
     right_stimulus_name.Text     = stim.GetName();
 }
Beispiel #2
0
        private Stimulus GetRightStimulus()
        {
            Stimulus stim = new Stimulus();

            stim.SetImage(right_stimulus.ImageLocation);
            stim.SetWidth(Convert.ToInt32(right_stimulus_width.Text));
            stim.SetHeight(Convert.ToInt32(right_stimulus_height.Text));
            stim.SetTop(Convert.ToInt32(right_stimulus_top.Text));
            stim.SetLeft(Convert.ToInt32(right_stimulus_left.Text));
            stim.SetStimulusName(right_stimulus_name.Text);
            return(stim);
        }
Beispiel #3
0
        // Helper functions for getting information from GUI elements
        private Trial GetGUITrial()
        {
            Trial trial             = new Trial(trial_name.Text);
            TransitionParameters tp = GetTransitionParameters();
            RewardParameters     rp = GetRewardParameters();

            Stimulus leftStimulus  = GetLeftStimulus();
            Stimulus rightStimulus = GetRightStimulus();

            trial.SetBlockPresentations(Convert.ToInt32(block_presentations.Value));
            trial.SetRewardParameters(rp);
            trial.SetTransitionParameters(tp);
            trial.SetStimulus(leftStimulus, rightStimulus);
            return(trial);
        }
Beispiel #4
0
        // Helper functions for reading from xml files
        private Stimulus XMLReadStimulusParameters(XmlElement xmlStimulus)
        {
            Stimulus stim = new Stimulus();

            int    top      = Convert.ToInt32(((XmlElement)xmlStimulus.GetElementsByTagName("top")[0]).InnerText);
            int    left     = Convert.ToInt32(((XmlElement)xmlStimulus.GetElementsByTagName("left")[0]).InnerText);
            int    height   = Convert.ToInt32(((XmlElement)xmlStimulus.GetElementsByTagName("height")[0]).InnerText);
            int    width    = Convert.ToInt32(((XmlElement)xmlStimulus.GetElementsByTagName("width")[0]).InnerText);
            string filename = ((XmlElement)xmlStimulus.GetElementsByTagName("location")[0]).InnerText;
            string name     = ((XmlElement)xmlStimulus.GetElementsByTagName("name")[0]).InnerText;

            stim.SetStimulusName(name);
            stim.SetFilename(filename);
            stim.SetTop(top);
            stim.SetLeft(left);
            stim.SetHeight(height);
            stim.SetWidth(width);

            return(stim);
        }
Beispiel #5
0
 public void XMLWriteStimulusParameters(XmlWriter xmlWriter, Stimulus stim, string screen)
 {
     xmlWriter.WriteStartElement("stimulus");
     xmlWriter.WriteAttributeString("screen", screen);
     xmlWriter.WriteStartElement("name");
     xmlWriter.WriteString(stim.GetName());
     xmlWriter.WriteEndElement();
     xmlWriter.WriteStartElement("location");
     xmlWriter.WriteString(stim.GetFilename());
     xmlWriter.WriteEndElement();
     xmlWriter.WriteStartElement("width");
     xmlWriter.WriteString(stim.GetWidth().ToString());
     xmlWriter.WriteEndElement();
     xmlWriter.WriteStartElement("height");
     xmlWriter.WriteString(stim.GetHeight().ToString());
     xmlWriter.WriteEndElement();
     xmlWriter.WriteStartElement("top");
     xmlWriter.WriteString(stim.GetTop().ToString());
     xmlWriter.WriteEndElement();
     xmlWriter.WriteStartElement("left");
     xmlWriter.WriteString(stim.GetLeft().ToString());
     xmlWriter.WriteEndElement();
     xmlWriter.WriteEndElement();
 }
Beispiel #6
0
 public void SetStimulus(Stimulus left, Stimulus right)
 {
     this.leftStimulus  = left;
     this.rightStimulus = right;
 }
Beispiel #7
0
        public void LoadConfiguration(string filename)
        {
            Trial  trial;
            string isiTrialName = "";
            Dictionary <string, Trial> newDictionary = new Dictionary <string, Trial>();

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(filename);
            XmlNodeList trialList = xmlDoc.GetElementsByTagName("trial");

            foreach (XmlNode xmlNode in trialList)
            {
                bool                 isi;
                string               trialName;
                int                  blockPresentations;
                RewardParameters     rp    = new RewardParameters();
                TransitionParameters tp    = new TransitionParameters();
                Stimulus             left  = new Stimulus();
                Stimulus             right = new Stimulus();


                // General trial info
                XmlElement trialElement = xmlNode as XmlElement;
                XmlElement xTrialName   = (XmlElement)trialElement.GetElementsByTagName("name")[0];
                trialName = ((XmlElement)trialElement.GetElementsByTagName("name")[0]).InnerText;
                if (((XmlElement)trialElement.GetElementsByTagName("isi")[0]).InnerText == "true")
                {
                    isi          = true;
                    isiTrialName = trialName;
                }
                else
                {
                    isi = false;
                }
                blockPresentations = Convert.ToInt32(((XmlElement)trialElement.GetElementsByTagName("blockPresentations")[0]).InnerText);

                // Reward parameters
                XmlElement xRewardParameters = (XmlElement)trialElement.GetElementsByTagName("reward")[0];
                rp = XMLReadRewardParameters(xRewardParameters);

                // Transition parameters
                XmlElement xTransitionParameters = (XmlElement)trialElement.GetElementsByTagName("transition")[0];
                tp = XMLReadTransitionParameters(xTransitionParameters);

                // Stimulus parameters
                XmlNodeList xNodes   = trialElement.GetElementsByTagName("stimulus");
                XmlElement  stimulus = (XmlElement)(trialElement.GetElementsByTagName("stimulus")[0]);
                if (stimulus.GetAttribute("screen") == "left")
                {
                    left = XMLReadStimulusParameters(stimulus);
                }
                else
                {
                    right = XMLReadStimulusParameters(stimulus);
                }

                stimulus = (XmlElement)(trialElement.GetElementsByTagName("stimulus")[1]);
                if (stimulus.GetAttribute("screen") == "right")
                {
                    right = XMLReadStimulusParameters(stimulus);
                }
                else
                {
                    left = XMLReadStimulusParameters(stimulus);
                }

                trial = new Trial(trialName);
                trial.SetISI(isi);
                trial.SetRewardParameters(rp);
                trial.SetTransitionParameters(tp);
                trial.SetStimulus(left, right);
                trial.SetBlockPresentations(blockPresentations);
                newDictionary.Add(trialName, trial);
            }
            int blockCount = Convert.ToInt32(xmlDoc.GetElementsByTagName("blocks")[0].FirstChild.InnerText);

            this.trialDictionary = new Dictionary <string, Trial>(newDictionary);
            this.blockCount      = blockCount;
            this.isiTrialName    = isiTrialName;
            currentFileName      = filename;
        }
Beispiel #8
0
 private Stimulus GetRightStimulus()
 {
     Stimulus stim = new Stimulus();
     stim.SetImage(right_stimulus.ImageLocation);
     stim.SetWidth(Convert.ToInt32(right_stimulus_width.Text));
     stim.SetHeight(Convert.ToInt32(right_stimulus_height.Text));
     stim.SetTop(Convert.ToInt32(right_stimulus_top.Text));
     stim.SetLeft(Convert.ToInt32(right_stimulus_left.Text));
     stim.SetStimulusName(right_stimulus_name.Text);
     return stim;
 }
Beispiel #9
0
 private void SetRightStimulus(Stimulus stim)
 {
     right_stimulus.ImageLocation = stim.GetFilename();
     right_stimulus_top.Text = stim.GetTop().ToString();
     right_stimulus_left.Text = stim.GetLeft().ToString();
     right_stimulus_width.Text = stim.GetWidth().ToString();
     right_stimulus_height.Text = stim.GetHeight().ToString();
     right_stimulus_name.Text = stim.GetName();
 }
Beispiel #10
0
 public void SetStimulus(Stimulus left, Stimulus right)
 {
     this.leftStimulus = left;
     this.rightStimulus = right;
 }
        // Helper functions for reading from xml files
        private Stimulus XMLReadStimulusParameters(XmlElement xmlStimulus)
        {
            Stimulus stim = new Stimulus();

            int top = Convert.ToInt32(((XmlElement)xmlStimulus.GetElementsByTagName("top")[0]).InnerText);
            int left = Convert.ToInt32(((XmlElement)xmlStimulus.GetElementsByTagName("left")[0]).InnerText);
            int height = Convert.ToInt32(((XmlElement)xmlStimulus.GetElementsByTagName("height")[0]).InnerText);
            int width = Convert.ToInt32(((XmlElement)xmlStimulus.GetElementsByTagName("width")[0]).InnerText);
            string filename = ((XmlElement)xmlStimulus.GetElementsByTagName("location")[0]).InnerText;
            string name = ((XmlElement)xmlStimulus.GetElementsByTagName("name")[0]).InnerText;

            stim.SetStimulusName(name);
            stim.SetFilename(filename);
            stim.SetTop(top);
            stim.SetLeft(left);
            stim.SetHeight(height);
            stim.SetWidth(width);

            return stim;
        }
 public void XMLWriteStimulusParameters(XmlWriter xmlWriter, Stimulus stim, string screen)
 {
     xmlWriter.WriteStartElement("stimulus");
     xmlWriter.WriteAttributeString("screen", screen);
     xmlWriter.WriteStartElement("name");
     xmlWriter.WriteString(stim.GetName());
     xmlWriter.WriteEndElement();
     xmlWriter.WriteStartElement("location");
     xmlWriter.WriteString(stim.GetFilename());
     xmlWriter.WriteEndElement();
     xmlWriter.WriteStartElement("width");
     xmlWriter.WriteString(stim.GetWidth().ToString());
     xmlWriter.WriteEndElement();
     xmlWriter.WriteStartElement("height");
     xmlWriter.WriteString(stim.GetHeight().ToString());
     xmlWriter.WriteEndElement();
     xmlWriter.WriteStartElement("top");
     xmlWriter.WriteString(stim.GetTop().ToString());
     xmlWriter.WriteEndElement();
     xmlWriter.WriteStartElement("left");
     xmlWriter.WriteString(stim.GetLeft().ToString());
     xmlWriter.WriteEndElement();
     xmlWriter.WriteEndElement();
 }
        public void LoadConfiguration(string filename)
        {
            Trial trial;
            string isiTrialName = "";
            Dictionary<string, Trial> newDictionary = new Dictionary<string, Trial>();

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(filename);
            XmlNodeList trialList = xmlDoc.GetElementsByTagName("trial");
            foreach (XmlNode xmlNode in trialList)
            {
                bool isi;
                string trialName;
                int blockPresentations;
                RewardParameters rp = new RewardParameters();
                TransitionParameters tp = new TransitionParameters();
                Stimulus left = new Stimulus();
                Stimulus right = new Stimulus();


                // General trial info
                XmlElement trialElement = xmlNode as XmlElement;
                XmlElement xTrialName = (XmlElement)trialElement.GetElementsByTagName("name")[0];
                trialName = ((XmlElement)trialElement.GetElementsByTagName("name")[0]).InnerText;
                if (((XmlElement)trialElement.GetElementsByTagName("isi")[0]).InnerText == "true")
                {
                    isi = true;
                    isiTrialName = trialName;
                }
                else
                    isi = false;
                blockPresentations = Convert.ToInt32(((XmlElement)trialElement.GetElementsByTagName("blockPresentations")[0]).InnerText);

                // Reward parameters
                XmlElement xRewardParameters = (XmlElement)trialElement.GetElementsByTagName("reward")[0];
                rp = XMLReadRewardParameters(xRewardParameters);

                // Transition parameters
                XmlElement xTransitionParameters = (XmlElement)trialElement.GetElementsByTagName("transition")[0];
                tp = XMLReadTransitionParameters(xTransitionParameters);

                // Stimulus parameters
                XmlNodeList xNodes = trialElement.GetElementsByTagName("stimulus");
                XmlElement stimulus = (XmlElement)(trialElement.GetElementsByTagName("stimulus")[0]);
                if (stimulus.GetAttribute("screen") == "left")
                    left = XMLReadStimulusParameters(stimulus);
                else
                    right = XMLReadStimulusParameters(stimulus);

                stimulus = (XmlElement)(trialElement.GetElementsByTagName("stimulus")[1]);
                if (stimulus.GetAttribute("screen") == "right")
                    right = XMLReadStimulusParameters(stimulus);
                else
                    left = XMLReadStimulusParameters(stimulus);

                trial = new Trial(trialName);
                trial.SetISI(isi);
                trial.SetRewardParameters(rp);
                trial.SetTransitionParameters(tp);
                trial.SetStimulus(left, right);
                trial.SetBlockPresentations(blockPresentations);
                newDictionary.Add(trialName, trial);
            }
            int blockCount = Convert.ToInt32(xmlDoc.GetElementsByTagName("blocks")[0].FirstChild.InnerText);

            this.trialDictionary = new Dictionary<string, Trial>(newDictionary);
            this.blockCount = blockCount;
            this.isiTrialName = isiTrialName;
            currentFileName = filename;
        }
Beispiel #14
0
        private void copy_left_stimulus_Click(object sender, EventArgs e)
        {
            Stimulus stim = GetLeftStimulus();

            SetRightStimulus(stim);
        }