Esempio n. 1
0
        public void CalculateBackground(Tiff scanTiff, int projectId, int runId)
        {
            int[] colsForBackground = new int[] { 1, TiffImages.columnPerScan };
            IEnumerable <int>[] colsForBackgroundMolFrames = new IEnumerable <int> [colsForBackground.Length];
            HashSet <short>     framesForBackgroundCalc    = new HashSet <short>();

            for (int colPos = 0; colPos < colsForBackground.Length; colPos++)
            {
                colsForBackgroundMolFrames[colPos] = DatabaseManager.SelectColumnRows(projectId, runId, 1, colsForBackground[colPos]);
                for (int row = 1; row <= TiffImages.rowsPerColumn; row++)
                {
                    if (!colsForBackgroundMolFrames[colPos].Contains(row))
                    {
                        framesForBackgroundCalc.Add(TiffImages.GetFrameNumber(colsForBackground[colPos], row, this.Channel));
                    }
                }
            }
            this.CalculateAveragePixelValues(scanTiff, framesForBackgroundCalc);
            this.CalculateBackgroundStd();
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();

            string[] runRootDirs = runs_paths_txtbx2.Text.Split('\n');
            if (String.IsNullOrEmpty(runRootDirs[0]))
            {
                MessageBox.Show("Must provide path to root directory of run files", "Missing file path");
                return;
            }
            stopWatch.Start();
            Task newTask = Task.Factory.StartNew(() =>
            {
                Dictionary <int, Scan[]> selectedMolecules = DatabaseManager.SelectMoleculesForPixelData(projectID, alignmentFilter, lengthFilter, confidenceFilter, alignedLenPercentFilter, molIdsFilterArray, chromIdsFilter,
                                                                                                         chromStartEndFilter);
                TiffImages.ProcessAllRuns(projectID, runRootDirs, selectedMolecules, updateBox);
            });

            newTask.ContinueWith(_ => MessageBox.Show(stopWatch.Elapsed.ToString()));
        }
Esempio n. 3
0
 private void CalculateAveragePixelValues(Tiff scanTiff, IEnumerable <short> noMoleculeFrames)
 {
     short[][] framePixels;
     foreach (short frame in noMoleculeFrames)
     {
         framePixels = TiffImages.FramePixelsAsShortArray(scanTiff, frame);
         for (int row = 0; row < this.ImageLength; row++)
         {
             for (int col = 0; col < this.ImageWidth; col++)
             {
                 this.PixelValues[row][col] += framePixels[row][col];
             }
         }
     }
     for (int row = 0; row < this.ImageLength; row++)
     {
         for (int col = 0; col < this.ImageWidth; col++)
         {
             this.PixelValues[row][col] /= noMoleculeFrames.Count();
             this.AverageValue          += this.PixelValues[row][col];
         }
     }
     this.AverageValue /= (ImageLength * ImageWidth);
 }