如何从DICOM文件中获取原始的心电图数据? [英] How to get raw ecg data from DICOM file?

查看:157
本文介绍了如何从DICOM文件中获取原始的心电图数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我拥有的dcm文件中获取原始的心电图数据(时间-电压).我想在MATLAB中执行此操作,如果还有其他方法,请告诉我.谢谢

I would like to obtain raw ecg data (time - voltage) from a dcm file I have. I would like to do that in MATLAB, hovever if there is any other way, please let me know. Thank you

推荐答案

以下代码将获取元素.不知道值是Big Endian还是Little Endian,因此可能需要交换字节.

The following code will get the elements. Not sure if the values are Big Endian or Little Endian so the bytes may need to be swapped.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication51
{

    class Program
    {
        const string FILENAME = @"c:\temp\test.dcm";

        static void Main(string[] args)
        {
           new DataElement(FILENAME);
        }
    }
    public class DataElement
    {
        public static List<DataElement> elements = null;

        public UInt16 groupNumber { get; set; }
        public UInt16 elementNumber { get; set; }
        public string vr { get; set; }
        public byte[] reserved { get; set; }
        public uint length { get; set; }
        public byte[] values { get; set; }

        public DataElement() { }
        public DataElement(string filename)
        {
            elements = new List<DataElement>();

            Stream stream = File.OpenRead(filename);
            BinaryReader bReader = new BinaryReader(stream);

            long length = stream.Length;
            while (stream.Position < length)
            {
                DataElement element = new DataElement();
                elements.Add(element);

                element.groupNumber = bReader.ReadUInt16();
                element.elementNumber = bReader.ReadUInt16();
                element.vr = bReader.ReadChars(2).ToString();
                element.reserved = bReader.ReadBytes(2);
                element.length = bReader.ReadUInt32();
                element.values = bReader.ReadBytes((int)element.length);
            }
        }

    }


}

这篇关于如何从DICOM文件中获取原始的心电图数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆