⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aecgformat.cs

📁 ecg tool kit for medical image retrieval system
💻 CS
📖 第 1 页 / 共 4 页
字号:
							&&	(ann.SupportingROI.Boundary[1] == null))
							{
								aECGValuePair vp1 = null, vp2 = null;

								if (string.Compare(ann.SupportingROI.Boundary[0].Code.Code, "TIME_RELATIVE") == 0)
								{
									switch (IndexOf(releventValues, (string)val))
									{
										case 0:
											vp1 = ann.SupportingROI.Boundary[0].Value["low"];
											vp2 = ann.SupportingROI.Boundary[0].Value["high"];

											if (((vp1 != null)
											||	 (vp2 != null))
											&&	((vp1 == null)
											||	 (string.Compare(vp1.Unit, "ms") == 0))
											&&	((vp2 == null)
											||	 (string.Compare(vp2.Unit, "ms") == 0)))
											{
												if ((gm == null)
												||	(gm.Ponset != GlobalMeasurement.NoValue)
												||	(gm.Ponset != GlobalMeasurement.NoValue))
												{
													gm = new GlobalMeasurement();

													alMeasurments.Add(gm);
												}

												if (vp1 != null)
													gm.Ponset = (ushort) ((double)vp1.Value);

												if (vp2 != null)
													gm.Poffset = (ushort) ((double)vp2.Value);
											}

											break;
										case 1:
											vp1 = ann.SupportingROI.Boundary[0].Value["low"];
											vp2 = ann.SupportingROI.Boundary[0].Value["high"];

											if (((vp1 != null)
											||	 (vp2 != null))
											&&	((vp1 == null)
											||	 (string.Compare(vp1.Unit, "ms") == 0))
											&&	((vp2 == null)
											||	 (string.Compare(vp2.Unit, "ms") == 0)))
											{
												if ((gm == null)
												||	(gm.QRSonset != GlobalMeasurement.NoValue)
												||	(gm.QRSoffset != GlobalMeasurement.NoValue))
												{
													gm = new GlobalMeasurement();

													alMeasurments.Add(gm);
												}

												if (vp1 != null)
													gm.QRSonset = (ushort) ((double)vp1.Value);

												if (vp2 != null)
													gm.QRSoffset = (ushort) ((double)vp2.Value);
											}
											break;
										case 2:
											vp1 = ann.SupportingROI.Boundary[0].Value["high"];

											if ((vp1 != null)
											&&	(string.Compare(vp1.Unit, "ms") == 0))
											{
												if ((gm == null)
													||	(gm.Toffset != GlobalMeasurement.NoValue))
												{
													gm = new GlobalMeasurement();

													alMeasurments.Add(gm);
												}

												gm.Toffset = (ushort) ((double) vp1.Value);
											}
											break;
									}
								}
								else if (string.Compare(ann.SupportingROI.Boundary[0].Code.Code, "TIME_ABSOLUTE") == 0)
								{

								}
							}
							else if (val is double)
							{
								switch (index)
								{
									case 1:
										if ((gm == null)
										||	(gm.Paxis != GlobalMeasurement.NoValue))
										{
											gm = new GlobalMeasurement();

											alMeasurments.Add(gm);
										}

										gm.Paxis = (short) ((double)val);
										break;
									case 2:
										if ((gm == null)
										||	(gm.QRSaxis != GlobalMeasurement.NoValue))
										{
											gm = new GlobalMeasurement();

											alMeasurments.Add(gm);
										}

										gm.QRSaxis = (short) ((double)val);
										break;
									case 3:
										if ((gm == null)
										||	(gm.Taxis != GlobalMeasurement.NoValue))
										{
											gm = new GlobalMeasurement();

											alMeasurments.Add(gm);
										}

										gm.Taxis = (short) ((double)val);
										break;
									case 4:
										mes.AvgPP = (ushort) ((double)val);
										break;
									case 5:
										mes.AvgRR = (ushort) ((double)val);
										break;
									case 6:
										mes.VentRate = (ushort) ((double)val);
										break;
									case 7:
										mes.QTc = (ushort) ((double)val);
										break;
								}
							}
						}
					}

					if (alMeasurments.Count != 0)
					{
						mes.measurment = new GlobalMeasurement[alMeasurments .Count];

						for (int i=0;i < alMeasurments.Count;i++)
						{
							mes.measurment[i] = (GlobalMeasurement) alMeasurments[i];
						}
					}

					return 0;
				}

				return 2;
			}

			return 1;
		}

		public int setGlobalMeasurements(GlobalMeasurements mes)
		{
			if ((mes != null)
			&&	(mes.measurment != null)
			&&	(Component.Count > 0))
			{
				aECGSeries
					series = Component[0],
					seriesMedian = (series.DerivedSet.Count == 1) ? series.DerivedSet[0] : null;

				aECGAnnotationSet
					aset = series.Annotation[0],
					asetMedian = seriesMedian.Annotation[0];

				int n =	1;

				while ((aset != null)
					&& ((DateTime)aset.ActivityTime.Value != this.TimeAcquisition))
					aset = series.Annotation[n++];

				n = 1;

				while ((aset != null)
					&& ((DateTime)aset.ActivityTime.Value != this.TimeAcquisition))
					aset = seriesMedian.Annotation[n++];

				if ((aset == null)
				||	((DateTime)aset.ActivityTime.Value != this.TimeAcquisition))
				{
					aset = new aECGAnnotationSet();

					aset.ActivityTime.Value = this.TimeAcquisition;

					aset.Author.AssignedAuthorType.AssignedDevice = new aECGDevice("assignedDevice");

					aset.Author.AssignedAuthorType.AssignedDevice.Set(series.SeriesAuthor.Device);
					aset.Author.AssignedAuthorType.AssignedDevice.PlayedManufacturedDevice.ManufacturerOrganization.Set(series.SeriesAuthor.Organization);
				}

				if ((asetMedian == null)
				||	((DateTime)asetMedian.ActivityTime.Value != this.TimeAcquisition))
				{
					asetMedian = new aECGAnnotationSet();

					asetMedian.ActivityTime.Value = this.TimeAcquisition;

					asetMedian.Author.AssignedAuthorType.AssignedDevice = new aECGDevice("assignedDevice");

					asetMedian.Author.AssignedAuthorType.AssignedDevice.Set(series.SeriesAuthor.Device);
					asetMedian.Author.AssignedAuthorType.AssignedDevice.PlayedManufacturedDevice.ManufacturerOrganization.Set(series.SeriesAuthor.Organization);
				}

				if (mes.VentRate != GlobalMeasurement.NoValue)
				{
					aECGAnnotation ann = new aECGAnnotation();

					ann.Code.Code = "MDC_ECG_HEART_RATE";
					ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

					ann.Value.Unit = "bpm";
					ann.Value.Value = (double) mes.VentRate;

					aset.Add(ann);
				}

				if (mes.AvgPP != GlobalMeasurement.NoValue)
				{
					aECGAnnotation ann = new aECGAnnotation();

					ann.Code.Code = "MDC_ECG_TIME_PD_PP";
					ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

					ann.Value.Unit = "ms";
					ann.Value.Value = (double) mes.AvgPP;

					aset.Add(ann);
				}

				if (mes.Pdur != GlobalMeasurement.NoValue)
				{
					aECGAnnotation ann = new aECGAnnotation();

					ann.Code.Code = "MDC_ECG_TIME_PD_P";
					ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

					ann.Value.Unit = "ms";
					ann.Value.Value = (double) mes.Pdur;

					aset.Add(ann);
				}

				if (mes.AvgRR != GlobalMeasurement.NoValue)
				{
					aECGAnnotation ann = new aECGAnnotation();

					ann.Code.Code = "MDC_ECG_TIME_PD_RR";
					ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

					ann.Value.Unit = "ms";
					ann.Value.Value = (double) mes.AvgRR;

					aset.Add(ann);
				}

				if (mes.PRint != GlobalMeasurement.NoValue)
				{
					aECGAnnotation ann = new aECGAnnotation();

					ann.Code.Code = "MDC_ECG_TIME_PD_PR";
					ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

					ann.Value.Unit = "ms";
					ann.Value.Value = (double) mes.PRint;

					aset.Add(ann);
				}

				if (mes.QRSdur != GlobalMeasurement.NoValue)
				{
					aECGAnnotation ann = new aECGAnnotation();

					ann.Code.Code = "MDC_ECG_TIME_PD_QRS";
					ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

					ann.Value.Unit = "ms";
					ann.Value.Value = (double) mes.QRSdur;

					aset.Add(ann);
				}

				if (mes.QTdur != GlobalMeasurement.NoValue)
				{
					aECGAnnotation ann = new aECGAnnotation();

					ann.Code.Code = "MDC_ECG_TIME_PD_QT";
					ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

					ann.Value.Unit = "ms";
					ann.Value.Value = (double) mes.QTdur;

					aset.Add(ann);
				}

				if (mes.QTc != GlobalMeasurement.NoValue)
				{
					aECGAnnotation ann = new aECGAnnotation();

					ann.Code.Code = "MDC_ECG_TIME_PD_QTc";
					ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

					ann.Value.Unit = "ms";
					ann.Value.Value = (double) mes.QTc;

					aset.Add(ann);
				}

				for (int i=0;i < mes.measurment.Length;i++)
				{
					IaECGAnnotationHolder tempset = null;

					if ((i == 0)
					&&	(asetMedian != null))
					{
						tempset = asetMedian;
					}
					else
					{
						aECGAnnotation tempAnn = new aECGAnnotation();
						tempAnn.Code.Code = "MDC_ECG_BEAT";
						tempAnn.Code.CodeSystem = "2.16.840.1.113883.6.24";
						tempAnn.Code.CodeSystemName = "MDC";

						tempAnn.Value.Type = "CE";
						tempAnn.Value.Code = "MDC_ECG_BEAT";
						tempAnn.Value.CodeSystem = "2.16.840.1.113883.6.24";
						tempAnn.Value.CodeSystemName = "MDC";

						aset.Add(tempAnn);

						tempset = tempAnn;
					}

					GlobalMeasurement gmes = mes.measurment[i];

					aECGAnnotation ann = new aECGAnnotation();

					ann.Code.Code = "MDC_ECG_WAVC";
					ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

					ann.Value.Type = "CE";
					ann.Value.Code = "MDC_ECG_WAVC_PWAVE";
					ann.Value.CodeSystem = "2.16.840.1.113883.6.24";

					ann.SupportingROI.Code.Code = "ROIPS";
					ann.SupportingROI.Code.CodeSystem = "2.16.840.1.113883.5.4";
					ann.SupportingROI.Code.CodeSystemName = "HL7V3";

					aECGBoundary boundary = new aECGBoundary();
					boundary.Code.Code = "TIME_RELATIVE";
					boundary.Code.CodeSystem = "2.16.840.1.113883.6.24";

					boundary.Value.Type = "IVL_PQ";
					boundary.Value["low"] = new aECGValuePair("low", gmes.Ponset, "ms");
					boundary.Value["high"] = new aECGValuePair("high", gmes.Poffset, "ms");

					ann.SupportingROI.Boundary[0] = boundary;
					tempset.Add(ann);

					ann = new aECGAnnotation();

					ann.Code.Code = "MDC_ECG_WAVC";
					ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

					ann.Value.Type = "CE";
					ann.Value.Code = "MDC_ECG_WAVC_QRSWAVE";
					ann.Value.CodeSystem = "2.16.840.1.113883.6.24";

					ann.SupportingROI.Code.Code = "ROIPS";
					ann.SupportingROI.Code.CodeSystem = "2.16.840.1.113883.5.4";
					ann.SupportingROI.Code.CodeSystemName = "HL7V3";

					boundary = new aECGBoundary();
					boundary.Code.Code = "TIME_RELATIVE";
					boundary.Code.CodeSystem = "2.16.840.1.113883.6.24";

					boundary.Value.Type = "IVL_PQ";
					boundary.Value["low"] = new aECGValuePair("low", gmes.QRSonset, "ms");
					boundary.Value["high"] = new aECGValuePair("high", gmes.QRSoffset, "ms");

					ann.SupportingROI.Boundary[0] = boundary;
					tempset.Add(ann);

					ann = new aECGAnnotation();

					ann.Code.Code = "MDC_ECG_WAVC";
					ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

					ann.Value.Type = "CE";
					ann.Value.Code = "MDC_ECG_WAVC_TWAVE";
					ann.Value.CodeSystem = "2.16.840.1.113883.6.24";

					ann.SupportingROI.Code.Code = "ROIPS";
					ann.SupportingROI.Code.CodeSystem = "2.16.840.1.113883.5.4";
					ann.SupportingROI.Code.CodeSystemName = "HL7V3";

					boundary = new aECGBoundary();
					boundary.Code.Code = "TIME_RELATIVE";
					boundary.Code.CodeSystem = "2.16.840.1.113883.6.24";

					boundary.Value.Type = "IVL_PQ";
					boundary.Value["high"] = new aECGValuePair("high", gmes.Toffset, "ms");

					ann.SupportingROI.Boundary[0] = boundary;
					tempset.Add(ann);

					if (gmes.Paxis != GlobalMeasurement.NoAxisValue)
					{
						ann = new aECGAnnotation();

						ann.Code.Code = "MDC_ECG_ANGLE_P_FRONT";
						ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

						ann.Value.Type = "PQ";
						ann.Value.Value = (double) gmes.Paxis;
						ann.Value.Unit = "deg";
						tempset.Add(ann);
					}

					if (gmes.QRSaxis != GlobalMeasurement.NoAxisValue)
					{
						ann = new aECGAnnotation();

						ann.Code.Code = "MDC_ECG_ANGLE_QRS_FRONT";
						ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

						ann.Value.Type = "PQ";
						ann.Value.Value = (double) gmes.QRSaxis;
						ann.Value.Unit = "deg";
						tempset.Add(ann);
					}

					if (gmes.Taxis != GlobalMeasurement.NoAxisValue)
					{
						ann = new aECGAnnotation();

						ann.Code.Code = "MDC_ECG_ANGLE_T_FRONT";
						ann.Code.CodeSystem = "2.16.840.1.113883.6.24";

						ann.Value.Type = "PQ";
						ann.Value.Value = (double) gmes.Taxis;
						ann.Value.Unit = "deg";
						tempset.Add(ann);
					}
				}

				if (aset.Annotation[0] != null)
					series.Add(aset);

				if (asetMedian.Annotation[0] != null)
					seriesMedian.Add(asetMedian);

				return 0;
			}

			return 1;
		}

		#endregion

		public static int IndexOf(string[] values, string val)
		{
			if ((values == null)
			||	(val == null))
				return -1;

			for (int i=0;i < values.Length;i++)
				if (string.Compare(values[i], val) == 0)
					return i;

			return -1;
		}

		private static string GetFileName(string temp1)
		{
			if (temp1 != null)
			{
				string[] temp2 = temp1.Split(' ');
				temp2 = temp2[temp2.Length-1].Split('\\', '/');
						
				return temp2[temp2.Length-1];
			}

			return string.Empty;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -