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(); }
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; }
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; }