private void set_isi_trial_Click(object sender, EventArgs e) { Button b = (Button)sender; if (b.Text == ">>") { if (trial_list.SelectedIndex > -1) { string trialName = trial_list.SelectedItem.ToString(); Trial trial = experimentDesigner.GetTrial(trialName); trial.SetISI(true); experimentDesigner.UpdateTrial(trialName, trial); experimentDesigner.SetISITrial(trialName); trial_list.Items.RemoveAt(trial_list.SelectedIndex); trial_list.Update(); b.Text = "<<"; } } else { string trialName = isi_trial.Text; Trial trial = experimentDesigner.GetTrial(trialName); trial.SetISI(false); experimentDesigner.UpdateTrial(trialName, trial); experimentDesigner.SetISITrial(""); trial_list.Items.Add(trialName); trial_list.Update(); b.Text = ">>"; } isi_trial.Text = experimentDesigner.GetISITrial(); }
// Helper functions for setting information in GUI elements private void SetGUITrial(Trial trial) { SetTransitionParameters(trial.GetTransitionParameters()); SetRewardParameters(trial.GetRewardParameters()); SetLeftStimulus(trial.GetLeftStimulus()); SetRightStimulus(trial.GetRightStimulus()); trial_name.Text = trial.GetName(); block_presentations.Value = trial.GetBlockPresentations(); }
public void XMLWriteTrial(XmlWriter xmlWriter, Trial trial, int id) { xmlWriter.WriteStartElement("trial"); xmlWriter.WriteAttributeString("id", id.ToString()); xmlWriter.WriteAttributeString("name", trial.GetName()); XMLWriteRewardParameters(xmlWriter, trial.GetRewardParameters()); XMLWriteTransitionParameters(xmlWriter, trial.GetTransitionParameters()); XMLWriteStimulusParameters(xmlWriter, trial.GetLeftStimulus(), "left"); XMLWriteStimulusParameters(xmlWriter, trial.GetLeftStimulus(), "right"); xmlWriter.WriteEndElement(); }
// 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); }
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; }
// 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; }
public void UpdateTrial(string originalName, Trial trial) { Trial originalTrial = GetTrial(originalName); trialDictionary.Remove(originalName); AddTrial(trial); }
public void XMLWriteTrial(XmlWriter xmlWriter, Trial trial, int id) { xmlWriter.WriteStartElement("trial"); xmlWriter.WriteAttributeString("id",id.ToString()); xmlWriter.WriteAttributeString("name",trial.GetName()); XMLWriteRewardParameters(xmlWriter, trial.GetRewardParameters()); XMLWriteTransitionParameters(xmlWriter, trial.GetTransitionParameters()); XMLWriteStimulusParameters(xmlWriter, trial.GetLeftStimulus(), "left"); XMLWriteStimulusParameters(xmlWriter, trial.GetLeftStimulus(), "right"); xmlWriter.WriteEndElement(); }
public void AddTrial(Trial trial) { if (!trialDictionary.ContainsKey(trial.GetName())) trialDictionary.Add(trial.GetName(), trial); }
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; }