Пример #1
0
 public PathSet(float[][,] f, int sthick, int tolthick, DoseKernel dk, StructureSet ss)
 {
     X = f[0].GetLength(0); Y = f[0].GetLength(1); Z = f.GetLength(0);
     DK = dk; SS = ss;
     N = dk.dose.GetLength(0);
     boundaries = FindBoundaries(f);
     SliceThickness = sthick;
     DoseCalculationThickness = SliceThickness * 2;
     TolThickness = tolthick;
     CalculateNumSlices();
     RasterPaths = new ArrayList();
     for (int i = 0; i < NumSlices; i++)
     {
         RasterPath rp = new RasterPath(CompressSection(f, SlicePositions[i], SliceThickness / 2));
         RasterPaths.Add(rp);
     }
     volume = f;
     AttachHandlers();
 }
Пример #2
0
 private void LoadDose_menu_Click(object sender, RoutedEventArgs e)
 {
     Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
     if (ofd.ShowDialog() != false)
     {
         DK = new DoseKernel(ofd.FileName);
         plan_dpRB.IsEnabled = true;
         IsDoseLoaded = true;
         RasterPath.doseN = DoseKernel.N;
         AddDoseLoadedToListBox();
     }
 }
Пример #3
0
 private void Load4mmDefault()
 {
     DK = new DoseKernel(4);
     plan_dpRB.IsEnabled = true;
     IsDoseLoaded = true;
     RasterPath.doseN = DoseKernel.N;
     RasterPath.N = DoseKernel.N;
     AddDoseLoadedToListBox();
 }
Пример #4
0
 /// <summary>
 /// Frontend method that calls PS_InitialDose_worker backgroundworker. 
 /// Background worker runs CalculateSliceDosesAndWrite() and AssembleFinalDoseMatrix()
 /// </summary>
 /// <param name="dk"></param>
 /// <param name="path"></param>
 public void CreateDoseMatrix(DoseKernel dk, string path)
 {
     this.folderpath = path;
     this.DK = dk;
     PS_CalcDose_worker.RunWorkerAsync();
 }
Пример #5
0
 /* TODO: Step-by-step walkthrough
  * 1) CreateDoseMatrix() is called
  * 2)
  */
 /// <summary>
 /// Given a folder path and a DoseKernel, will create path names for each rasterpath in RasterPaths 
 /// and write each resulting slicedose to path specified.
 /// </summary>
 /// <param name="dk"></param>
 /// <param name="folderpath"></param>
 public void CalculateAndWriteSliceDoses(DoseKernel dk, string folderpath)
 {
     DK = dk; this.folderpath = folderpath;
     string path;
     string subfolder = System.IO.Path.Combine(folderpath, DateTime.Now.ToString("yyyyMMddHHmmssfff"));
     System.IO.Directory.CreateDirectory(subfolder);
     ActiveDirectory = subfolder;
     this.folderpath = subfolder;
     for (int s = 0; s < NumSlices; s++)
     {
         string filename = string.Concat("slice_", s);
         path = System.IO.Path.Combine(subfolder, filename);
         RasterPath rp = (RasterPath)RasterPaths[s];
         rp.CalculateAndSaveSliceDose(dk, DoseCalculationThickness, path);
     }
     //TODO: Need to have some kind of confirmation event?
 }
Пример #6
0
 public void CalculateAndSaveSliceDose(DoseKernel dk, int dosecalcthickness, string savepath)
 {
     PointF[] startingpoints = GetStartingPoints(shots);
     N = dk.DKI.Size;
     int xsize = slice.GetLength(0); int ysize = slice.GetLength(1);
     int xmid = xsize / 2; int ymid = ysize / 2; int zmid = dosecalcthickness / 2;
     int StartingDoseSlice = ((N - 1) / 2) - zmid;
     float[] slicedose = new float[xsize * ysize * dosecalcthickness];
     for (int k = 0; k < dosecalcthickness; k++)
         for (int j = 0; j < N; j++)
             for (int i = 0; i < N; i++)
                 for (int w = 0; w < shots.GetLength(0); w++)
                 {
                     PointF shot = shots[w];
                     PointF center = new PointF((N - 1) / 2, (N - 1) / 2);
                     PointF firstdosepixel = FindFirstExistingDosePixel(shot);
                     PointF lastdosepixel = FindLastExistingDosePixel(shot, new PointF(xsize, ysize));
                     if (i < firstdosepixel.X || j < firstdosepixel.Y) //if the current dose pixel doesn't exist for the shot, continue
                         continue;
                     else if (i > lastdosepixel.X || j > lastdosepixel.Y)
                         continue;
                     else
                     {
                         if (dk.ReturnSpecificDoseValue(i, j, k) * weight[w] > 0)
                             slicedose[k * xsize * ysize + ((int)shot.Y - (int)center.Y + j) * xsize + ((int)shot.X - (int)center.X + i)] += dk.ReturnSpecificDoseValue(i, j, StartingDoseSlice+k) * weight[w];
                     }
                 }
     float f = dk.ReturnSpecificDoseValue(80, 80, 80);
     WriteToFile(savepath, slicedose, xsize, ysize, dosecalcthickness);
 }