Пример #1
0
        public bool GetIndicatorList(int experimentID)
        {
            bool success = true;
            ObservableCollection <ExperimentIndicatorContainer> indicators;

            if (m_db.GetAllExperimentIndicatorsForExperiment(experimentID, out indicators))
            {
                m_vm.indicators = indicators;
            }
            else
            {
                success = false;
            }

            return(success);
        }
Пример #2
0
        private void CreateReportPB_Click(object sender, RoutedEventArgs e)
        {
            ObservableCollection <ExperimentIndicatorContainer> expIndicatorList;
            bool success = m_wgDB.GetAllExperimentIndicatorsForExperiment(VM.CurrentExperiment.ExperimentID, out expIndicatorList);

            if (success)
            {
                ProjectContainer project;
                success = m_wgDB.GetProject(VM.CurrentProject.ProjectID, out project);

                if (success && project != null)
                {
                    ExperimentContainer experiment;
                    success = m_wgDB.GetExperiment(VM.CurrentExperiment.ExperimentID, out experiment);

                    if (success && experiment != null)
                    {
                        ReportDialog dlg = new ReportDialog(project, experiment, expIndicatorList);

                        dlg.ShowDialog();
                    }
                }
            }
        }
Пример #3
0
        public bool WriteExperimentFile_WaveGuide(string filename, List <AnalysisContainer> analysisList)
        {
            bool success = true;

            if (File.Exists(filename))
            {
                MessageBoxResult result = MessageBox.Show("File: " + filename + " already exists! Do you want to over write it?", "File Already Exists",
                                                          MessageBoxButton.YesNo, MessageBoxImage.Exclamation);

                switch (result)
                {
                case MessageBoxResult.Yes:
                    File.Delete(filename);
                    break;

                case MessageBoxResult.No:
                    success           = false;
                    m_lastErrorString = "File already exists";
                    break;
                }
            }



            if (success)
            {
                try
                {
                    string delimiter = "\t";   // \t = tab

                    FileStream fs = new FileStream(filename, FileMode.CreateNew, FileAccess.Write);

                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        //  Start writing HEADER

                        sw.WriteLine("<HEADER>");
                        DateTime dt = m_experiment.TimeStamp;
                        sw.WriteLine("Date" + delimiter + dt.Year.ToString() + "-" + dt.Month.ToString() + "-" + dt.Day.ToString());
                        sw.WriteLine("Time" + delimiter + dt.Hour.ToString() + ":" + dt.Minute.ToString() + ":" + dt.Second.ToString());
                        sw.WriteLine("Instrument" + delimiter + "Panoptic");
                        sw.WriteLine("ProtocolName" + delimiter + m_method.Description);
                        sw.WriteLine("AssayPlateBarcode" + delimiter + m_plate.Barcode);

                        success = m_wgDB.GetAllExperimentCompoundPlatesForExperiment(m_experiment.ExperimentID);
                        if (success)
                        {
                            foreach (ExperimentCompoundPlateContainer ecPlate in m_wgDB.m_experimentCompoundPlateList)
                            {
                                sw.WriteLine("AddPlateBarcode" + delimiter + ecPlate.Barcode);
                            }
                        }

                        ObservableCollection <ExperimentIndicatorContainer> expIndicatorList = new ObservableCollection <ExperimentIndicatorContainer>();
                        foreach (AnalysisContainer ac in analysisList)
                        {
                            ExperimentIndicatorContainer expIndicator;
                            success = m_wgDB.GetExperimentIndicator(ac.ExperimentIndicatorID, out expIndicator);
                            if (success && expIndicator != null)
                            {
                                // make sure this experiment indicator isn't already in the list
                                bool alreadyInList = false;
                                foreach (ExperimentIndicatorContainer expCont in expIndicatorList)
                                {
                                    if (expIndicator.ExperimentIndicatorID == expCont.ExperimentIndicatorID)
                                    {
                                        alreadyInList = true;
                                        break;
                                    }
                                }

                                if (!alreadyInList)
                                {
                                    sw.WriteLine("Indicator" + delimiter +
                                                 expIndicator.Description + delimiter +
                                                 expIndicator.ExcitationFilterDesc + delimiter +
                                                 expIndicator.EmissionFilterDesc + delimiter +
                                                 expIndicator.Exposure.ToString() + delimiter +
                                                 expIndicator.Gain.ToString());

                                    expIndicatorList.Add(expIndicator);
                                }
                            }
                        }


                        success = m_wgDB.GetAllExperimentIndicatorsForExperiment(m_experiment.ExperimentID, out expIndicatorList);
                        if (success)
                        {
                            foreach (ExperimentIndicatorContainer expIndicator in expIndicatorList)
                            {
                            }
                        }

                        sw.WriteLine("NumRows" + delimiter + m_plateType.Rows.ToString());
                        sw.WriteLine("NumCols" + delimiter + m_plateType.Cols.ToString());

                        List <EventMarkerContainer> eventMarkerList;
                        success = m_wgDB.GetAllEventMarkersForExperiment(m_experiment.ExperimentID, out eventMarkerList);
                        if (success)
                        {
                            foreach (EventMarkerContainer eventMarker in eventMarkerList)
                            {
                                string timeString = String.Format("{0:0.000}", (float)eventMarker.SequenceNumber / 1000);
                                sw.WriteLine("Event" + delimiter + eventMarker.Name + delimiter +
                                             eventMarker.Description + delimiter +
                                             timeString);
                            }
                        }

                        sw.WriteLine("Operator" + delimiter + m_user.Username + delimiter +
                                     m_user.Lastname + delimiter +
                                     m_user.Firstname);

                        sw.WriteLine("Project" + delimiter + m_project.Description);

                        sw.WriteLine("</HEADER>");

                        // END writing HEADER


                        if (success)
                        {
                            foreach (AnalysisContainer analysis in analysisList)
                            {
                                ExperimentIndicatorContainer expIndicator;
                                success = m_wgDB.GetExperimentIndicator(analysis.ExperimentIndicatorID, out expIndicator);

                                sw.WriteLine("<INDICATOR_DATA" + delimiter + expIndicator.Description + delimiter + ">");

                                // START write column headers
                                sw.Write("Time" + delimiter);

                                StringBuilder builder = new StringBuilder();
                                for (int r = 0; r < m_plateType.Rows; r++)
                                {
                                    for (int c = 0; c < m_plateType.Cols; c++)
                                    {
                                        builder.Append((char)(65 + r)).Append(c + 1).Append(delimiter);
                                    }
                                }
                                builder.Remove(builder.Length - delimiter.Length, delimiter.Length); // remove last delimiter
                                sw.WriteLine(builder.ToString());
                                // END write column headers

                                // START writing data frames
                                success = m_wgDB.GetAllAnalysisFramesForAnalysis(analysis.AnalysisID);
                                if (success)
                                {
                                    foreach (AnalysisFrameContainer aFrame in m_wgDB.m_analysisFrameList)
                                    {
                                        string timeString = String.Format("{0:0.000}", (float)aFrame.SequenceNumber / 1000);
                                        sw.Write(timeString + delimiter);

                                        string[] values = aFrame.ValueString.Split(',');
                                        foreach (string val in values)
                                        {
                                            sw.Write(val + delimiter);
                                        }

                                        sw.WriteLine("");
                                    }
                                }
                                // END writing data frames

                                sw.WriteLine("</INDICATOR_DATA>");
                            }
                        }
                    }

                    if (!success)
                    {
                        m_lastErrorString = m_wgDB.GetLastErrorMsg();
                    }
                } // end try
                catch (Exception e)
                {
                    success           = false;
                    m_lastErrorString = e.Message;
                }
            }

            return(success);
        } // end function
Пример #4
0
        void LoadSimulationConfiguration()
        {
            //  m_iParams = iParams;
            //  m_project = project;
            //  m_experimentPlate = plate;
            //  m_method = method;
            //  m_mask = mask;
            //  m_plateType = plateType;
            //  m_indicatorList = indicatorList;
            //  m_compoundPlateList = compoundPlateList;
            //  m_controlSubtractionWellList = controlSubtractionWellList;
            //m_numFoFrames = numFoFrames;
            //m_dynamicRatioNumerator = dynamicRatioNumerator;
            //m_dynamicRatioDenominator = dynamicRatioDenominator;

            //ChartArray.BuildChartArray(mask.Rows, mask.Cols, m_indicatorList);

            ////////////////////////
            // set up project
            m_project = null;
            bool success = m_wgDB.GetAllProjects(false);

            foreach (ProjectContainer project in m_wgDB.m_projectList)
            {
                if (project.Description.Equals("Debug", StringComparison.OrdinalIgnoreCase))
                {
                    m_project = project;
                    break;
                }
            }
            if (m_project == null) // not found in database, so create it
            {
                m_project             = new ProjectContainer();
                m_project.Description = "Debug";
                m_project.TimeStamp   = DateTime.Now;
                m_project.Archived    = false;
                success = m_wgDB.InsertProject(ref m_project);
            }


            ////////////////////////
            // set up plateType
            m_plateType = null;
            success     = m_wgDB.GetAllPlateTypes();
            if (m_wgDB.m_plateTypeList.Count() > 0)
            {
                m_plateType = m_wgDB.m_plateTypeList.ElementAt(0);
            }
            else
            {
                // create a new plateType
                m_plateType             = new PlateTypeContainer();
                m_plateType.Cols        = 24;
                m_plateType.Description = "Debug";
                m_plateType.IsDefault   = false;
                m_plateType.Rows        = 16;
                success = m_wgDB.InsertPlateType(ref m_plateType);
            }



            ////////////////////////
            // set up experiment plate
            m_experimentPlate = null;
            success           = m_wgDB.GetAllPlatesForProject(m_project.ProjectID);
            if (m_wgDB.m_plateList.Count() > 0)
            {
                m_experimentPlate = m_wgDB.m_plateList.ElementAt(0);
            }
            else
            {
                // create a new plate
                m_experimentPlate             = new PlateContainer();
                m_experimentPlate.Barcode     = "12345678";
                m_experimentPlate.Description = "Debug";
                m_experimentPlate.IsPublic    = true;
                m_experimentPlate.OwnerID     = GlobalVars.UserID;
                m_experimentPlate.PlateTypeID = m_plateType.PlateTypeID;
                m_experimentPlate.ProjectID   = m_project.ProjectID;

                success = m_wgDB.InsertPlate(ref m_experimentPlate);
            }



            ////////////////////////
            // set up method
            m_method = null;
            success  = m_wgDB.GetAllMethodsForUser(GlobalVars.UserID);
            foreach (MethodContainer method in m_wgDB.m_methodList)
            {
                if (method.Description.Equals("Debug", StringComparison.OrdinalIgnoreCase))
                {
                    m_method = method;
                    break;
                }
            }
            if (m_method == null)
            {
                m_method = new MethodContainer();
                m_method.BravoMethodFile = "";
                m_method.Description     = "Debug";
                m_method.IsPublic        = true;
                m_method.OwnerID         = GlobalVars.UserID;
                success = m_wgDB.InsertMethod(ref m_method);
            }
            success = m_wgDB.GetAllIndicatorsForMethod(m_method.MethodID);
            if (m_wgDB.m_indicatorList.Count < 1)
            {
                // create indicators for this new method
                IndicatorContainer ind = new IndicatorContainer();
                ind.Description              = "Debug";
                ind.EmissionsFilterPosition  = 6;
                ind.ExcitationFilterPosition = 4;
                ind.MethodID   = m_method.MethodID;
                ind.SignalType = SIGNAL_TYPE.UP;
                success        = m_wgDB.InsertIndicator(ref ind);
            }



            ////////////////////////
            // set up experiment
            m_experiment = null;
            ObservableCollection <ExperimentContainer> expList;

            success = m_wgDB.GetAllExperimentsForPlate(m_experimentPlate.PlateID, out expList);
            if (expList.Count() > 0)
            {
                m_experiment = expList.ElementAt(0);
            }
            else
            {
                m_experiment              = new ExperimentContainer();
                m_experiment.Description  = "Debug";
                m_experiment.HorzBinning  = 1;
                m_experiment.MethodID     = m_method.MethodID;
                m_experiment.PlateID      = m_experimentPlate.PlateID;
                m_experiment.ROI_Height   = GlobalVars.PixelHeight;
                m_experiment.ROI_Width    = GlobalVars.PixelWidth;
                m_experiment.ROI_Origin_X = 1;
                m_experiment.ROI_Origin_Y = 1;
                m_experiment.TimeStamp    = DateTime.Now;
                m_experiment.VertBinning  = 1;
                success = m_wgDB.InsertExperiment(ref m_experiment);
            }


            ////////////////////////
            // set up mask
            m_mask  = null;
            success = m_wgDB.GetAllMasksForPlateType(m_experimentPlate.PlateTypeID);
            if (m_wgDB.m_maskList.Count() > 0)
            {
                m_mask = m_wgDB.m_maskList.ElementAt(0);
            }
            else
            {
                // create a new mask
                m_mask                    = new MaskContainer();
                m_mask.Angle              = 0.0;
                m_mask.Cols               = 24;
                m_mask.Description        = "Debug";
                m_mask.IsDefault          = false;
                m_mask.NumEllipseVertices = 24;
                m_mask.PlateTypeID        = m_experimentPlate.PlateTypeID;
                m_mask.ReferenceImageID   = 0;
                m_mask.Rows               = 16;
                m_mask.Shape              = 0;
                m_mask.XOffset            = 28;
                m_mask.XSize              = 28;
                m_mask.XStep              = 41.522;
                m_mask.YOffset            = 190;
                m_mask.YSize              = 28;
                m_mask.YStep              = 41.467;
                success                   = m_wgDB.InsertMask(ref m_mask);
            }



            ////////////////////////////////////
            // setup test indicator(s)
            m_indicatorList = new ObservableCollection <ExperimentIndicatorContainer>();
            ObservableCollection <ExperimentIndicatorContainer> expIndList;

            success = m_wgDB.GetAllExperimentIndicatorsForExperiment(m_experiment.ExperimentID, out expIndList);
            if (expIndList.Count > 0)
            {
                foreach (ExperimentIndicatorContainer ex in expIndList)
                {
                    m_indicatorList.Add(ex);
                }
            }
            else
            {
                success = m_wgDB.GetAllIndicatorsForMethod(m_method.MethodID);
                foreach (IndicatorContainer ind in m_wgDB.m_indicatorList)
                {
                    ExperimentIndicatorContainer exInd = new ExperimentIndicatorContainer();
                    exInd.Description = ind.Description;

                    FilterContainer filter;
                    success = m_wgDB.GetExcitationFilterAtPosition(ind.ExcitationFilterPosition, out filter);
                    exInd.ExcitationFilterDesc = filter.Description;
                    success = m_wgDB.GetEmissionFilterAtPosition(ind.EmissionsFilterPosition, out filter);
                    exInd.EmissionFilterDesc = filter.Description;

                    exInd.EmissionFilterPos   = ind.EmissionsFilterPosition;
                    exInd.ExcitationFilterPos = ind.ExcitationFilterPosition;
                    exInd.ExperimentID        = m_experiment.ExperimentID;
                    exInd.Exposure            = 150;
                    exInd.Gain       = 5;
                    exInd.MaskID     = m_mask.MaskID;
                    exInd.SignalType = SIGNAL_TYPE.UP;
                    exInd.Verified   = true;
                    success          = m_wgDB.InsertExperimentIndicator(ref exInd);
                    m_indicatorList.Add(exInd);
                }
            }


            ////////////////////////////////////
            // compound plates
            m_compoundPlateList = new ObservableCollection <ExperimentCompoundPlateContainer>();


            ////////////////////////////////////
            // control subtraction well list
            m_controlSubtractionWellList = new ObservableCollection <Tuple <int, int> >();
            // all wells in last row = control wells
            for (int c = 0; c < m_mask.Cols; c++)
            {
                m_controlSubtractionWellList.Add(Tuple.Create(m_mask.Rows - 1, c));
            }

            ////////////////////////////////////
            //m_numFoFrames = numFoFrames;
            m_numFoFrames = 5;


            if (m_indicatorList.Count() > 1)
            {
                ////////////////////////////////////
                //m_dynamicRatioNumerator = dynamicRatioNumerator;
                m_dynamicRatioNumerator = m_indicatorList.ElementAt(0);
                ////////////////////////////////////
                //m_dynamicRatioDenominator = dynamicRatioDenominator;
                m_dynamicRatioDenominator = m_indicatorList.ElementAt(1);
            }
            else
            {
                m_dynamicRatioNumerator = new ExperimentIndicatorContainer();
                m_dynamicRatioNumerator.ExperimentIndicatorID = 0;
                m_dynamicRatioDenominator = new ExperimentIndicatorContainer();
                m_dynamicRatioDenominator.ExperimentIndicatorID = 0;
            }


            if (m_iParams == null)
            {
                m_iParams = new ImagingParameters();
            }


            m_iParams.maxPixelValue               = GlobalVars.MaxPixelValue;
            m_iParams.imageWidth                  = GlobalVars.PixelWidth;
            m_iParams.imageHeight                 = GlobalVars.PixelHeight;
            m_iParams.Image_StartCol              = 1;
            m_iParams.Image_EndCol                = GlobalVars.PixelWidth;
            m_iParams.Image_StartRow              = 1;
            m_iParams.Image_EndRow                = GlobalVars.PixelHeight;
            m_iParams.BravoMethodFilename         = "";
            m_iParams.CameraTemperature           = GlobalVars.CameraTargetTemperature;
            m_iParams.HorzBinning                 = 1;
            m_iParams.VertBinning                 = 1;
            m_iParams.EmissionFilterChangeSpeed   = GlobalVars.FilterChangeSpeed;
            m_iParams.ExcitationFilterChangeSpeed = GlobalVars.FilterChangeSpeed;
            m_iParams.LightIntensity              = 100;
            m_iParams.NumImages     = 1000000; // artificial limit on number of images
            m_iParams.NumIndicators = m_indicatorList.Count;
            m_iParams.SyncExcitationFilterWithImaging = true;

            m_iParams.CycleTime             = new int[m_indicatorList.Count];
            m_iParams.EmissionFilter        = new byte[m_indicatorList.Count];
            m_iParams.ExcitationFilter      = new byte[m_indicatorList.Count];
            m_iParams.Exposure              = new float[m_indicatorList.Count];
            m_iParams.Gain                  = new int[m_indicatorList.Count];
            m_iParams.ExperimentIndicatorID = new int[m_indicatorList.Count];
            m_iParams.IndicatorName         = new string[m_indicatorList.Count];
            m_iParams.LampShutterIsOpen     = new bool[m_indicatorList.Count];


            int i = 0;

            foreach (ExperimentIndicatorContainer ind in m_indicatorList)
            {
                m_iParams.CycleTime[i]             = 1000;
                m_iParams.EmissionFilter[i]        = (byte)ind.EmissionFilterPos;
                m_iParams.ExcitationFilter[i]      = (byte)ind.ExcitationFilterPos;
                m_iParams.Exposure[i]              = (float)ind.Exposure / 1000;
                m_iParams.Gain[i]                  = ind.Gain;
                m_iParams.ExperimentIndicatorID[i] = 0; // created by the RunExperiment object when the experiment is run
                m_iParams.IndicatorName[i]         = ind.Description;
                m_iParams.LampShutterIsOpen[i]     = true;
                m_iParams.ExperimentIndicatorID[i] = ind.ExperimentIndicatorID;

                i++;
            }
        }
Пример #5
0
        public bool GetIndicatorList(int experimentID)
        {
#if (SIMULATE)
            m_vm.indicators.Clear();
            ExperimentIndicatorContainer indicator = new ExperimentIndicatorContainer();
            indicator.CycleTime             = 100;
            indicator.DarkFieldRefImageID   = 1;
            indicator.Description           = "indicator 1";
            indicator.EmissionFilterDesc    = "filter 1";
            indicator.EmissionFilterPos     = 1;
            indicator.ExcitationFilterDesc  = "filter 2";
            indicator.ExcitationFilterPos   = 2;
            indicator.ExperimentID          = 1;
            indicator.ExperimentIndicatorID = 1;
            indicator.Exposure            = 50;
            indicator.FlatFieldCorrection = FLATFIELD_SELECT.NONE;
            indicator.FlatFieldRefImageID = 1;
            indicator.Gain             = 10;
            indicator.MaskID           = 1;
            indicator.OptimizeWellList = null;
            indicator.PreAmpGain       = 1;
            indicator.SignalType       = SIGNAL_TYPE.UP;
            indicator.Verified         = true;
            m_vm.indicators.Add(indicator);

            indicator                       = new ExperimentIndicatorContainer();
            indicator.CycleTime             = 100;
            indicator.DarkFieldRefImageID   = 1;
            indicator.Description           = "indicator 2";
            indicator.EmissionFilterDesc    = "filter 1";
            indicator.EmissionFilterPos     = 1;
            indicator.ExcitationFilterDesc  = "filter 2";
            indicator.ExcitationFilterPos   = 2;
            indicator.ExperimentID          = 2;
            indicator.ExperimentIndicatorID = 2;
            indicator.Exposure              = 50;
            indicator.FlatFieldCorrection   = FLATFIELD_SELECT.NONE;
            indicator.FlatFieldRefImageID   = 1;
            indicator.Gain                  = 10;
            indicator.MaskID                = 1;
            indicator.OptimizeWellList      = null;
            indicator.PreAmpGain            = 1;
            indicator.SignalType            = SIGNAL_TYPE.UP;
            indicator.Verified              = true;
            m_vm.indicators.Add(indicator);

            return(true);
#else
            bool success = true;
            ObservableCollection <ExperimentIndicatorContainer> indicators;
            if (m_db.GetAllExperimentIndicatorsForExperiment(experimentID, out indicators))
            {
                m_vm.indicators = indicators;
            }
            else
            {
                success = false;
            }

            return(success);
#endif
        }