public MainViewModel(User user, Patient patient, string scriptVersion, ObservableCollection <PlanningItemViewModel> planningItemList, PlanningItemViewModel planningItem) { ActivePlanningItem = planningItem; Patient = patient; Image = ActivePlanningItem.PlanningItemImage; StructureSet = ActivePlanningItem.PlanningItemStructureSet; DirectoryInfo constraintDir = new DirectoryInfo(Path.Combine(AssemblyHelper.GetAssemblyDirectory(), "ConstraintTemplates")); //DirectoryInfo constraintDir = new DirectoryInfo(Path.Combine(AssemblyHelper.GetAssemblyDirectory(), "ConstraintTemplates")); string firstFileName = constraintDir.GetFiles().FirstOrDefault().ToString(); string firstConstraintFilePath = Path.Combine(constraintDir.ToString(), firstFileName); ActiveConstraintPath = new ConstraintViewModel(firstConstraintFilePath); PlanningItemList = planningItemList; StructureList = StructureSetListViewModel.GetStructureList(StructureSet);; ConstraintComboBoxList = ConstraintListViewModel.GetConstraintList(constraintDir.ToString()); //GetPQMSummaries(ActiveConstraintPath, ActivePlanningItem, Patient); //PqmSummaries = new ObservableCollection<PQMSummaryViewModel>(); ErrorGrid = GetErrors(ActivePlanningItem); Title = GetTitle(patient, scriptVersion); ModelGroup = new Model3DGroup(); SliderValue = 0; upDir = new Vector3D(0, -1, 0); lookDir = new Vector3D(0, 0, 1); isoctr = new Point3D(0, 0, 0); //just to initalize cameraPosition = new Point3D(0, 0, -3500); PlanningItemSummaries = GetPlanningItemSummary(ActivePlanningItem, PlanningItemList); //NotifyPropertyChanged("Structure"); }
public PQMSummaryViewModel[] GetObjectives(ConstraintViewModel constraintVM) { PQMSummaryViewModel[] m_objectives; string WORKBOOK_TEMPLATE_DIR = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string WORKBOOK_RESULT_DIR = System.IO.Path.GetTempPath(); List <string[]> CSVSheet = new List <string[]>(); string[] header; string constraintPath = constraintVM.ConstraintPath; // make sure the workbook template exists if (!System.IO.File.Exists(constraintPath)) { System.Windows.MessageBox.Show(string.Format("The template file '{0}' chosen does not exist.", constraintPath)); //return; } CSVSheet = parseCSV(constraintPath); //extract header and modify to indicate output values header = CSVSheet.First(); header[2] = "Patient Structure"; CSVSheet.RemoveAt(0); int numFoundObjectives = ReadObjectives(CSVSheet, out m_objectives); Console.WriteLine("File " + constraintPath + " loaded. Objective number is " + numFoundObjectives); return(m_objectives); }
public static ObservableCollection <ConstraintViewModel> GetConstraintList(string constraintDir) { var ConstraintComboBoxList = new ObservableCollection <ConstraintViewModel>(); foreach (string file in Directory.EnumerateFiles(constraintDir, "*.csv")) { var constraintViewModel = new ConstraintViewModel(file); ConstraintComboBoxList.Add(constraintViewModel); } return(ConstraintComboBoxList); }
public ObservableCollection <Structure> FindMatchingStructures(ConstraintViewModel constraintVM, StructureSet structureSet) { PQMSummaryViewModel[] m_objectives = GetObjectives(constraintVM); var evalStructureList = new ObservableCollection <Structure>(); //int i = 0; foreach (var objective in m_objectives) { Structure evalStructure = FindStructureFromAlias(structureSet, objective.TemplateId, objective.TemplateAliases, objective.TemplateCodes); evalStructureList.Add(evalStructure); //i++; } return(evalStructureList); }
public static PQMViewModel[] GetObjectives(ConstraintViewModel constraint) { List <string[]> CSVSheet = new List <string[]>(); CSVSheet = parseCSV(constraint.ConstraintPath); //extract header and modify to indicate output values PQMViewModel[] objectives = new PQMViewModel[CSVSheet.Count()]; int i = 0; foreach (string[] line in CSVSheet) { if (line[0] == "") //A blank line is present { continue; } if (line[0] == "Structure IDs") { continue; } objectives[i] = new PQMViewModel(); // Structure ID objectives[i].TemplateId = line[0]; // Structure Code string codes = line[1]; objectives[i].TemplateCodes = (codes.Length > 0) ? ReplaceWhitespace(codes, @"\s+").Split('|') : new string[] { objectives[i].TemplateId }; // Aliases : extract individual aliases using "|" as separator. Ignore whitespaces. If blank, use the ID. string aliases = line[2]; objectives[i].TemplateAliases = (aliases.Length > 0) ? aliases.Split('|') : new string[] { objectives[i].TemplateId }; // DVH Objective objectives[i].DVHObjective = line[4]; // Evaluator objectives[i].Goal = line[5]; objectives[i].Variation = line[6]; objectives[i].Priority = line[7]; objectives[i].Achieved = ""; //find this later objectives[i].Met = ""; //find this later i++; } return(objectives); }
public Task <PQMViewModel[]> GetObjectivesAsync(ConstraintViewModel constraint) => RunAsync(context => { var objectives = Objectives.GetObjectives(constraint); return(objectives.ToArray() ?? new PQMViewModel[0]); });
public ObservableCollection <PQMSummaryViewModel> AddPQMSummary(ObservableCollection <PQMSummaryViewModel> PqmSummaries, ConstraintViewModel constraintPath, PlanningItemViewModel planningItem, Patient patient) { StructureSet structureSet = planningItem.PlanningItemStructureSet; Structure evalStructure; //ObservableCollection<PQMSummaryViewModel> pqmSummaries = new ObservableCollection<PQMSummaryViewModel>(); //ObservableCollection<StructureViewModel> foundStructureList = new ObservableCollection<StructureViewModel>(); var calculator = new PQMSummaryCalculator(); //var numCol = PqmSummaries[0] //Objectives = calculator.GetObjectives(constraintPath); if (planningItem.PlanningItemObject is PlanSum) { var waitWindowPQM = new WaitWindowPQM(); PlanSum plansum = (PlanSum)planningItem.PlanningItemObject; if (plansum.IsDoseValid() == true) { waitWindowPQM.Show(); foreach (PQMSummaryViewModel pqm in PqmSummaries) { evalStructure = calculator.FindStructureFromAlias(structureSet, pqm.TemplateId, pqm.TemplateAliases, pqm.TemplateCodes); if (evalStructure != null) { var pqmSummary = calculator.GetObjectiveProperties(pqm, planningItem, structureSet, new StructureViewModel(evalStructure)); pqm.Achieved_Comparison = pqmSummary.Achieved; pqm.AchievedColor_Comparison = pqmSummary.AchievedColor; pqm.AchievedPercentageOfGoal_Comparison = pqmSummary.AchievedPercentageOfGoal; pqm.Met_Comparison = pqmSummary.Met; //pqmSummaries.Add(pqmSummary); //foundStructureList.Add(new StructureViewModel(evalStructure)); } } //FoundStructureList = foundStructureList; waitWindowPQM.Close(); } //PqmSummaries = pqmSummaries; } else //is plansetup { var waitWindowPQM = new WaitWindowPQM(); PlanSetup planSetup = (PlanSetup)planningItem.PlanningItemObject; if (planSetup.IsDoseValid() == true) { waitWindowPQM.Show(); foreach (PQMSummaryViewModel pqm in PqmSummaries) { evalStructure = calculator.FindStructureFromAlias(structureSet, pqm.TemplateId, pqm.TemplateAliases, pqm.TemplateCodes); if (evalStructure != null) { if (evalStructure.Id.Contains("PTV") == true) { foreach (Structure s in structureSet.Structures) { if (s.Id == planSetup.TargetVolumeID) { evalStructure = s; } } } var pqmSummary = calculator.GetObjectiveProperties(pqm, planningItem, structureSet, new StructureViewModel(evalStructure)); pqm.Achieved_Comparison = pqmSummary.Achieved; //foundStructureList.Add(new StructureViewModel(evalStructure)); } } //FoundStructureList = foundStructureList; waitWindowPQM.Close(); } //PqmSummaries = pqmSummaries; } return(PqmSummaries); }
public void GetPQMSummaries(ConstraintViewModel constraintPath, PlanningItemViewModel planningItem, Patient patient) { PqmSummaries = new ObservableCollection <PQMSummaryViewModel>(); StructureSet structureSet = planningItem.PlanningItemStructureSet; Structure evalStructure; ObservableCollection <PQMSummaryViewModel> pqmSummaries = new ObservableCollection <PQMSummaryViewModel>(); ObservableCollection <StructureViewModel> foundStructureList = new ObservableCollection <StructureViewModel>(); var calculator = new PQMSummaryCalculator(); Objectives = calculator.GetObjectives(constraintPath); if (planningItem.PlanningItemObject is PlanSum) { var waitWindowPQM = new WaitWindowPQM(); PlanSum plansum = (PlanSum)planningItem.PlanningItemObject; if (plansum.IsDoseValid() == true) { waitWindowPQM.Show(); foreach (PQMSummaryViewModel objective in Objectives) { evalStructure = calculator.FindStructureFromAlias(structureSet, objective.TemplateId, objective.TemplateAliases, objective.TemplateCodes); if (evalStructure != null) { var evalStructureVM = new StructureViewModel(evalStructure); var obj = calculator.GetObjectiveProperties(objective, planningItem, structureSet, evalStructureVM); PqmSummaries.Add(obj); NotifyPropertyChanged("Structure"); } } waitWindowPQM.Close(); } } if (planningItem.PlanningItemObject is PlanSetup) //is plansetup { var waitWindowPQM = new WaitWindowPQM(); PlanSetup planSetup = (PlanSetup)planningItem.PlanningItemObject; if (planSetup.IsDoseValid() == true) { waitWindowPQM.Show(); foreach (PQMSummaryViewModel objective in Objectives) { evalStructure = calculator.FindStructureFromAlias(structureSet, objective.TemplateId, objective.TemplateAliases, objective.TemplateCodes); if (evalStructure != null) { if (evalStructure.Id.Contains("PTV") == true) { foreach (Structure s in structureSet.Structures) { if (s.Id == planSetup.TargetVolumeID) { evalStructure = s; } } } var evalStructureVM = new StructureViewModel(evalStructure); var obj = calculator.GetObjectiveProperties(objective, planningItem, structureSet, evalStructureVM); PqmSummaries.Add(obj); NotifyPropertyChanged("Structure"); } } waitWindowPQM.Close(); } } }