コード例 #1
0
        private void createASCConverter(ASCConverter conv)
        {
            conv.syncToFirst = (bool)SyncToFirst.IsChecked;
            conv.specs = new EpisodeDescription[this.EpisodeEntries.Items.Count];
            for (int i = 0; i < this.EpisodeEntries.Items.Count; i++)
            {
                conv.specs[i] = getEpisode((EpisodeDescriptionEntry)this.EpisodeEntries.Items[i]);
            }

            conv.channels = this.channels;
            conv.directory = this.directory;
            conv.headerFileName = this.headerFileName;
            conv.GVCopyAcross = listView2.SelectedItems.Cast<GVEntry>().ToList<GVEntry>();
            conv.head = this.head;
            conv.decimation = _decimation;
            conv.removeOffsets = (bool)removeOffsets.IsChecked;
            conv.removeTrends = (bool)removeTrends.IsChecked;
            conv.radinOffset = Radin.IsEnabled && (bool)Radin.IsChecked;
            if (conv.radinOffset)
            {
                conv.radinLow = System.Convert.ToInt32(RadinLowPts.Text);
                conv.radinHigh = System.Convert.ToInt32(RadinHighPts.Text);
            }

            if ((bool)radioButton2.IsChecked) //list of reference channels
            {
                conv.referenceGroups = new List<List<int>>(1);
                conv.referenceGroups.Add(conv.channels); // All channels are referenced to
                conv.referenceChannels = new List<List<int>>(1); // this list of channels
                conv.referenceChannels.Add(_refChan);
            }
            else if ((bool)radioButton4.IsChecked) //Reference expression
            {
                conv.referenceGroups = new List<List<int>>();
                conv.referenceChannels = new List<List<int>>();
                for (int i = 0; i < _refChanExp.Count; i += 2)
                {
                    conv.referenceGroups.Add(_refChanExp[i]);
                    conv.referenceChannels.Add(_refChanExp[i + 1]);
                }
                correctReferenceLists(conv);
            }
            else // no overall reference
            {
                conv.referenceGroups = null;
                conv.referenceChannels = null;
            }
            conv.bdf = this.bdf;
            conv.ED = this.ED;
            conv.FMRecLength = this._recLength;
            conv.samplingRate = this.samplingRate;
            if (conv.ignoreStatus = (bool)NoSyncToStatus.IsChecked)
                conv.offsetToFirstEvent = offsetToFirstEvent;
        }
コード例 #2
0
ファイル: LogFile.cs プロジェクト: DOPS-CCI/CCI_project
        public void registerHeader(ASCConverter c)
        {
            string conversionType;
            double recordLength;
            conversionType = "ASC";
            recordLength = ((ASCConverter)c).FMRecLength;
            logStream.WriteStartElement("Conversion");
            logStream.WriteAttributeString("Type", conversionType);
            logStream.WriteElementString("Computer", Environment.MachineName);
            logStream.WriteElementString("User", Environment.UserName);
            logStream.WriteElementString("Source", c.directory);

            logStream.WriteStartElement("Episodes");
            bool addPKGVs=false;
            foreach (EpisodeDescription ED in c.specs)
            {
                logStream.WriteStartElement("EpisodeDefinition");
                logStream.WriteAttributeString("NewGV", ED.GVValue.ToString("0"));
                logStream.WriteStartElement("Start");
                logStream.WriteElementString("Event", ED.Start.EventName());
                if(ED.Start._GV!=null){
                    logStream.WriteStartElement("GVCriterium");
                    logStream.WriteAttributeString("Name", ED.Start._GV.Name);
                    logStream.WriteAttributeString("Comp", ED.Start.CompToString());
                    logStream.WriteAttributeString("Value", ED.Start._GV.ConvertGVValueIntegerToString(ED.Start._GVVal));
                    logStream.WriteEndElement(/* GVCriterium */);
                }
                logStream.WriteElementString("Offset", ED.Start._offset.ToString("0"));
                logStream.WriteEndElement(/* Start */);
                logStream.WriteStartElement("End");
                logStream.WriteElementString("Event", ED.End.EventName());
                if (ED.End._GV != null)
                {
                    logStream.WriteStartElement("GVCriterium");
                    logStream.WriteAttributeString("Name", ED.End._GV.Name);
                    logStream.WriteAttributeString("Comp", ED.End.CompToString());
                    logStream.WriteAttributeString("Value", ED.End._GV.ConvertGVValueIntegerToString(ED.End._GVVal));
                    logStream.WriteEndElement(/* GVCriterium */);
                }
                logStream.WriteElementString("Offset", ED.End._offset.ToString("0"));
                logStream.WriteEndElement(/* End */);

                if(ED.PKCounter!=null)
                {
                    addPKGVs = true;
                    PKDetectorEventCounterDescription pkd = ED.PKCounter;
                    logStream.WriteStartElement("PKDetectorCounter");
                    logStream.WriteStartElement("Events");
                    foreach (string s in pkd.EventNames)
                    {
                        logStream.WriteElementString("Name", s);
                    }
                    logStream.WriteEndElement(/* Events */);
                    if (pkd.found != null)
                        logStream.WriteElementString("FoundFit", (bool)pkd.found ? "True" : "False");
                    if (pkd.includeChi2)
                    {
                        logStream.WriteStartElement("ChiSquare");
                        logStream.WriteAttributeString("Comp", pkd.comp1.ToString());
                        logStream.WriteAttributeString("Value", pkd.chi2.ToString("0.0"));
                        logStream.WriteEndElement(/* ChiSquare */);
                    }
                    if (pkd.includeMagnitude)
                    {
                        logStream.WriteStartElement("Magnitude");
                        logStream.WriteAttributeString("Comp", pkd.comp2.ToString());
                        logStream.WriteAttributeString("Value", pkd.magnitude.ToString("0.0"));
                        logStream.WriteEndElement(/* Magnitude */);
                    }
                    if (pkd.positive != null)
                        logStream.WriteElementString("Sign", (bool)pkd.positive ? "Positive" : "Negative");
                    logStream.WriteEndElement(/* PKDetectorCounter */);
                }
                logStream.WriteEndElement(/* EpisodeDefinition */);
            }
            logStream.WriteEndElement(/* Episodes */);

            logStream.WriteStartElement("GroupVars");
            foreach (GVEntry gv in c.GVCopyAcross)
            {
                logStream.WriteStartElement("GroupVar");
                logStream.WriteAttributeString("Type", "CopyOver");
                logStream.WriteString(gv.Name);
                logStream.WriteEndElement(/* GroupVar */);
            }
            if (addPKGVs)
            {
                logStream.WriteStartElement("GroupVar");
                logStream.WriteAttributeString("Type", "PKCount");
                logStream.WriteString("PK-rate");
                logStream.WriteEndElement(/* GroupVar */);
                logStream.WriteStartElement("GroupVar");
                logStream.WriteAttributeString("Type", "PKCount");
                logStream.WriteString("PK-velocity");
                logStream.WriteEndElement(/* GroupVar */);
                logStream.WriteStartElement("GroupVar");
                logStream.WriteAttributeString("Type", "PKCount");
                logStream.WriteString("PK-accel");
                logStream.WriteEndElement(/* GroupVar */);
            }
            logStream.WriteEndElement(/* GroupVars */);
            logStream.WriteElementString("Channels", CCIUtilities.Utilities.intListToString(c.channels, true));

            logStream.WriteStartElement("Records");
            logStream.WriteElementString("Length", recordLength.ToString("0.00") + "secs");
            logStream.WriteElementString("Decimation", c.decimation.ToString("0"));

            logStream.WriteStartElement("Processing");
            string p;
            if (c.radinOffset)
                p = "Radin: " + c.radinLow.ToString("0") + " to " + c.radinHigh.ToString("0") + "pts";
            else
            {
                p = "None";
                if (c.removeTrends) p = "Offset and linear trend removal";
                else if (c.removeOffsets) p = "Offset removal";
            }
            logStream.WriteString(p);
            logStream.WriteEndElement(/* Processing */);
            logStream.WriteEndElement(/* Record */);

            logStream.WriteStartElement("Reference");
            if (c.referenceGroups == null || c.referenceGroups.Count == 0)
                logStream.WriteAttributeString("Type", "None");
            else
            {
                logStream.WriteAttributeString("Type", "Channel");
                for (int i = 0; i < c.referenceGroups.Count; i++)
                {
                    logStream.WriteStartElement("ReferenceGroup");
                    logStream.WriteElementString("Channels", CCIUtilities.Utilities.intListToString(c.referenceGroups[i], true));
                    logStream.WriteElementString("ReferenceChans", CCIUtilities.Utilities.intListToString(c.referenceChannels[i], true));
                    logStream.WriteEndElement(/*ReferenceGroup*/);
                }
            }
            logStream.WriteEndElement(/* Reference */);

            logStream.WriteEndElement(/* Conversion */);
        }
コード例 #3
0
 private void correctReferenceLists(ASCConverter conv)
 {
     List<List<int>> list = conv.referenceGroups;
     for (int c = 1; c < list.Count; c++) //don't need to check first list
     {
         List<int> chanList1 = list[c];
         for (int chan = 0; chan < chanList1.Count; chan++)
         {
             int chan1 = chanList1[chan]; //channel number to look for
             for (int d = 0; d < c; d++) //look into previous lists only
             {
                 List<int> chanList2 = list[d];
                 for (int comp = chanList2.Count - 1; comp >= 0; comp--) //always work backwards to avoid changing indices
                     if (chan1 == chanList2[comp]) //remove element from chanList2
                         chanList2.Remove(chanList2[comp]); //assumes that no dupes within lists (enforced by parser)
             }
         }
     }
     for (int i = list.Count - 1; i >= 0; i--)
     {
         if (list[i].Count == 0)
         {
             list.Remove(list[i]);
             conv.referenceChannels.Remove(conv.referenceChannels[i]);
         }
     }
 }