上篇文件介绍了什么dicomhttps://blog.csdn.net/qq_39569480/article/details/149641920?spm=1001.2014.3001.5502 本篇文章我们来使用fo_dicom接收并解析dicom文件。
文章结尾附源码。
1.开发环境
visual studio 2019
.netframwork 4.8
2.关键知识点
dicom三要素为 AE title、IP、port
AE Title(Application Entity Title,应用实体标题)
是DICOM(医学数字成像与通信)标准中用于唯一标识网络中的通信节点的核心参数。它在医疗影像系统(如PACS、影像设备)的互联互通通过唯一命名和长度限制(≤16字符) 确保设备间精准通信。它在影像传输、来源追溯、服务调度中不可或缺,配置错误可能引发传输失败或数据混乱。实际应用中需严格遵循命名唯一性规则。
首先声明允许的ae title集合
private static readonly string[] AllowedAEs = { "PACS_SERVER", "MICRODICOM" }; // 允许的AE Title列表
端口号:用于通信端口
private const int Port = 11112; // PACS标准端口
ip: 服务的ip地址
什么是sop类:
SOP类(Service Object Pair,服务对象对)是DICOM(医学数字成像与通信)标准中的核心概念,定义了如何通过特定服务操作特定类型的医学数据对象。它是DICOM网络通信和数据处理的基础单元,确保不同医疗设备(如CT、MRI、PACS)之间的互操作性。
SOP类的作用与意义:
1.标准化通信
设备通过协商支持的SOP类建立关联(Association),确保双方能理解彼此的请求与响应。例如CT设备需声明支持CT Image Storage SOP Class才能向PACS传输图像5。
2.唯一标识
每个SOP类有唯一的UID(如CT图像存储类UID为1.2.840.10008.5.1.4.1.1.2),避免操作歧义45。
3.功能扩展性
新型医疗技术(如眼科层析成像)可定义专属SOP类,支持复杂数据(如动态多帧图像)8。
4.常见的sop类举例
(1).Verification SOP Class
作用:验证网络连通性(如C-ECHO命令)15。
UID:1.2.840.10008.1.1。
(2).Storage SOP Class
作用:传输图像(如CT/MR图像)。
特点:不同设备有专属UID(如MR图像类UID为1.2.840.10008.5.1.4.1.1.4)14。
(3).Modality Worklist SOP Class
作用:设备从HIS/RIS系统获取待检患者列表(C-FIND查询)6。
UID:1.2.840.10008.5.1.4.31。
(4).Query/Retrieve SOP Class
作用:分层级查询数据(如患者级、检查级)16。
(5).MPPS SOP Class
作用:管理设备执行检查的进度状态2。
设置支持的SOP类UID列表
private static readonly string[] SupportedSopClasses ={// 验证服务类SOP (必须添加)DicomUID.Verification.UID,// 存储类SOPDicomUID.CTImageStorage.UID,DicomUID.MRImageStorage.UID,DicomUID.ComputedRadiographyImageStorage.UID,DicomUID.DigitalXRayImageStorageForPresentation.UID,DicomUID.UltrasoundImageStorage.UID,DicomUID.SecondaryCaptureImageStorage.UID,DicomUID.NuclearMedicineImageStorageRetiredRETIRED.UID,DicomUID.NuclearMedicineImageStorage.UID,DicomUID.PositronEmissionTomographyImageStorage.UID,DicomUID.RTImageStorage.UID,DicomUID.UltrasoundImageStorageRetiredRETIRED.UID,DicomUID.UltrasoundMultiFrameImageStorage.UID,DicomUID.UltrasoundMultiFrameImageStorageRetiredRETIRED.UID,DicomUID.XRayAngiographicImageStorage.UID,DicomUID.XRayRadiofluoroscopicImageStorage.UID,DicomUID.DigitalXRayImageStorageForPresentation.UID,DicomUID.DigitalXRayImageStorageForProcessing.UID,DicomUID.DigitalMammographyXRayImageStorageForPresentation.UID,DicomUID.DigitalMammographyXRayImageStorageForProcessing.UID,DicomUID.DigitalIntraOralXRayImageStorageForPresentation.UID,DicomUID.DigitalIntraOralXRayImageStorageForProcessing.UID,DicomUID.XRayAngiographicBiPlaneImageStorageRETIRED.UID,DicomUID.VLEndoscopicImageStorage.UID,DicomUID.VLMicroscopicImageStorage.UID,DicomUID.VLSlideCoordinatesMicroscopicImageStorage.UID,DicomUID.VLPhotographicImageStorage.UID,DicomUID.GrayscaleSoftcopyPresentationStateStorage.UID,DicomUID.KeyObjectSelectionDocumentStorage.UID// 添加其他需要的SOP类};
3.环境配置
这里使用的是fo-dicom 4.0.8 大家可根据自己的需求使用对应版本
部分代码实现
DICOM服务类:
using Dicom;
using Dicom.Imaging;
using Dicom.Network;
using Dicom.Log;
using SixLabors.ImageSharp.Formats.Jpeg;
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace DICOMkztDemo
{public class DICOMServer{private const int Port = 11112; // PACS标准端口private static readonly string StoragePath = @"C:\DICOM_Storage\";private static readonly string JpegOutputPath = @"C:\DICOM_Storage\DICOM_JPG\";private static readonly string[] AllowedAEs = { "PACS_SERVER", "MICRODICOM" }; // 允许的AE Title列表private static readonly DicomTransferSyntax[] AcceptedTransferSyntaxes ={DicomTransferSyntax.ExplicitVRLittleEndian,<