private ArtifactType FillDecelerationData(PeriGen.Patterns.Engine.Data.Deceleration item) { var toRet = new Deceleration() { Category = Resource.IDS_DECELERATION }; FillAcelerationFields(toRet, item); toRet.ContractionStart = item.ContractionStart; toRet.DecelerationCategory = DecelCategoryToString(item.DecelerationCategory); toRet.HasSixtiesNonReassuringFeature = item.HasSixtiesNonReassuringFeature; toRet.IsEarlyDeceleration = item.IsEarlyDeceleration; toRet.IsLateDeceleration = item.IsLateDeceleration; toRet.IsNonAssociatedDeceleration = item.IsNonAssociatedDeceleration; toRet.IsVariableDeceleration = item.IsVariableDeceleration; toRet.NonReassuringFeatures = NonReassuringToString(item.NonReassuringFeatures); return(toRet); }
private static int GetDecelType(DetectionArtifact item) { Deceleration artifact = item as Deceleration; int eventType = 0; if (artifact.IsNonAssociatedDeceleration) { eventType = 7; // event::tnadeceleration *** } else if (artifact.IsEarlyDeceleration) { eventType = 3; // event::tearly *** } else if (artifact.IsLateDeceleration) { eventType = 6; // event::tlate *** } else if (artifact.IsVariableDeceleration) { if (artifact.HasProlongedNonReassuringFeature) { eventType = 14; // event::tprolonged *** } else if (artifact.HasNonReassuringFeature) { eventType = 5; // event::tatypical *** } else { eventType = 4; // event::ttypical *** } } else { throw new InvalidOperationException("Unable to match the deceleration type to an engine type"); } return(eventType); }
private static int GetDecelNonReassuring(DetectionArtifact item) { Deceleration artifact = item as Deceleration; int atypicalValue = 0; if (artifact.HasBiphasicNonReassuringFeature) { atypicalValue |= 1; } if (artifact.HasLossRiseNonReassuringFeature) { atypicalValue |= 2; } if (artifact.HasLossVariabilityNonReassuringFeature) { atypicalValue |= 4; } if (artifact.HasLowerBaselineNonReassuringFeature) { atypicalValue |= 8; } if (artifact.HasProlongedSecondRiseNonReassuringFeature) { atypicalValue |= 16; } if (artifact.HasSixtiesNonReassuringFeature) { atypicalValue |= 32; } if (artifact.HasSlowReturnNonReassuringFeature) { atypicalValue |= 64; } return(atypicalValue); }
public static String WriteDecelerationDAT(DetectionArtifact item, DateTime AbsoluteStart) { Deceleration decItem = item as Deceleration; StringBuilder value = new StringBuilder(255); value.Append("EVT|"); /* 00 */ value.Append(GetDecelType(item).ToString(CultureInfo.InvariantCulture)); value.Append("|"); /* 01 */ value.Append(((int)((item.StartTime - AbsoluteStart).TotalSeconds * 4)).ToString(CultureInfo.InvariantCulture)); value.Append("|"); /* 02 */ value.Append(((int)((decItem.PeakTime - AbsoluteStart).TotalSeconds * 4)).ToString(CultureInfo.InvariantCulture)); value.Append("|"); /* 03 */ value.Append(((int)((item.EndTime - AbsoluteStart).TotalSeconds * 4)).ToString(CultureInfo.InvariantCulture)); value.Append("|"); /* 04 */ value.Append(String.Empty); // Y1 value.Append("|"); /* 05 */ value.Append(String.Empty); // Y2 value.Append("|"); /* 06 */ value.Append(decItem.ContractionStart.HasValue ? ((int)((decItem.ContractionStart.Value - AbsoluteStart).TotalSeconds * 4)).ToString(CultureInfo.InvariantCulture) : String.Empty); value.Append("|"); /* 07 */ value.Append("y"); // Final value.Append("|"); /* 08 */ value.Append(String.Empty); // Strikeout value.Append("|"); /* 09 */ value.Append(decItem.Confidence.ToString("0.000000", CultureInfo.InvariantCulture)); value.Append("|"); /* 10 */ value.Append(decItem.Repair.ToString("0.000000", CultureInfo.InvariantCulture)); value.Append("|"); /* 11 */ value.Append(decItem.Height.ToString("0.000000", CultureInfo.InvariantCulture)); value.Append("|"); /* 12 */ value.Append(String.Empty); // Baseline variability value.Append("|"); /* 13 */ value.Append(decItem.PeakValue.ToString("0.000000", CultureInfo.InvariantCulture)); value.Append("|"); /* 14 */ value.Append("|"); /* 15 */ if (decItem.DecelerationCategory.Equals("Variable")) { value.Append("y"); } value.Append("|"); /* 16 */ value.Append("-1"); // Lag value.Append("|"); /* 17 */ value.Append(GetDecelNonReassuring(item).ToString(CultureInfo.InvariantCulture)); value.Append("|"); /* 18 */ if (decItem.IsNonInterpretable) { value.Append("y"); } value.Append("|"); /* 19 */ value.Append(String.Empty); // Confirmed value.Append("|"); /* 20 */ value.Append(item.Id.ToString(CultureInfo.InvariantCulture)); return(value.ToString()); }
static Deceleration DecelerationFromEngine(DateTime baseTime, string[] data) { Debug.Assert(data.GetLength(0) == 12); Debug.Assert(string.CompareOrdinal(data[0], "EVT") == 0); int type = Convert.ToInt32(data[1], CultureInfo.InvariantCulture); Deceleration decel = new Deceleration { StartTime = baseTime.AddSeconds(Convert.ToUInt32(data[2], CultureInfo.InvariantCulture) / 4f), EndTime = baseTime.AddSeconds(Convert.ToUInt32(data[3], CultureInfo.InvariantCulture) / 4f), PeakTime = baseTime.AddSeconds(Convert.ToUInt32(data[4], CultureInfo.InvariantCulture) / 4f), PeakValue = data[5].ToSafeDouble(), Confidence = data[6].ToSafeDouble(), Repair = data[7].ToSafeDouble(), Height = data[8].ToSafeDouble(), IsNonInterpretable = (string.CompareOrdinal(data[9], "y") == 0) }; switch (type) { // event::tearly *** case 3: decel.IsEarlyDeceleration = true; break; // event::ttypical *** case 4: decel.IsVariableDeceleration = true; break; // event::tatypical *** case 5: decel.IsVariableDeceleration = true; break; // event::tlate *** case 6: decel.IsLateDeceleration = true; break; // event::tnadeceleration *** case 7: decel.IsNonAssociatedDeceleration = true; break; // event::tprolonged*** case 14: decel.IsVariableDeceleration = true; decel.HasProlongedNonReassuringFeature = true; break; // others... default: throw new ArgumentOutOfRangeException("data", "Unrecognized EVT detection artifact subtype"); } if (data[10].Length > 0) { int offset = Convert.ToInt32(data[10], CultureInfo.InvariantCulture); if (offset >= 0) { decel.ContractionStart = baseTime.AddSeconds(offset / 4d); } } int atypical = Convert.ToInt32(data[11], CultureInfo.InvariantCulture); if ((atypical & 1) == 1) { decel.HasBiphasicNonReassuringFeature = true; } if ((atypical & 2) == 2) { decel.HasLossRiseNonReassuringFeature = true; } if ((atypical & 4) == 4) { decel.HasLossVariabilityNonReassuringFeature = true; } if ((atypical & 8) == 8) { decel.HasLowerBaselineNonReassuringFeature = true; } if ((atypical & 16) == 16) { decel.HasProlongedSecondRiseNonReassuringFeature = true; } if ((atypical & 32) == 32) { decel.HasSixtiesNonReassuringFeature = true; } if ((atypical & 64) == 64) { decel.HasSlowReturnNonReassuringFeature = true; } return(decel); }