Exemplo n.º 1
0
        public static int[] LowestValIndices(double[,] a, int dim, int numberPoints)
        //returns a list of indices corresponding to the lowest values within a list at a certain dimension.
        {
            double[]   min  = { a[0, dim], 0 }; //first entry min, second corresponding index
            List <int> used = new List <int>();

            int[] smalls = new int[numberPoints];

            for (int i = 0; i < numberPoints; i++)
            {
                for (int j = 0; j < a.GetLength(0); j++)
                {
                    if ((a[j, dim] < min[0]) && (!used.Contains(j)))
                    {
                        min[0] = a[j, dim];
                        min[1] = j;
                    }
                }
                smalls[i] = (int)min[1];
                used.Add(smalls[i]);
                min[0] = 1000;
                min[1] = 0;
            }
            smalls = Sort(smalls);
            smalls = DataConversion.ReverseArray(smalls);
            return(smalls);
        }
Exemplo n.º 2
0
        public static double[] GetYValues(DicomDataset doseData)
        {
            int[]    orientation = doseData.Get <int[]>(DicomTag.ImageOrientationPatient);
            double[] doseCorner  = doseData.Get <double[]>(DicomTag.ImagePositionPatient);
            int      rows        = doseData.Get <int>(DicomTag.Rows);

            double[] pixelSpacing = doseData.Get <double[]>(DicomTag.PixelSpacing);
            double[] yValues      = new double[rows];
            if ((orientation[0] == 1) && (orientation[1] == 0) && (orientation[2] == 0))
            {
                for (int i = 0; i < rows; i++)
                {
                    yValues[i] = pixelSpacing[1] * i + doseCorner[1];
                }
            }
            else if ((orientation[0] == -1) && (orientation[1] == 0) && (orientation[2] == 0))
            {
                for (int i = 0; i < rows; i++)
                {
                    yValues[i] = -pixelSpacing[1] * i + doseCorner[1];
                    yValues    = DataConversion.ReverseArray(yValues);
                }
            }
            else
            {
                Console.WriteLine("patient orientation error encountered. Terminating.");
                Environment.Exit(2);
            }
            return(yValues);
        }
Exemplo n.º 3
0
 public static double[] GetZValues(DicomDataset doseData)
 //This method gives back a double array with elements corresponding to the z-values for the doseMatrix 3rd dimension.
 {
     double[] offsetVector = doseData.Get <double[]>(DicomTag.GridFrameOffsetVector);
     double[] doseCorner   = doseData.Get <double[]>(DicomTag.ImagePositionPatient);
     //If first element starts with a 0, its a relative offset. if it starts with non-zero, it is patient coordinate system values
     if (offsetVector[0] != 0)
     {
         for (int i = 0; i < offsetVector.Length; i++)
         {
             offsetVector[i] -= offsetVector[0];
         }
     }
     double[] zValues = new double[offsetVector.Length];
     for (int i = 0; i < offsetVector.Length; i++)
     {
         zValues[i] = offsetVector[i] + doseCorner[2];
     }
     //Now flip if sorted by descending z.
     if (zValues[1] - zValues[0] < 0)
     {
         zValues = DataConversion.ReverseArray(zValues);
     }
     return(zValues);
 }
Exemplo n.º 4
0
        public static double[] GetXValues(DicomDataset doseData)
        {
            int[]    orientation = doseData.Get <int[]>(DicomTag.ImageOrientationPatient);
            double[] doseCorner  = doseData.Get <double[]>(DicomTag.ImagePositionPatient);
            int      cols        = doseData.Get <int>(DicomTag.Columns);

            double[] pixelSpacing = doseData.Get <double[]>(DicomTag.PixelSpacing);
            double[] xValues      = new double[cols];
            if ((orientation[3] == 0) && (orientation[4] == 1) && (orientation[5] == 0))
            {
                for (int i = 0; i < cols; i++)
                {
                    xValues[i] = pixelSpacing[0] * i + doseCorner[0];
                }
            }
            else if ((orientation[3] == 0) && (orientation[4] == -1) && (orientation[5] == 0))
            {
                for (int i = 0; i < cols; i++)
                {
                    xValues[i] = -pixelSpacing[0] * i + doseCorner[0];
                    xValues    = DataConversion.ReverseArray(xValues);
                }
            }
            else
            {
                Console.WriteLine("patient orientation error encountered. Terminating.");
                Environment.Exit(2);
            }
            return(xValues);
        }