Esempio n. 1
0
        private static void ProcessRunTiffs(int projectId, string[] runsDirectoryPaths, int runId, Scan[] runMoleculesByScanByCol, UpdateBox updateBox)
        {
            BackgroundFOV[] allChannelsBackgroundFOVs;

            string[] runNameMonth = DatabaseManager.GetRunNameMonth(runId);
            int      rootDirIdx   = UserInputParser.GetRunRootDir(runsDirectoryPaths, runNameMonth[1], runNameMonth[0]);

            if (rootDirIdx >= 0)
            {
                string runDir             = Path.Combine(runsDirectoryPaths[rootDirIdx], runNameMonth[1], runNameMonth[0]);
                string backgroundTiffPath = Path.Combine(runDir, runNameMonth[0] + "_Scan001.tiff");
                using (Tiff backgroundTiff = Tiff.Open(backgroundTiffPath, "r"))
                {
                    FieldValue[] width  = backgroundTiff.GetField(TiffTag.IMAGEWIDTH);
                    FieldValue[] height = backgroundTiff.GetField(TiffTag.IMAGELENGTH);
                    imageLength  = height[0].ToInt();
                    imageWidth   = width[0].ToInt();
                    scanlineSize = backgroundTiff.ScanlineSize();
                    allChannelsBackgroundFOVs = GetAllChannelsBackgroundFOVs(backgroundTiff, projectId, runId);
                }

                Parallel.ForEach(runMoleculesByScanByCol.Where(scan => scan != null), scan =>
                {
                    ProcessScanTiff(runDir, runNameMonth[0], scan, allChannelsBackgroundFOVs, updateBox);
                });
            }
        }
Esempio n. 2
0
 public static void ProcessAllRuns(int projectId, string[] runsDirectoryPaths, Dictionary <int, Scan[]> selectedMolecules, UpdateBox updateBox)
 {
     DatabaseManager.SetConnection();
     DatabaseManager.sql_con.Open();
     using (DatabaseManager.sql_con)
     {
         foreach (KeyValuePair <int, Scan[]> moleculesByRun in selectedMolecules)
         {
             ProcessRunTiffs(projectId, runsDirectoryPaths, moleculesByRun.Key, moleculesByRun.Value, updateBox);
         }
     }
 }
Esempio n. 3
0
        public static void ProcessScanTiff(string runPath, string runName, Scan scan, BackgroundFOV[] allChannelsBackgroundFOVs, UpdateBox updateBox)
        {
            const string scanFilesSubDir  = "Detect Molecules";
            const string FOVFilePrefix    = "Stitch";
            const string FOVFileExtension = ".fov";

            string scanTiffFilePath = Path.Combine(runPath, runName + "_Scan" + scan.ScanNumber.ToString("D3") + ".tiff");
            string FOVFilePath      = Path.Combine(runPath, scanFilesSubDir, FOVFilePrefix + scan.ScanNumber.ToString() + FOVFileExtension);

            using (Tiff scanImages = Tiff.Open(scanTiffFilePath, "r"))
            {
                FieldValue[] width           = scanImages.GetField(TiffTag.IMAGEWIDTH);
                FieldValue[] height          = scanImages.GetField(TiffTag.IMAGELENGTH);
                FieldValue[] bitsPerSample   = scanImages.GetField(TiffTag.BITSPERSAMPLE);
                FieldValue[] samplesPerPixel = scanImages.GetField(TiffTag.SAMPLESPERPIXEL);
                imageLength  = height[0].ToInt();
                imageWidth   = width[0].ToInt();
                bitsPerPixel = bitsPerSample[0].ToShort();
                spp          = samplesPerPixel[0].ToShort();
                scanlineSize = scanImages.ScanlineSize();

                Dictionary <Tuple <int, int>, FOV> FOVData = ParseFOVFile(FOVFilePath);

                using (var transaction = DatabaseManager.sql_con.BeginTransaction())
                {
                    for (int currColumn = 1; currColumn <= columnPerScan; currColumn++)
                    {
                        if (scan.ColumnMolecules[currColumn - 1].Count > 0)
                        {
                            ProcessColumnImages(scanImages, currColumn, FOVData, allChannelsBackgroundFOVs, scan.ColumnMolecules[currColumn - 1]);
                        }
                        updateBox(currColumn.ToString());
                    }
                    transaction.Commit();
                }
                scan.ColumnMolecules = null;
            }
        }