private void SaveDvhIndices() { foreach (var dvhObjectivesViewModel in DvhObjectivesViewModels) { var planInfo = new PlanInfo { PatientId = PatientId, PatientName = PatientName, CourseId = dvhObjectivesViewModel.CourseId, PlanId = dvhObjectivesViewModel.PlanId, // cGy to Gy PrescribedDose = dvhObjectivesViewModel.PrescribedDose / 100, MaxDose = dvhObjectivesViewModel.MaxDose }; string planFolderPath = Path.Combine(PlanCheckerDirectoryPath, Path.Combine(PatientId, Path.Combine(planInfo.PlanId, "PlanCheckData"))); if (!Directory.Exists(planFolderPath)) { Directory.CreateDirectory(planFolderPath); } var dvhObjectives = dvhObjectivesViewModel.DvhObjectives; if (dvhObjectives.Count > 0) { var originalProtocolId = dvhObjectives[0].OriginalProtocolId; DvhObjective.WriteObjectivesToFile(dvhObjectives.ToList(), originalProtocolId, Path.Combine(planFolderPath, "DvhInfo_sjis.csv"), planInfo); } else { MessageBox.Show("No Objective"); } } return; }
private void SynchronizedStructureNameTps(DvhObjective dvhObjective) { if (!IsStructureNameTpsSynchronized) { return; } var dvhObjectivesWithSameStructureName = DvhObjectives.Where(d => ((d.StructureName == dvhObjective.StructureName) && (d.StructureNameTps != dvhObjective.StructureNameTps))); foreach (var d in dvhObjectivesWithSameStructureName) { d.StructureNameTps = dvhObjective.StructureNameTps; } }
private void ChooseFile(DvhObjectivesViewModel dvhObjectivesViewModel) { var dialog = new OpenFileDialog { Title = "Choose file", Filter = "CSV file (*.csv)|*.csv", InitialDirectory = Path.Combine(DvhCheckerDirectoryPath, "templates") }; if (dialog.ShowDialog() == true) { ProtocolFilePath = dialog.FileName; } else { ProtocolFilePath = string.Empty; Message = "\"Choose file\" is canceled"; return; } dvhObjectivesViewModel.DvhObjectives = new ObservableCollection <DvhObjective>(DvhObjective.ReadObjectivesFromCsv(ProtocolFilePath)); var dvhObjectives = dvhObjectivesViewModel.DvhObjectives; if (!StructureNames.Contains(StructureNameNone)) { StructureNames.Insert(0, StructureNameNone); } foreach (var o in dvhObjectives) { if (StructureNames.Contains(o.StructureName)) { o.StructureNameTps = o.StructureName; o.InUse = true; } else { o.StructureNameTps = StructureNameNone; } } if (dvhObjectives.Count > 0) { dvhObjectivesViewModel.ProtocolId = dvhObjectives[0].ProtocolId; } }
/// <summary> /// Constructor from DvhObjective /// </summary> /// <param name="dvhObjective"> DvhObjective </param> /// <param name="prescribedDose"> Prescribed dose in cGy </param> /// <param name="volume"> volume in cc </param> public ClinicalGoal(DvhObjective dvhObjective, double prescribedDose = 0, double volume = 0) { DvhObjective = dvhObjective; RoiName = dvhObjective.StructureNameTps; switch (dvhObjective.TargetType) { case DvhTargetType.Dose: if (dvhObjective.TargetUnit == DvhPresentationType.Rel) { //% to absolute dose (prescribed dose is given in cGy) AcceptanceLevel = prescribedDose * dvhObjective.TargetValue / 100; } else if (dvhObjective.TargetUnit == DvhPresentationType.Abs) { //Gy to cGy AcceptanceLevel = dvhObjective.TargetValue * 100; } switch (dvhObjective.ObjectiveType) { case DvhObjectiveType.Max: GoalCriteria = "AtMost"; GoalType = "DoseAtVolume"; ParameterValue = 0; break; case DvhObjectiveType.Min: GoalCriteria = "AtLeast"; GoalType = "DoseAtVolume"; ParameterValue = 1; break; case DvhObjectiveType.MeanUpper: GoalCriteria = "AtMost"; GoalType = "AverageDose"; ParameterValue = 0; break; case DvhObjectiveType.MeanLower: GoalCriteria = "AtLeast"; GoalType = "AverageDose"; ParameterValue = 0; break; case DvhObjectiveType.Upper: GoalCriteria = "AtMost"; if (dvhObjective.ArgumentUnit == DvhPresentationType.Rel) { GoalType = "DoseAtVolume"; ParameterValue = dvhObjective.ArgumentValue / 100; } else if (dvhObjective.ArgumentUnit == DvhPresentationType.Abs) { GoalType = "DoseAtAbsoluteVolume"; ParameterValue = dvhObjective.ArgumentValue; } break; case DvhObjectiveType.Lower: GoalCriteria = "AtLeast"; if (dvhObjective.ArgumentUnit == DvhPresentationType.Rel) { GoalType = "DoseAtVolume"; ParameterValue = dvhObjective.ArgumentValue / 100; } else if (dvhObjective.ArgumentUnit == DvhPresentationType.Abs) { GoalType = "DoseAtAbsoluteVolume"; ParameterValue = dvhObjective.ArgumentValue; } break; default: break; } break; case DvhTargetType.Volume: if (dvhObjective.TargetUnit == DvhPresentationType.Rel) { AcceptanceLevel = dvhObjective.TargetValue / 100; GoalType = "VolumeAtDose"; } else if (dvhObjective.TargetUnit == DvhPresentationType.Abs) { AcceptanceLevel = dvhObjective.TargetValue; GoalType = "AbsoluteVolumeAtDose"; } if (dvhObjective.ArgumentUnit == DvhPresentationType.Rel) { //prescribed dose is given in cGy ParameterValue = prescribedDose * dvhObjective.ArgumentValue / 100; } else if (dvhObjective.ArgumentUnit == DvhPresentationType.Abs) { //Gy to cGy ParameterValue = dvhObjective.ArgumentValue * 100; } switch (dvhObjective.ObjectiveType) { case DvhObjectiveType.Upper: GoalCriteria = "AtMost"; break; case DvhObjectiveType.Lower: GoalCriteria = "AtLeast"; break; case DvhObjectiveType.Spare: GoalCriteria = "AtMost"; if (dvhObjective.TargetUnit == DvhPresentationType.Rel) { AcceptanceLevel = 1 - AcceptanceLevel; } else if (dvhObjective.TargetUnit == DvhPresentationType.Abs) { AcceptanceLevel = volume - AcceptanceLevel; // 0 if acceptance level is larger than volume if (AcceptanceLevel < 0) { AcceptanceLevel = 0; } } break; default: break; } break; default: break; } }