// 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 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; }