123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524 |
- using AI.Common;
- using System;
- using System.Collections.Generic;
- using System.Runtime.Serialization;
- using System.Text;
- namespace AutoEFInferenceCalcLib
- {
- /// <summary>
- /// 单个心动周期相关信息
- /// </summary>
- [DataContract]
- public struct CardiacCycleInfos
- {
- #region field
- private double _startTimeStamp;
- private double _endTimeStamp;
- private double _esTimeStamp;
- private double _edTimeStamp;
- private float _esVolume;
- private float _edVolume;
- #endregion
- #region public
- /// <summary>
- /// 心动周期开始的时间戳
- /// </summary>
- public double StartTimeStamp
- {
- get => _startTimeStamp;
- set => _startTimeStamp = value;
- }
- /// <summary>
- /// 心动周期结束的时间戳
- /// </summary>
- public double EndTimeStamp
- {
- get => _endTimeStamp;
- set => _endTimeStamp = value;
- }
- /// <summary>
- /// ES帧的时间戳
- /// </summary>
- public double ESTimeStamp
- {
- get => _esTimeStamp;
- set => _esTimeStamp = value;
- }
- /// <summary>
- /// ED帧的时间戳
- /// </summary>
- public double EDTimeStamp
- {
- get => _edTimeStamp;
- set => _edTimeStamp = value;
- }
- /// <summary>
- /// 当前心动周期内,收缩末期的左心室容积
- /// </summary>
- public float ESVolume
- {
- get => _esVolume;
- set => _esVolume = value;
- }
- /// <summary>
- /// 当前心动周期内,舒张末期的左心室容积
- /// </summary>
- public float EDVolume
- {
- get => _edVolume;
- set => _edVolume = value;
- }
- /// <summary>
- /// 空
- /// </summary>
- public static readonly CardiacCycleInfos Empty = new CardiacCycleInfos();
- /// <summary>
- /// 判断是否相等
- /// </summary>
- /// <param name="other"></param>
- /// <returns></returns>
- public bool Equals(CardiacCycleInfos other)
- {
- return Equals(this, other);
- }
- /// <summary>
- /// 判断是否相等
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- public override bool Equals(object obj)
- {
- if (obj == null || !(obj is CardiacCycleInfos))
- {
- return false;
- }
- CardiacCycleInfos info = (CardiacCycleInfos)obj;
- return Equals(this, info);
- }
- /// <summary>
- /// 判断是否相等
- /// </summary>
- /// <param name="one"></param>
- /// <param name="other"></param>
- /// <returns></returns>
- public static bool Equals(CardiacCycleInfos one, CardiacCycleInfos other)
- {
- return one.StartTimeStamp == other.StartTimeStamp && one.EndTimeStamp == other.EndTimeStamp &&
- one.ESTimeStamp == other.ESTimeStamp && one.EDTimeStamp == other.EDTimeStamp &&
- one.ESVolume == other.ESVolume && one.EDVolume == other.EDVolume;
- }
- /// <summary>
- /// 判断是否相等
- /// </summary>
- /// <param name="one"></param>
- /// <param name="other"></param>
- /// <returns></returns>
- public static bool operator ==(CardiacCycleInfos one, CardiacCycleInfos other)
- {
- return Equals(one, other);
- }
- /// <summary>
- /// 判断是否相等
- /// </summary>
- /// <param name="one"></param>
- /// <param name="other"></param>
- /// <returns></returns>
- public static bool operator !=(CardiacCycleInfos one, CardiacCycleInfos other)
- {
- return !Equals(one, other);
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="startTimeStamp"></param>
- /// <param name="endTimeStamp"></param>
- /// <param name="esTimeStamp"></param>
- /// <param name="edTimeStamp"></param>
- /// <param name="esVolume"></param>
- /// <param name="edVolume"></param>
- public CardiacCycleInfos(double startTimeStamp, double endTimeStamp, double esTimeStamp, double edTimeStamp,
- float esVolume, float edVolume)
- {
- _startTimeStamp = startTimeStamp;
- _endTimeStamp = endTimeStamp;
- _esTimeStamp = esTimeStamp;
- _edTimeStamp = edTimeStamp;
- _esVolume = esVolume;
- _edVolume = edVolume;
- }
- #endregion
- }
- /// <summary>
- /// 左心室容积测量的关键点
- /// </summary>
- public struct LVVolumeMeasureMarks
- {
- #region field
- private Point2D _apexPoint;
- private Point2D[] _endPoints;
- private Point2D[] _slicePoints;
- private Point2D[] _controlPoints;
- #endregion
- #region public
- /// <summary>
- /// 左心室内轮廓心尖点,只有一个
- /// </summary>
- public Point2D ApexPoint
- {
- get => _apexPoint;
- set => _apexPoint = value;
- }
- /// <summary>
- /// 左心室内轮廓末端点,有两个
- /// </summary>
- public Point2D[] EndPoints
- {
- get => _endPoints;
- set => _endPoints = value;
- }
- /// <summary>
- /// 左心室内轮廓切片点
- /// </summary>
- public Point2D[] SlicePoint
- {
- get => _slicePoints;
- set => _slicePoints = value;
- }
- /// <summary>
- /// 左心室内轮廓控制点
- /// </summary>
- public Point2D[] ControlPoints
- {
- get => _controlPoints;
- set => _controlPoints = value;
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="apexPoint"></param>
- /// <param name="endPoints"></param>
- /// <param name="slicePoints"></param>
- /// <param name="controlPoints"></param>
- public LVVolumeMeasureMarks(Point2D apexPoint, Point2D[] endPoints,
- Point2D[] slicePoints, Point2D[] controlPoints)
- {
- _apexPoint = apexPoint;
- _endPoints = endPoints;
- _slicePoints = slicePoints;
- _controlPoints = controlPoints;
- }
- public static readonly LVVolumeMeasureMarks Empty = new LVVolumeMeasureMarks();
- /// <summary>
- /// 判断是否相等
- /// </summary>
- /// <param name="other"></param>
- /// <returns></returns>
- public bool Equals(LVVolumeMeasureMarks other)
- {
- return Equals(this, other);
- }
- public override bool Equals(object obj)
- {
- if (obj == null || !(obj is LVVolumeMeasureMarks))
- {
- return false;
- }
- LVVolumeMeasureMarks measureMarks = (LVVolumeMeasureMarks)obj;
- return Equals(this, measureMarks);
- }
- public static bool Equals(LVVolumeMeasureMarks one, LVVolumeMeasureMarks other)
- {
- if (one.ApexPoint != other.ApexPoint)
- {
- return false;
- }
- if (one.EndPoints != null && other.EndPoints == null || one.EndPoints == null && other.EndPoints != null ||
- one.SlicePoint != null && other.SlicePoint == null || one.SlicePoint == null && other.SlicePoint != null
- || one.ControlPoints != null && one.ControlPoints == null || one.ControlPoints == null && other.ControlPoints != null)
- {
- return false;
- }
- if (one.EndPoints.Length != other.EndPoints.Length || one.SlicePoint.Length != other.EndPoints.Length ||
- one.ControlPoints.Length != other.ControlPoints.Length)
- {
- return false;
- }
- for (int i = 0; i < one.EndPoints.Length; i++)
- {
- if (one.EndPoints[i] != other.EndPoints[i])
- {
- return false;
- }
- }
- for (int i = 0; i < one.SlicePoint.Length; i++)
- {
- if (one.SlicePoint[i] != other.SlicePoint[i])
- {
- return false;
- }
- }
- for (int i = 0; i < other.ControlPoints.Length; i++)
- {
- if (one.ControlPoints[i] != other.ControlPoints[i])
- {
- return false;
- }
- }
- return true;
- }
- public static bool operator ==(LVVolumeMeasureMarks one, LVVolumeMeasureMarks other)
- {
- return Equals(one, other);
- }
- public static bool operator !=(LVVolumeMeasureMarks one, LVVolumeMeasureMarks other)
- {
- return !Equals(one, other);
- }
- #endregion
- }
- /// <summary>
- /// 单帧图像上的推理结果
- /// </summary>
- public struct LVVolumeCalcResult
- {
- #region field
- private Point2D[] _contour;
- private double _volume;
- private float _score;
- private LVVolumeMeasureMarks _measureMarks;
- #endregion
- #region public
- /// <summary>
- /// 左心室内轮廓原始点
- /// </summary>
- public Point2D[] Contour
- {
- get => _contour;
- set => _contour = value;
- }
- /// <summary>
- /// 左心室的容积值
- /// </summary>
- public double Volume
- {
- get => _volume;
- set => _volume = value;
- }
- /// <summary>
- /// 心肌分割的得分
- /// </summary>
- public float Score
- {
- get => _score;
- set => _score = value;
- }
- /// <summary>
- /// 左心室容积测量的关键点
- /// </summary>
- public LVVolumeMeasureMarks MeasureMarks
- {
- get => _measureMarks;
- set => _measureMarks = value;
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="contour"></param>
- /// <param name="Volume"></param>
- /// <param name="score"></param>
- /// <param name="measureMarks"></param>
- public LVVolumeCalcResult(Point2D[] contour, double Volume, float score,
- LVVolumeMeasureMarks measureMarks)
- {
- _contour = contour;
- _volume = Volume;
- _score = score;
- _measureMarks = measureMarks;
- }
- /// <summary>
- /// 空
- /// </summary>
- public static readonly LVVolumeCalcResult Empty = new LVVolumeCalcResult(new Point2D[0], 0, 0,
- new LVVolumeMeasureMarks(new Point2D(0, 0), new Point2D[0], new Point2D[0], new Point2D[0]));
- public bool Equals(LVVolumeCalcResult other)
- {
- return Equals(this, other);
- }
- public override bool Equals(object obj)
- {
- if (obj == null || !(obj is LVVolumeCalcResult))
- {
- return false;
- }
- LVVolumeCalcResult calcResult = (LVVolumeCalcResult)obj;
- return Equals(this, calcResult);
- }
- public static bool Equals(LVVolumeCalcResult one, LVVolumeCalcResult other)
- {
- if (one.Volume != other.Volume)
- {
- return false;
- }
- if (one.Score != other.Score)
- {
- return false;
- }
- if (one.Contour == null && other.Contour != null || one.Contour != null && other.Contour == null)
- {
- return false;
- }
- if (one.Contour.Length != other.Contour.Length)
- {
- return false;
- }
- if (one.MeasureMarks != other.MeasureMarks)
- {
- return false;
- }
- for (int i = 0; i < one.Contour.Length; i++)
- {
- if (one.Contour[i] != other.Contour[i])
- {
- return false;
- }
- }
- return true;
- }
- public static bool operator ==(LVVolumeCalcResult one, LVVolumeCalcResult other)
- {
- return Equals(one, other);
- }
- public static bool operator !=(LVVolumeCalcResult one, LVVolumeCalcResult other)
- {
- return !Equals(one, other);
- }
- #endregion
- }
- [DataContract]
- [KnownType(typeof(CardiacCurveInfos))]
- public class CardiacCurveInfos
- {
- #region field
- private Dictionary<double, LVVolumeCalcResult> _resultsPerImage;
- private int _bestCycleIndex;
- private CardiacCycleInfos[] _cardiacCycles;
- #endregion
- #region properties
- /// <summary>
- /// 每张图对应的左心室容积的计算结果
- /// </summary>
- [DataMember]
- public Dictionary<double, LVVolumeCalcResult> ResultPerImage
- {
- get => _resultsPerImage;
- set => _resultsPerImage = value;
- }
- /// <summary>
- /// 最好周期的Index
- /// </summary>
- [DataMember]
- public int BestCycleIndex
- {
- get => _bestCycleIndex;
- set => _bestCycleIndex = value;
- }
- /// <summary>
- /// 心动周期的信息
- /// </summary>
- [DataMember]
- public CardiacCycleInfos[] CardiacCycles
- {
- get => _cardiacCycles;
- set => _cardiacCycles = value;
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- public CardiacCurveInfos()
- {
- _resultsPerImage = new Dictionary<double, LVVolumeCalcResult>();
- _bestCycleIndex = 0;
- _cardiacCycles = Array.Empty<CardiacCycleInfos>();
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="resultsPerImage"></param>
- /// <param name="bestCycleIndex"></param>
- /// <param name="cardiacCycles"></param>
- public CardiacCurveInfos(Dictionary<double, LVVolumeCalcResult> resultsPerImage, int bestCycleIndex,
- CardiacCycleInfos[] cardiacCycles)
- {
- _resultsPerImage = resultsPerImage;
- _bestCycleIndex = bestCycleIndex;
- _cardiacCycles = cardiacCycles;
- }
- /// <summary>
- /// 空
- /// </summary>
- public static readonly CardiacCurveInfos Empty = new CardiacCurveInfos();
- #endregion
- }
- }
|