Sets 8-bit data for a channel.
#include "Ltdic.h"
L_UINT32 LDicomWaveformChannel::SetChannelSamples8(pSamples, uCount)
Pointer to the buffer that holds the new channel samples.
Size of the buffer pointed to by pSamples.
The actual number of samples set for the channel.
This function sets the new samples for a channel. Before calling the LDicomWaveformChannel::SetChannelSamples8 function, be sure to call LDicomWaveformGroup::SetSampleInterpretation to set the waveform sample interpretation.
The number of samples actually set will be less than or equal to the "Number of samples per channel" (003A, 0010) in the multiplex group that represents the parent of this channel. To get that number, call the LDicomWaveformGroup::GetNumberOfSamplesPerChannel function.
This function is intended to be used for setting the data of 8-bit channels where the "Waveform Sample Interpretation" (5400,1006) is signed 8-bit linear (DICOM_SAMPLE_INTERPRETATION_SB), unsigned 8-bit linear (DICOM_SAMPLE_INTERPRETATION_UB), 8-bit mu-law (DICOM_SAMPLE_INTERPRETATION_MB) or 8-bit A-law (DICOM_SAMPLE_INTERPRETATION_AB). To get the waveform sample interpretation, call the LDicomWaveformGroup::GetSampleInterpretation function.
Win32, x64
/******************************************************************//* This is a comprehensive sample, which shows how to insert a *//* waveform group with one ECG channel into a dataset. *//* The main function is InsertECGCWaveform ,and the rest of the *//* functions are helping functions. *//******************************************************************/// Function prototypesBOOL SetChannelSourceAndSensitivity(LDicomWaveformChannel* pECGChannel);BOOL SetChannelAnnotations(LDicomWaveformChannel* pECGChannel);BOOL InsertECGCChannel( LDicomWaveformGroup* pECGWaveformGroup,L_INT16* pSamples,L_UINT32 uSampleCount);// The main function that creates the// waveform group and adds to the datasetL_INT LDicomWaveformChannel_SetChannelSamples8Example(LDicomDS &InputDS, L_INT16* pSamples, L_UINT32 uSampleCount){L_INT nRet;// Sanity checkif(!pSamples || (uSampleCount == 0) ){return -1;}// Our new waveform groupLDicomWaveformGroup ECGWaveformGroup;// Reset the waveform group, we don't// really need to call this!ECGWaveformGroup.Reset();// Set the number of samples per channel. You can call// LDicomWaveformGroup::GetNumberOfSamplesPerChannel to get// the number of samplesif(!ECGWaveformGroup.SetNumberOfSamplesPerChannel(uSampleCount)){return -1;}// Set the sampling frequency. You can call// LDicomWaveformGroup::GetSamplingFrequency to// get the sampling frequencyECGWaveformGroup.SetSamplingFrequency(240.00);// Set sample interpretationif(!ECGWaveformGroup.SetSampleInterpretation(DICOM_SAMPLE_INTERPRETATION_SS)){return -1;}// Just in case!if(ECGWaveformGroup.GetSampleInterpretation() != DICOM_SAMPLE_INTERPRETATION_SS){return -1;}// No Multiplex Group Time Offset// You can call LDicomWaveformGroup::GetMultiplexGroupTimeOffset// to get the time offsetif(!ECGWaveformGroup.SetMultiplexGroupTimeOffset(FALSE, 0.0)){return -1;}// No Trigger Time Offset// You can call LDicomWaveformGroup::GetTriggerTimeOffset// to get the trigger time offsetif(!ECGWaveformGroup.SetTriggerTimeOffset(FALSE, 0.0)){return -1;}// No Trigger Sample Position// You can call LDicomWaveformGroup::GetTriggerSamplePosition// to get the trigger sample positionif(!ECGWaveformGroup.SetTriggerSamplePosition(FALSE, 0)){return -1;}// Waveform originality is originalECGWaveformGroup.SetWaveformOriginality(DICOM_WAVEFORM_ORIGINALITY_ORIGINAL);// Just in caseif(ECGWaveformGroup.GetWaveformOriginality() != DICOM_WAVEFORM_ORIGINALITY_ORIGINAL){return -1;}// Set the multiplex group labelif(!ECGWaveformGroup.SetMultiplexGroupLabel(TEXT("SCPECG Waveform"))){return -1;}if(ECGWaveformGroup.GetMultiplexGroupLabel() == NULL){return -1;}// Set the Waveform padding value// You can call LDicomWaveformGroup::GetWaveformPaddingValue// to get the waveform padding valueif(!ECGWaveformGroup.SetWaveformPaddingValue(TRUE,32768)){return -1;}if (!InsertECGCChannel(&ECGWaveformGroup , pSamples, uSampleCount)){return -1;}// Delete any waveform groups that already exist in the datasetL_UINT32 uWaveformGroupCount = InputDS.GetWaveformGroupCount();for(L_UINT32 uIndex = 0 ; uIndex < uWaveformGroupCount ; uIndex++){nRet = InputDS.DeleteWaveformGroup(uIndex,0);if(nRet != DICOM_SUCCESS)return nRet;}// Insert the new waveform group into the datasetnRet = InputDS.AddWaveformGroup(&ECGWaveformGroup, 0, ELEMENT_INDEX_MAX);if(nRet != DICOM_SUCCESS)return nRet;return DICOM_SUCCESS;}// Add an ECG channel to the groupBOOL InsertECGCChannel (LDicomWaveformGroup* pECGWaveformGroup, L_INT16* pSamples, L_UINT32 uSampleCount){LDicomWaveformChannel* pECGChannel= NULL;L_UINT32 uNumberOfSamples =0;L_INT32 nChannelNumber = -1;L_INT32 nMinValue = 0;L_INT32 nMaxValue = 0;if(pECGWaveformGroup == NULL){return FALSE;}// Add a channel to the grouppECGChannel = pECGWaveformGroup->AddChannel(/*ELEMENT_INDEX_MAX*/);if(pECGChannel == NULL){return FALSE;}// If we want to update a channel, we can first call// LDicomWaveformGroup::DeleteChannel and then call// LDicomWaveformGroup::AddChannel with the same// index we passed to DeleteChannel// Make sure that the channel really got added// This is for the purposes of this sample only, because// the check we did in the previous statement is enoughif( (pECGWaveformGroup->GetNumberOfChannels() !=1)||(pECGWaveformGroup->GetChannel(0) ==NULL) ){return FALSE;}// Sanity checks!if((pECGChannel->GetWaveformGroup() != pECGWaveformGroup)||(pECGChannel->GetIndex() != 0)){return FALSE;}/*Set the channel samplesThe data we are setting in here is 16 bit data.We would call SetChannelSamples8 if the data were 8 bit.We can also call SetChannelSamples32, which will set the dataas either 8-bit or 16-bit depending on the sample interpretation*/if(pECGChannel->SetChannelSamples16(pSamples, uSampleCount)!=uSampleCount){return FALSE;}// Just in caseif((!pECGChannel->GetChannelSamples(&uNumberOfSamples))||(uNumberOfSamples == 0)){return FALSE;}// Set the channel source and sensitivityif(!SetChannelSourceAndSensitivity(pECGChannel)){return FALSE;}// Set the channel statuspECGChannel->SetChannelStatus(DICOM_CHANNEL_STATUS_OK);if(pECGChannel->GetChannelStatus()!=DICOM_CHANNEL_STATUS_OK){return FALSE;}// Set the channel time skew. You can call// LDicomWaveformChannel::GetChannelTimeSkew to get the time skew// You can also call LDicomWaveformChannel::SetChannelSampleSkew// And LDicomWaveformChannel::GetChannelSampleSkew to set and get// the channel samples skewpECGChannel->SetChannelTimeSkew(0.000000);// Set the waveform channel numberif(!pECGChannel->SetWaveformChannelNumber(TRUE, 0)){return FALSE;}if((!pECGChannel->GetWaveformChannelNumber(&nChannelNumber))||(nChannelNumber !=0)){return FALSE;}// Set the channel labelif(!pECGChannel->SetChannelLabel(TEXT("First Channel"))){return FALSE;}if(!pECGChannel->GetChannelLabel()){return FALSE;}// No channel offset// You can also call LDicomWaveformChannel::GetChannelOffset// To get the channel offsetif(!pECGChannel->SetChannelOffset(FALSE, 0.0)){return FALSE;}// Set filter low frequency// You can also call LDicomWaveformChannel::GetFilterLowFrequency// To get the filter low frequencyif(!pECGChannel->SetFilterLowFrequency(TRUE, 0.050)){return FALSE;}// Set filter high frequency// You can also call LDicomWaveformChannel::GetFilterHighFrequency// To get the filter high frequencyif(!pECGChannel->SetFilterHighFrequency(TRUE, 100.00)){return FALSE;}// Set the channel minimum valueif(!pECGChannel->SetChannelMinimumValue(TRUE, -386)){return FALSE;}// Set the channel maximum valueif(!pECGChannel->SetChannelMaximumValue(TRUE, 1264)){return FALSE;}// Just in caseif((!pECGChannel->GetChannelMinimumValue(&nMinValue))||(nMinValue !=-386)){return FALSE;}// Just in caseif((!pECGChannel->GetChannelMaximumValue(&nMaxValue))||(nMaxValue !=1264)){return FALSE;}/*You can also call the following functions to set and getthe notchfilter frequency and bandwidthLDicomWaveformChannel::SetNotchFilterFrequencyLDicomWaveformChannel::GetNotchFilterFrequencyLDicomWaveformChannel::SetNotchFilterBandwidthLDicomWaveformChannel::GetNotchFilterBandwidth*/// Last, but not least, set the channel annotations!return SetChannelAnnotations(pECGChannel);}//Set the channel source and sensitivityBOOL SetChannelSourceAndSensitivity(LDicomWaveformChannel* pECGChannel){// Let's use the DICOM context group tables!///////////////////////Channel Source/////////////////////////// Load the ECG Leads tableLDicomContextGroup::Load(CID_3001);pDICOMCONTEXTGROUP pECGLeadsGroup = LDicomContextGroup::Find(CID_3001);if (pECGLeadsGroup){// 5.6.3-9-1 is Lead I (Einthoven)pDICOMCODEDCONCEPT pCodedConcept = LDicomContextGroup::FindCodedConcept(pECGLeadsGroup,TEXT("MDC"),TEXT("2:1"));if (pCodedConcept){DICOMCODESEQUENCEITEM DicomSourceSequenceItem;L_UINT16 uRet;memset(&DicomSourceSequenceItem, 0, sizeof(DICOMCODESEQUENCEITEM));DicomSourceSequenceItem.uStructSize = sizeof(DICOMCODESEQUENCEITEM);DicomSourceSequenceItem.pszCodeValue = pCodedConcept->pszCodeValue;DicomSourceSequenceItem.pszCodingSchemeDesignator = pCodedConcept->pszCodingSchemeDesignator;DicomSourceSequenceItem.pszCodingSchemeVersion = pCodedConcept->pszCodingSchemeVersion;DicomSourceSequenceItem.pszCodeMeaning = pCodedConcept->pszCodeMeaning;// Set the channel sourceuRet = pECGChannel->SetChannelSource(&DicomSourceSequenceItem);if (uRet != DICOM_SUCCESS){return FALSE;}// You can call LDicomWaveformChannel::GetChannelSource ()// to get the channel source}else{return FALSE;}}else{return FALSE;}///////////////////////Channel Sensitivity////////////////////////// Cardiology Units of MeasurementDICOMCODESEQUENCEITEM DicomSourceSequenceItem;L_UINT16 uRet;memset(&DicomSourceSequenceItem, 0, sizeof(DICOMCODESEQUENCEITEM));DicomSourceSequenceItem.uStructSize = sizeof(DICOMCODESEQUENCEITEM);DicomSourceSequenceItem.pszCodeValue = TEXT("mV");DicomSourceSequenceItem.pszCodingSchemeDesignator = TEXT("UCUM");DicomSourceSequenceItem.pszCodingSchemeVersion = TEXT("");DicomSourceSequenceItem.pszCodeMeaning = TEXT("millivolt");// Set the channel sensitivityuRet = pECGChannel->SetChannelSensitivity(TRUE,0.001220,&DicomSourceSequenceItem);if (uRet != DICOM_SUCCESS){return FALSE;}// You can call LDicomWaveformChannel::GetChannelSensitivity()// to get the channel sensitivityreturn TRUE;}// Add annotations for the channelBOOL SetChannelAnnotations(LDicomWaveformChannel* pECGChannel){// Delete any existing channel annotationsfor(L_UINT32 uIndex = 0 ; uIndex <pECGChannel->GetAnnotationCount();uIndex++){if(pECGChannel->GetAnnotation(uIndex)){pECGChannel->DeleteAnnotation(uIndex);}}DICOMWAVEFORMANNOTATION ECGWaveformAnnotation;memset(&ECGWaveformAnnotation,0, sizeof(DICOMWAVEFORMANNOTATION));ECGWaveformAnnotation.uStructSize = sizeof(DICOMWAVEFORMANNOTATION);// Over here we are populating the DICOMCODESEQUENCEITEM structure// directly. What we can also do is fill it with values from// the LDicomContextGroup table which lists all the context// group tables defined by the DICOM standard. You can look at// the SetChannelSourceAndSensitivity above for an Example on// how to do that//DICOMCODESEQUENCEITEM CodedName;memset(&CodedName,0, sizeof(DICOMCODESEQUENCEITEM));CodedName.uStructSize = sizeof(DICOMCODESEQUENCEITEM);CodedName.pszCodeValue = TEXT("8867-4");CodedName.pszCodeMeaning = TEXT("Heart rate");CodedName.pszCodingSchemeDesignator = TEXT("LN");CodedName.pszCodingSchemeVersion = TEXT("19971101");ECGWaveformAnnotation.pCodedName = &CodedName;DICOMCODESEQUENCEITEM MeasurementUnits;memset(&MeasurementUnits,0, sizeof(DICOMCODESEQUENCEITEM));MeasurementUnits.uStructSize =sizeof(DICOMCODESEQUENCEITEM);MeasurementUnits.pszCodeValue = TEXT("{H.B.}/min");MeasurementUnits.pszCodeMeaning = TEXT("Heart beat per minute");MeasurementUnits.pszCodingSchemeDesignator = TEXT("UCUM");MeasurementUnits.pszCodingSchemeVersion = TEXT("1.4");ECGWaveformAnnotation.pMeasurementUnits = &MeasurementUnits;L_DOUBLE dNumericValue = 69.00;ECGWaveformAnnotation.pNumericValue = &dNumericValue ;ECGWaveformAnnotation.uNumericValueCount = 1;if(pECGChannel->AddAnnotation(&ECGWaveformAnnotation) != DICOM_SUCCESS){return FALSE;}return TRUE;}