//glowna funkcja private void mainOperations(Dataset _ds) { //inicjalizacja double[,] maxDose = new double[1, 2]; //maksymalna dawka i numer wiazki dla tej dawki maxDose[0, 0] = 0; maxDose[0, 1] = 0; double tmpDose = 0; //tymczasowa zmienna przechowujaca ostatnia dawke string[] tmpLeafPostionBoundariesOrJaws; #region wiązki Dataset dsFractionGroupSequence = _ds.GetItem(Tags.FractionGroupSeq, 0); this.numberOfBeams = Convert.ToInt16(dsFractionGroupSequence.GetString(Tags.NumberOfBeams, 0)); //inicjalizacja this.beamDoses = new double[this.numberOfBeams]; this.TPR = new double[this.numberOfBeams]; this.MU = new double[this.numberOfBeams]; this.SSD = new double[this.numberOfBeams]; this.SSDDepth = new double[this.numberOfBeams]; this.beamMetersets = new double[this.numberOfBeams]; this.nominalBeamEnergy = new double[this.numberOfBeams]; DcmElement dcmeReferencedBeamSequence = dsFractionGroupSequence.Get(Tags.RefBeamSeq); string message = "Liczba wiązek: " + numberOfBeams.ToString() + Environment.NewLine; Dataset dsReferencedBeams = null; for (int i = 0; i < numberOfBeams; i++) { dsReferencedBeams = dcmeReferencedBeamSequence.GetItem(i); tmpDose = Convert.ToDouble(dsReferencedBeams.GetString(Tags.BeamDose, 0).Replace('.', ',')) * 100; //aut zamiana dawki na cGy message += "Wiązka " + (i + 1) + " = " + Math.Round(tmpDose, 2).ToString() + " cGy" + Environment.NewLine; //wpisanie dawek do tablicy this.beamDoses[i] = tmpDose; //wpisanie MU do tablicy this.beamMetersets[i] = Convert.ToDouble(dsReferencedBeams.GetString(Tags.BeamMeterset, 0).Replace('.', ',')); message += "Zapisane MU = " + Math.Round(this.beamMetersets[i], 2).ToString() + Environment.NewLine; //wyświetlenie //maksymalna dawka if (tmpDose > maxDose[0, 0]) { maxDose[0, 0] = tmpDose; maxDose[0, 1] = i; //numer wiazki } } message += "Maksymalna dawka: " + Math.Round(maxDose[0, 0], 3).ToString() + ", wiązka nr " + maxDose[0, 1].ToString() + Environment.NewLine; #endregion #region listki, nominalna energia wiązek i SSD DcmElement dcmeBeamSequence = _ds.Get(Tags.BeamSeq); for (int i = 0; i < this.numberOfBeams; i++) { Dataset dsBeamParams = dcmeBeamSequence.GetItem(i); DcmElement dcmeBeamLimitingDeviceSequence = dsBeamParams.Get(Tags.BeamLimitingDeviceSeq); Dataset dsLeafs = dcmeBeamLimitingDeviceSequence.GetItem(1); message += Environment.NewLine + "Listki" + Environment.NewLine; //string[] test = dsLeafs.GetStrings(Tags.LeafPositionBoundaries); tmpLeafPostionBoundariesOrJaws = dsLeafs.GetString(Tags.LeafPositionBoundaries).Split('\\'); //wczytanie wsp x listkow message += "Parametry " + i + ": " + dsLeafs.GetString(Tags.LeafPositionBoundaries); //jesli nie istnieje tablica tworzymy ja lub (jesli istnieje) zmieniamy jej rozmiar, gdy jest za maly/duzy dla nowego pliku if (this.leafPositionBoundaries == null || (this.leafPositionBoundaries.Length / tmpLeafPostionBoundariesOrJaws.Length) != this.numberOfBeams || (this.leafPositionBoundaries.Length / this.numberOfBeams) < tmpLeafPostionBoundariesOrJaws.Length) { this.leafPositionBoundaries = new double[this.numberOfBeams, tmpLeafPostionBoundariesOrJaws.Length]; } for (int j = 0; j < tmpLeafPostionBoundariesOrJaws.Length; j++) { this.leafPositionBoundaries[i, j] = Convert.ToDouble(tmpLeafPostionBoundariesOrJaws[j].Replace('.', ',')); } DcmElement dcmeControlPointSequence = dsBeamParams.Get(Tags.ControlPointSeq); Dataset dsControlPointSequence = dcmeControlPointSequence.GetItem(0); #region nominal beam energy nominalBeamEnergy[i] = Convert.ToDouble(dsControlPointSequence.GetString(Tags.NominalBeamEnergy).Replace('.', ',')); message += Environment.NewLine + "nominalBeamEnergy: " + nominalBeamEnergy[i].ToString() + Environment.NewLine; #endregion #region leaf jaw positions DcmElement dcmeBeamLimitingDevicePositionSequence = dsControlPointSequence.Get(Tags.BeamLimitingDevicePositionSeq); //wsp x Dataset dsLeafJawPositionsX = dcmeBeamLimitingDevicePositionSequence.GetItem(1); message += Environment.NewLine + "LeafJawPositions(X): " + dsLeafJawPositionsX.GetString(Tags.LeafJawPositions) + Environment.NewLine; #region zapisanie do tablicy tmpLeafPostionBoundariesOrJaws = dsLeafJawPositionsX.GetString(Tags.LeafJawPositions).Split('\\'); //tymczasowa tablica //jesli nie istnieje tablica tworzymy ja lub (jesli istnieje) zmieniamy jej rozmiar, gdy jest za maly/duzy dla nowego pliku if (this.leafJawPositionsX == null || (this.leafJawPositionsX.Length / tmpLeafPostionBoundariesOrJaws.Length) != this.numberOfBeams || (this.leafJawPositionsX.Length / this.numberOfBeams) < tmpLeafPostionBoundariesOrJaws.Length) { this.leafJawPositionsX = new double[this.numberOfBeams, tmpLeafPostionBoundariesOrJaws.Length]; } for (int j = 0; j < tmpLeafPostionBoundariesOrJaws.Length; j++) { this.leafJawPositionsX[i, j] = Convert.ToDouble(tmpLeafPostionBoundariesOrJaws[j].Replace('.', ',')); } #endregion //wsp y Dataset dsLeafJawPositionsY = dcmeBeamLimitingDevicePositionSequence.GetItem(0); message += Environment.NewLine + "LeafJawPositions(Y): " + dsLeafJawPositionsY.GetString(Tags.LeafJawPositions) + Environment.NewLine; #region zapisanie do tablicy tmpLeafPostionBoundariesOrJaws = dsLeafJawPositionsY.GetString(Tags.LeafJawPositions).Split('\\'); //tymczasowa tablica //jesli nie istnieje tablica tworzymy ja lub (jesli istnieje) zmieniamy jej rozmiar, gdy jest za maly/duzy dla nowego pliku if (this.leafJawPositionsY == null || (this.leafJawPositionsY.Length / tmpLeafPostionBoundariesOrJaws.Length) != this.numberOfBeams || (this.leafJawPositionsY.Length / this.numberOfBeams) < tmpLeafPostionBoundariesOrJaws.Length) { this.leafJawPositionsY = new double[this.numberOfBeams, tmpLeafPostionBoundariesOrJaws.Length]; } for (int j = 0; j < tmpLeafPostionBoundariesOrJaws.Length; j++) { this.leafJawPositionsY[i, j] = Convert.ToDouble(tmpLeafPostionBoundariesOrJaws[j].Replace('.', ',')); } #endregion #endregion #region SSD i glebokosc izocentrum Dataset dsSourceAxisDistance = dcmeBeamSequence.GetItem(i); SSD[i] = Convert.ToDouble(dsControlPointSequence.GetString(Tags.SourceToSurfaceDistance).Replace('.', ',')) / 10; SSDDepth[i] = (Convert.ToDouble(dsSourceAxisDistance.GetString(Tags.SourceAxisDistance).Replace('.', ',')) / 10) - SSD[i]; message += Environment.NewLine + "SSD(cm): " + SSD[i].ToString() + Environment.NewLine; message += "Głębokość izocentrum(cm): " + SSDDepth[i].ToString() + Environment.NewLine; #endregion } #endregion #region automatyczne ladowanie tabeli wydajnosci i pdg dla danego aparatu bool properLoadWyd = false; bool properLoadPDG = false; if (nominalBeamEnergy[0].ToString() == "6") { properLoadWyd = this.loadTables(ref this.tlWyd, defaultTablePath6 + "wyd.dat"); properLoadPDG = this.loadTables(ref this.tlPDG, defaultTablePath6 + "pdg.dat"); } else if (nominalBeamEnergy[0].ToString() == "15") { properLoadWyd = this.loadTables(ref this.tlWyd, defaultTablePath15 + "wyd.dat"); properLoadPDG = this.loadTables(ref this.tlPDG, defaultTablePath15 + "pdg.dat"); } if (properLoadWyd && properLoadPDG) { MessageBox.Show("Pomyślnie załadowano pliki tabel wydajności i pdg!", "Sukces", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (properLoadWyd) { MessageBox.Show("Pomyślnie załadowano plik tabeli wydajności!", "Sukces", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Błąd ładowania pliku tabeli pdg!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (properLoadPDG) { MessageBox.Show("Pomyślnie załadowano plik tabeli pdg!", "Sukces", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Błąd ładowania pliku tabeli wydajności!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Błąd ładowania plików tabel wydajności i pdg!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion logTextbox.Text = message; }
//glowna funkcja private void mainOperations(Dataset _ds) { //inicjalizacja double[,] maxDose = new double[1, 2]; //maksymalna dawka i numer wiazki dla tej dawki maxDose[0, 0] = 0; maxDose[0, 1] = 0; double tmpDose = 0; //tymczasowa zmienna przechowujaca ostatnia dawke double[] nominalBeamEnergy; #region wiązki Dataset dsFractionGroupSequence = _ds.GetItem(Tags.FractionGroupSeq, 0); this.numberOfBeams = Convert.ToInt16(dsFractionGroupSequence.GetString(Tags.NumberOfBeams, 0)); //inicjalizacja this.beamDoses = new double[this.numberOfBeams]; this.TPR = new double[this.numberOfBeams]; this.MU = new double[this.numberOfBeams]; this.beamMetersets = new double[this.numberOfBeams]; nominalBeamEnergy = new double[this.numberOfBeams]; DcmElement dcmeReferencedBeamSequence = dsFractionGroupSequence.Get(Tags.RefBeamSeq); string message = "Liczba wiązek: " + numberOfBeams.ToString() + Environment.NewLine; Dataset dsReferencedBeams = null; for (int i = 0; i < numberOfBeams; i++) { dsReferencedBeams = dcmeReferencedBeamSequence.GetItem(i); message += "Wiązka " + (i + 1) + " = " + dsReferencedBeams.GetString(Tags.BeamDose, 0) + Environment.NewLine; tmpDose = Convert.ToDouble(dsReferencedBeams.GetString(Tags.BeamDose, 0).Replace('.', ',')); //wpisanie dawek do tablicy this.beamDoses[i] = tmpDose; //wpisanie MU do tablicy this.beamMetersets[i] = Convert.ToDouble(dsReferencedBeams.GetString(Tags.BeamMeterset, 0).Replace('.', ',')); message += "Zapisane MU = " + this.beamMetersets[i].ToString() + Environment.NewLine; //wyświetlenie //maksymalna dawka if (tmpDose > maxDose[0, 0]) { maxDose[0, 0] = tmpDose; maxDose[0, 1] = i; //numer wiazki } } message += "Maksymalna dawka: " + Math.Round(maxDose[0, 0], 3).ToString() + ", wiązka nr " + maxDose[0, 1].ToString() + Environment.NewLine; #endregion #region listki i nominalna energia wiązek DcmElement dcmeBeamSequence = _ds.Get(Tags.BeamSeq); for (int i = 0; i < this.numberOfBeams; i++) { Dataset dsBeamParams = dcmeBeamSequence.GetItem(i); DcmElement dcmeBeamLimitingDeviceSequence = dsBeamParams.Get(Tags.BeamLimitingDeviceSeq); Dataset dsLeafs = dcmeBeamLimitingDeviceSequence.GetItem(1); //bez zmian //Dataset dsLeafPositionBoundaries = dsLeafs.GetItem(Tags.LeafPositionBoundaries, 0); message += Environment.NewLine + "Listki" + Environment.NewLine; //string[] test = dsLeafs.GetStrings(Tags.LeafPositionBoundaries); message += "Parametry " + i + ": " + dsLeafs.GetString(Tags.LeafPositionBoundaries); //nominal beam energy DcmElement dcmeControlPointSequence = dsBeamParams.Get(Tags.ControlPointSeq); Dataset dsnominalBeamEnergy = dcmeControlPointSequence.GetItem(0); nominalBeamEnergy[i] = Convert.ToDouble(dsnominalBeamEnergy.GetString(Tags.NominalBeamEnergy).Replace('.', ',')); //message += "nominalBeamEnergy: " + nominalBeamEnergy.ToString() + Environment.NewLine; } #endregion #region obliczanie TPR for (int i = 0; i < numberOfBeams; i++) { this.TPR[i] = this.beamDoses[i] / nominalBeamEnergy[i]; } //message += "TPR: " + this.TPR.ToString() + Environment.NewLine; #endregion logTextbox.Text = message; }
//glowna funkcja private void mainOperations(Dataset _ds) { //inicjalizacja double[,] maxDose = new double[1, 2]; //maksymalna dawka i numer wiazki dla tej dawki maxDose[0, 0] = 0; maxDose[0, 1] = 0; double tmpDose = 0; //tymczasowa zmienna przechowujaca ostatnia dawke string[] tmpLeafPostionBoundariesOrJaws; Dataset dsFractionGroupSequence = _ds.GetItem(Tags.FractionGroupSeq, 0); if (dsFractionGroupSequence != null) { try { #region wiązki this.numberOfBeams = Convert.ToInt16(dsFractionGroupSequence.GetString(Tags.NumberOfBeams, 0)); this.numberOfFractions = Convert.ToInt16(dsFractionGroupSequence.GetString(Tags.NumberOfFractionsPlanned, 0)); //inicjalizacja this.beamDoses = new double[this.numberOfBeams]; this.TPR = new double[this.numberOfBeams]; this.MU = new double[this.numberOfBeams]; this.SSD = new double[this.numberOfBeams]; this.SSDDepth = new double[this.numberOfBeams]; this.radDepth = new double[this.numberOfBeams]; this.beamMetersets = new double[this.numberOfBeams]; this.nominalBeamEnergy = new double[this.numberOfBeams]; DcmElement dcmeReferencedBeamSequence = dsFractionGroupSequence.Get(Tags.RefBeamSeq); string message = "Liczba wiązek: " + numberOfBeams.ToString() + Environment.NewLine; message += "Frakcje: " + this.numberOfFractions + Environment.NewLine; Dataset dsReferencedBeams = null; for (int i = 0; i < numberOfBeams; i++) { dsReferencedBeams = dcmeReferencedBeamSequence.GetItem(i); tmpDose = Convert.ToDouble(dsReferencedBeams.GetString(Tags.BeamDose, 0).Replace('.', ',')) * 100; //zamiana dawki na cGy message += "Wiązka " + (i + 1) + " = " + Math.Round(tmpDose, 2).ToString() + " cGy" + Environment.NewLine; //wpisanie dawek do tablicy this.beamDoses[i] = tmpDose; //wpisanie MU do tablicy this.beamMetersets[i] = Convert.ToDouble(dsReferencedBeams.GetString(Tags.BeamMeterset, 0).Replace('.', ',')); message += "Zapisane MU = " + Math.Round(this.beamMetersets[i], 2).ToString() + Environment.NewLine; //wyświetlenie //maksymalna dawka if (tmpDose > maxDose[0, 0]) { maxDose[0, 0] = tmpDose; maxDose[0, 1] = i; //numer wiazki } } message += "Maksymalna dawka: " + Math.Round(maxDose[0, 0], 3).ToString() + ", wiązka nr " + maxDose[0, 1].ToString() + Environment.NewLine; #endregion #region listki, nominalna energia wiązek i SSD DcmElement dcmeBeamSequence = _ds.Get(Tags.BeamSeq); for (int i = 0; i < this.numberOfBeams; i++) { Dataset dsBeamParams = dcmeBeamSequence.GetItem(i); DcmElement dcmeBeamLimitingDeviceSequence = dsBeamParams.Get(Tags.BeamLimitingDeviceSeq); Dataset dsLeafs = dcmeBeamLimitingDeviceSequence.GetItem(1); message += Environment.NewLine + "Listki" + Environment.NewLine; //string[] test = dsLeafs.GetStrings(Tags.LeafPositionBoundaries); tmpLeafPostionBoundariesOrJaws = dsLeafs.GetString(Tags.LeafPositionBoundaries).Split('\\'); //wczytanie wsp x listkow message += "Parametry " + i + ": " + dsLeafs.GetString(Tags.LeafPositionBoundaries); //jesli nie istnieje tablica tworzymy ja lub (jesli istnieje) zmieniamy jej rozmiar, gdy jest za maly/duzy dla nowego pliku //GetUpperBound(poziom) - indeks ostatniego el na danym poziomie tablicy if (this.leafPositionBoundaries == null || (this.leafPositionBoundaries.GetUpperBound(0) + 1) != this.numberOfBeams || (this.leafPositionBoundaries.GetUpperBound(1) + 1) != tmpLeafPostionBoundariesOrJaws.Length) { this.leafPositionBoundaries = new double[this.numberOfBeams, tmpLeafPostionBoundariesOrJaws.Length]; } for (int j = 0; j < tmpLeafPostionBoundariesOrJaws.Length; j++) { this.leafPositionBoundaries[i, j] = Convert.ToDouble(tmpLeafPostionBoundariesOrJaws[j].Replace('.', ',')); } DcmElement dcmeControlPointSequence = dsBeamParams.Get(Tags.ControlPointSeq); Dataset dsControlPointSequence = dcmeControlPointSequence.GetItem(0); #region nominal beam energy nominalBeamEnergy[i] = Convert.ToDouble(dsControlPointSequence.GetString(Tags.NominalBeamEnergy).Replace('.', ',')); message += Environment.NewLine + "nominalBeamEnergy: " + nominalBeamEnergy[i].ToString() + Environment.NewLine; #endregion #region leaf jaw positions DcmElement dcmeBeamLimitingDevicePositionSequence = dsControlPointSequence.Get(Tags.BeamLimitingDevicePositionSeq); //wsp x Dataset dsLeafJawPositionsX = dcmeBeamLimitingDevicePositionSequence.GetItem(1); message += Environment.NewLine + "LeafJawPositions(X): " + dsLeafJawPositionsX.GetString(Tags.LeafJawPositions) + Environment.NewLine; #region zapisanie do tablicy tmpLeafPostionBoundariesOrJaws = dsLeafJawPositionsX.GetString(Tags.LeafJawPositions).Split('\\'); //tymczasowa tablica //jesli nie istnieje tablica tworzymy ja lub (jesli istnieje) zmieniamy jej rozmiar, gdy jest za maly/duzy dla nowego pliku if (this.leafJawPositionsX == null || (this.leafJawPositionsX.GetUpperBound(0) + 1) != this.numberOfBeams || (this.leafJawPositionsX.GetUpperBound(1) + 1) != tmpLeafPostionBoundariesOrJaws.Length) { this.leafJawPositionsX = new double[this.numberOfBeams, tmpLeafPostionBoundariesOrJaws.Length]; } for (int j = 0; j < tmpLeafPostionBoundariesOrJaws.Length; j++) { this.leafJawPositionsX[i, j] = Convert.ToDouble(tmpLeafPostionBoundariesOrJaws[j].Replace('.', ',')); } #endregion //wsp y Dataset dsLeafJawPositionsY = dcmeBeamLimitingDevicePositionSequence.GetItem(0); message += Environment.NewLine + "LeafJawPositions(Y): " + dsLeafJawPositionsY.GetString(Tags.LeafJawPositions) + Environment.NewLine; #region zapisanie do tablicy tmpLeafPostionBoundariesOrJaws = dsLeafJawPositionsY.GetString(Tags.LeafJawPositions).Split('\\'); //tymczasowa tablica //jesli nie istnieje tablica tworzymy ja lub (jesli istnieje) zmieniamy jej rozmiar, gdy jest za maly/duzy dla nowego pliku if (this.leafJawPositionsY == null || (this.leafJawPositionsY.GetUpperBound(0) + 1) != this.numberOfBeams || (this.leafJawPositionsY.GetUpperBound(1) + 1) != tmpLeafPostionBoundariesOrJaws.Length) { this.leafJawPositionsY = new double[this.numberOfBeams, tmpLeafPostionBoundariesOrJaws.Length]; } for (int j = 0; j < tmpLeafPostionBoundariesOrJaws.Length; j++) { this.leafJawPositionsY[i, j] = Convert.ToDouble(tmpLeafPostionBoundariesOrJaws[j].Replace('.', ',')); } #endregion #endregion #region SSD i glebokosc izocentrum Dataset dsSourceAxisDistance = dcmeBeamSequence.GetItem(i); SSD[i] = Convert.ToDouble(dsControlPointSequence.GetString(Tags.SourceToSurfaceDistance).Replace('.', ',')) / 10; SSDDepth[i] = (Convert.ToDouble(dsSourceAxisDistance.GetString(Tags.SourceAxisDistance).Replace('.', ',')) / 10) - SSD[i]; message += Environment.NewLine + "SSD(cm): " + SSD[i].ToString() + Environment.NewLine; message += "Głębokość izocentrum(cm): " + SSDDepth[i].ToString() + Environment.NewLine; #endregion } #endregion this.properRTPlanLoaded = true; logTextbox.Text = message; } catch (NullReferenceException) //wyłapywanie braku którychś danych { MessageBox.Show("Ten plik nie zawiera wszystkich potrzebnych do obliczeń danych!" + Environment.NewLine + "Spróbuj załadować prawidłowy plik!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); this.properRTPlanLoaded = false; } #region wczytywanie parametrow z plikow DOSE //inicjalizacja bool[] doseLoaded = new bool[this.numberOfBeams]; if (MessageBox.Show("Czy chcesz załadować pliki RT Dose?", "Ładowanie RT Dose", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { #region automatyczne wczytywanie plikow DOSE string RTPlanPath = Path.GetDirectoryName(fileNameTextbox.Text); IEnumerable<string> RTPlanDirDoseFiles = Directory.EnumerateFiles(RTPlanPath, "RD*.dcm"); int j = 0; foreach (string doseFileName in RTPlanDirDoseFiles) { DOSELoad doseload = this.doseFileLoad(doseFileName); List<List<string>> doseData = doseload.beamData(); if (doseload.success) { if (doseData[1].Count > 0) //sprawdzenie, czy potrzebne dane sa w pliku { this.SSD[doseload.beamNumber - 1] = Convert.ToDouble(doseData[1][3].Replace('.', ',')) / 10; this.SSDDepth[doseload.beamNumber - 1] = Convert.ToDouble(doseData[1][4].Replace('.', ',')) / 10; this.radDepth[doseload.beamNumber - 1] = Convert.ToDouble(doseData[1][5].Replace('.', ',')) / 10; doseLoaded[j] = true; } else { j--; //zmniejszenie licznika aby zaladowac wlasciwy plik dla kazdej wiazki } } else { doseLoaded[j] = false; } j++; } if (j > 0) { MessageBox.Show("Załadowano " + j.ToString() + " plików RT Dose", "Pliki RT Dose", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Nie znaleziono w katalogu RT Planu plików RT Dose", "Pliki RT Dose", MessageBoxButtons.OK, MessageBoxIcon.Information); } #endregion } else { MessageBox.Show("W związku z niewybraniem plików RT Dose niektóre wyniki mogą być nieprecyzyjne!", "Ostrzeżenie", MessageBoxButtons.OK, MessageBoxIcon.Warning); } #endregion #region automatyczne ladowanie tabeli wydajnosci i pdg dla danego aparatu bool properLoadWyd = false; bool properLoadPDG = false; if (nominalBeamEnergy[0].ToString() == "6") { properLoadWyd = this.loadTables(ref this.tlWyd, defaultTablePath6 + "wyd.dat"); properLoadPDG = this.loadTables(ref this.tlPDG, defaultTablePath6 + "pdg.dat"); } else if (nominalBeamEnergy[0].ToString() == "15") { properLoadWyd = this.loadTables(ref this.tlWyd, defaultTablePath15 + "wyd.dat"); properLoadPDG = this.loadTables(ref this.tlPDG, defaultTablePath15 + "pdg.dat"); } if (properLoadWyd && properLoadPDG) { MessageBox.Show("Pomyślnie załadowano pliki tabel wydajności i pdg!", "Sukces", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (properLoadWyd) { MessageBox.Show("Pomyślnie załadowano plik tabeli wydajności!", "Sukces", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Błąd ładowania pliku tabeli pdg!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (properLoadPDG) { MessageBox.Show("Pomyślnie załadowano plik tabeli pdg!", "Sukces", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Błąd ładowania pliku tabeli wydajności!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Błąd ładowania plików tabel wydajności i pdg!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion } else //w przypadku, gdy nie jest to RT Plan { MessageBox.Show("Ten plik nie zawiera potrzebnych danych!" + Environment.NewLine + "Najprawdopodobniej nie jest to RTPlan - spróbuj załadować prawidłowy plik!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//glowna funkcja private void mainOperations(Dataset _ds) { //inicjalizacja double[,] maxDose = new double[1, 2]; //maksymalna dawka i numer wiazki dla tej dawki maxDose[0, 0] = 0; maxDose[0, 1] = 0; double tmpDose = 0; //tymczasowa zmienna przechowujaca ostatnia dawke double[] nominalBeamEnergy; string[] tmpLeafPostionBoundaries; #region wiązki Dataset dsFractionGroupSequence = _ds.GetItem(Tags.FractionGroupSeq, 0); this.numberOfBeams = Convert.ToInt16(dsFractionGroupSequence.GetString(Tags.NumberOfBeams, 0)); //inicjalizacja this.beamDoses = new double[this.numberOfBeams]; this.TPR = new double[this.numberOfBeams]; this.MU = new double[this.numberOfBeams]; this.beamMetersets = new double[this.numberOfBeams]; nominalBeamEnergy = new double[this.numberOfBeams]; DcmElement dcmeReferencedBeamSequence = dsFractionGroupSequence.Get(Tags.RefBeamSeq); string message = "Liczba wiązek: " + numberOfBeams.ToString() + Environment.NewLine; Dataset dsReferencedBeams = null; for (int i = 0; i < numberOfBeams; i++) { dsReferencedBeams = dcmeReferencedBeamSequence.GetItem(i); message += "Wiązka " + (i + 1) + " = " + dsReferencedBeams.GetString(Tags.BeamDose, 0) + Environment.NewLine; tmpDose = Convert.ToDouble(dsReferencedBeams.GetString(Tags.BeamDose, 0).Replace('.', ',')); //wpisanie dawek do tablicy this.beamDoses[i] = tmpDose; //wpisanie MU do tablicy this.beamMetersets[i] = Convert.ToDouble(dsReferencedBeams.GetString(Tags.BeamMeterset, 0).Replace('.', ',')); message += "Zapisane MU = " + this.beamMetersets[i].ToString() + Environment.NewLine; //wyświetlenie //maksymalna dawka if (tmpDose > maxDose[0, 0]) { maxDose[0, 0] = tmpDose; maxDose[0, 1] = i; //numer wiazki } } message += "Maksymalna dawka: " + Math.Round(maxDose[0, 0], 3).ToString() + ", wiązka nr " + maxDose[0, 1].ToString() + Environment.NewLine; #endregion #region listki i nominalna energia wiązek DcmElement dcmeBeamSequence = _ds.Get(Tags.BeamSeq); for (int i = 0; i < this.numberOfBeams; i++) { Dataset dsBeamParams = dcmeBeamSequence.GetItem(i); DcmElement dcmeBeamLimitingDeviceSequence = dsBeamParams.Get(Tags.BeamLimitingDeviceSeq); Dataset dsLeafs = dcmeBeamLimitingDeviceSequence.GetItem(1); message += Environment.NewLine + "Listki" + Environment.NewLine; //string[] test = dsLeafs.GetStrings(Tags.LeafPositionBoundaries); tmpLeafPostionBoundaries = dsLeafs.GetString(Tags.LeafPositionBoundaries).Split('\\'); //wczytanie wsp x listkow message += "Parametry " + i + ": " + dsLeafs.GetString(Tags.LeafPositionBoundaries); //jesli nie istnieje tablica tworzymy ja lub (jesli istnieje) zmieniamy jej rozmiar, gdy jest za maly/duzy dla nowego pliku if (this.leafPositionBoundaries == null || (this.leafPositionBoundaries.Length / tmpLeafPostionBoundaries.Length) != this.numberOfBeams || (this.leafPositionBoundaries.Length / this.numberOfBeams) < tmpLeafPostionBoundaries.Length) { this.leafPositionBoundaries = new double[this.numberOfBeams, tmpLeafPostionBoundaries.Length]; } for (int j = 0; j < tmpLeafPostionBoundaries.Length; j++) { this.leafPositionBoundaries[i, j] = Convert.ToDouble(tmpLeafPostionBoundaries[j].Replace('.', ',')); } DcmElement dcmeControlPointSequence = dsBeamParams.Get(Tags.ControlPointSeq); Dataset dsControlPointSequence = dcmeControlPointSequence.GetItem(0); #region nominal beam energy nominalBeamEnergy[i] = Convert.ToDouble(dsControlPointSequence.GetString(Tags.NominalBeamEnergy).Replace('.', ',')); message += Environment.NewLine + "nominalBeamEnergy: " + nominalBeamEnergy[i].ToString() + Environment.NewLine; #endregion #region leaf jaw positions DcmElement dcmeBeamLimitingDevicePositionSequence = dsControlPointSequence.Get(Tags.BeamLimitingDevicePositionSeq); //wsp x Dataset dsLeafJawPositionsX = dcmeBeamLimitingDevicePositionSequence.GetItem(1); message += Environment.NewLine + "LeafJawPositions(X): " + dsLeafJawPositionsX.GetString(Tags.LeafJawPositions) + Environment.NewLine; //wsp y Dataset dsLeafJawPositionsY = dcmeBeamLimitingDevicePositionSequence.GetItem(0); message += Environment.NewLine + "LeafJawPositions(Y): " + dsLeafJawPositionsY.GetString(Tags.LeafJawPositions) + Environment.NewLine; #endregion } #endregion #region obliczanie TPR for (int i = 0; i < numberOfBeams; i++) { this.TPR[i] = this.beamDoses[i] / nominalBeamEnergy[i]; } //message += "TPR: " + this.TPR.ToString() + Environment.NewLine; #endregion logTextbox.Text = message; }