I am trying to convert digitized ecg data to dicom file. My code looks like as below
DateTime today = DateTime.Today;
DicomFile dicomFile = new DicomFile();
dicomFile.TransferSyntax = TransferSyntax.ExplicitVrLittleEndian;
dicomFile.DataSet[DicomTags.StudyDate].SetStringValue(today.ToString("yyyyMMdd"));
dicomFile.DataSet[DicomTags.StudyTime].SetStringValue(today.ToString("HHmmss"));
dicomFile.DataSet[DicomTags.PatientsBirthName].SetStringValue(patientName);
dicomFile.DataSet[DicomTags.PatientId].SetStringValue(patientId);
dicomFile.DataSet[DicomTags.StudyInstanceUid].SetStringValue(studyId);
dicomFile.DataSet[DicomTags.SeriesInstanceUid].SetStringValue(seriesId);
dicomFile.DataSet[DicomTags.Modality].SetStringValue(modality);
dicomFile.DataSet[DicomTags.ConversionType].SetStringValue(conversionType);//Drawing
string sopInstanceUid = DicomUid.GenerateUid().UID; // Should be unique for each image
this.pacsAccessionNumber = (Functions.GetRandomString() + Functions.GetRandomString()).Substring(0, 16);
dicomFile.DataSet[DicomTags.InstanceNumber].SetInt32(0, instanceNumber);//Series Instance Number
dicomFile.DataSet[DicomTags.SopClassUid].SetStringValue(SopClass.Sop12LeadEcgWaveformStorage.Uid);
dicomFile.DataSet[DicomTags.SopInstanceUid].SetStringValue(sopInstanceUid);
dicomFile.DataSet[DicomTags.AccessionNumber].SetStringValue(this.pacsAccessionNumber);
dicomFile.MediaStorageSopClassUid = SopClass.Sop12LeadEcgWaveformStorage.Uid;
dicomFile.MediaStorageSopInstanceUid = sopInstanceUid;
dicomFile.DataSet[DicomTags.Manufacturer].SetStringValue("MITS");// Manufacturer Name
DicomSequenceItem waveFormSeq = new DicomSequenceItem();
waveFormSeq[DicomTags.WaveformOriginality].SetStringValue("DERIVED");// Other option is ORIGINAL
waveFormSeq[DicomTags.WaveformChannelNumber].SetUInt32(0, 1);//must be between 1-13
waveFormSeq[DicomTags.NumberOfWaveformSamples].Values = samplingCount;//NumberOfWaveformSamples -- max value is 16384
waveFormSeq[DicomTags.SamplingFrequency].SetFloat32(0, 1000);//frequency(must be dynamic) -- must be dynamic must be between 200-100
waveFormSeq[DicomTags.WaveformSampleInterpretation].SetStringValue("SS");//signed
waveFormSeq[DicomTags.WaveformBitsAllocated].SetInt32(0, 16);//16 bit
waveFormSeq[DicomTags.WaveformData].Values = voltageValues;
DicomSequenceItem channelSeq = new DicomSequenceItem();
channelSeq[DicomTags.ChannelSensitivityCorrectionFactor].SetUInt32(0, 1);
channelSeq[DicomTags.ChannelBaseline].SetUInt32(0, 0);
channelSeq[DicomTags.ChannelTimeSkew].SetUInt32(0, 0);
DicomSequenceItem channelSourceSeq = new DicomSequenceItem();
channelSourceSeq[DicomTags.CodeValue].SetStringValue("5.6.3-9-1");
channelSourceSeq[DicomTags.CodingSchemeDesignator].SetStringValue("SCPECG");
channelSourceSeq[DicomTags.CodingSchemeVersion].SetStringValue("1.3");
channelSeq[DicomTags.ChannelSourceSequence].AddSequenceItem(channelSourceSeq);
DicomSequenceItem channelSensUnitSeq = new DicomSequenceItem();
channelSensUnitSeq[DicomTags.CodeValue].SetStringValue("uV");
channelSensUnitSeq[DicomTags.CodingSchemeDesignator].SetStringValue("UCUM");
channelSensUnitSeq[DicomTags.CodingSchemeVersion].SetStringValue("1.4");
channelSeq[DicomTags.ChannelSensitivityUnitsSequence].AddSequenceItem(channelSensUnitSeq);
waveFormSeq[DicomTags.ChannelSequence].AddSequenceItem(channelSeq);
dicomFile.DataSet[DicomTags.WaveformSequence].AddSequenceItem(waveFormSeq);
SendFile(dicomFile);
But in pacs server, I could not open the dcm file.
Is there sth I am missing?
The link of the dicom file http://www.ikincidoktor.com/NonDicomRepository/8/testecg.dcm