How to get data from DICOM file receiver in C++

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
ruben.cruz
Posts: 43
Joined: Fri, 2019-05-03, 15:06

How to get data from DICOM file receiver in C++

#1 Post by ruben.cruz »

hi,

we are trying to develop a small tool in c++ to receive and store DICOM files.
Main goal is to store it and save the information of each into a another file or a database.

this is the code we have been using, but we need to understand were and how to get the data from each file receive to use it properlly when we need it:

Code: Select all

#include "dcmtk/dcmdata/dctk.h"
#include "dcmtk/dcmnet/assoc.h"
#include "dcmtk/dcmnet/dimse.h"
#include "dcmtk/dcmnet/dstorscp.h"

#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	DcmSCP scp;
	DcmStorageSCP storagescp;

	OFList<OFString> XferSyntaxes;
	XferSyntaxes.push_back(UID_LittleEndianImplicitTransferSyntax);
	XferSyntaxes.push_back(UID_LittleEndianExplicitTransferSyntax);
	XferSyntaxes.push_back(UID_BigEndianExplicitTransferSyntax);

	storagescp.addPresentationContext(UID_AmbulatoryECGWaveformStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_BasicTextSRStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_BasicVoiceAudioWaveformStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_BlendingSoftcopyPresentationStateStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_CardiacElectrophysiologyWaveformStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_ChestCADSRStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_ColorSoftcopyPresentationStateStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_ComprehensiveSRStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_ComputedRadiographyImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_CTImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_DigitalIntraOralXRayImageStorageForPresentation, XferSyntaxes);
	storagescp.addPresentationContext(UID_DigitalIntraOralXRayImageStorageForProcessing, XferSyntaxes);
	storagescp.addPresentationContext(UID_DigitalMammographyXRayImageStorageForPresentation, XferSyntaxes);
	storagescp.addPresentationContext(UID_DigitalMammographyXRayImageStorageForProcessing, XferSyntaxes);
	storagescp.addPresentationContext(UID_DigitalXRayImageStorageForPresentation, XferSyntaxes);
	storagescp.addPresentationContext(UID_DigitalXRayImageStorageForProcessing, XferSyntaxes);
	storagescp.addPresentationContext(UID_EncapsulatedPDFStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_EnhancedCTImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_EnhancedMRImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_EnhancedSRStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_EnhancedXAImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_EnhancedXRFImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_GeneralECGWaveformStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_GrayscaleSoftcopyPresentationStateStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_HemodynamicWaveformStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_KeyObjectSelectionDocumentStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_MammographyCADSRStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_MRImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_MRSpectroscopyStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_MultiframeGrayscaleByteSecondaryCaptureImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_MultiframeGrayscaleWordSecondaryCaptureImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_MultiframeSingleBitSecondaryCaptureImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_MultiframeTrueColorSecondaryCaptureImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_NuclearMedicineImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_OphthalmicPhotography16BitImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_OphthalmicPhotography8BitImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_OphthalmicTomographyImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_PositronEmissionTomographyImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_ProcedureLogStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_PseudoColorSoftcopyPresentationStateStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_RawDataStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_RealWorldValueMappingStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_RTBeamsTreatmentRecordStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_RTBrachyTreatmentRecordStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_RTDoseStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_RTImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_RTPlanStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_RTStructureSetStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_RTTreatmentSummaryRecordStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_SecondaryCaptureImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_SpatialFiducialsStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_SpatialRegistrationStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_StereometricRelationshipStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_TwelveLeadECGWaveformStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_UltrasoundImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_UltrasoundMultiframeImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_VLEndoscopicImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_VLMicroscopicImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_VLPhotographicImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_VLSlideCoordinatesMicroscopicImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_XRayAngiographicImageStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_XRayRadiationDoseSRStorage, XferSyntaxes);
	storagescp.addPresentationContext(UID_XRayRadiofluoroscopicImageStorage, XferSyntaxes);

	// temporaty folder in Desktop
	storagescp.setOutputDirectory("C:\\Users\\user-pc\\Desktop\\temp");
	
	storagescp.setFilenameGenerationMode(DcmStorageSCP::FGM_SOPInstanceUID);

	storagescp.setAETitle("TEST");
	storagescp.setPort(104);

	storagescp.listen();
}
if @Michael Onken, or someone could help it would be very appreciated.
(dcmtk-3.6.4)

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: How to get data from DICOM file receiver in C++

#2 Post by J. Riesmeier »

For DcmStorageSCP, a class that I wrote, everything you need to know should be available in the documentation: https://support.dcmtk.org/docs/classDcmStorageSCP.html
Also the command line tool dcmrecv could be used as a demonstration object since it is based on DcmStorageSCP: https://support.dcmtk.org/docs/dcmrecv.html

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: How to get data from DICOM file receiver in C++

#3 Post by J. Riesmeier »

If you need further "storage modes" this would also be possible, of course. I've developed the above-mentioned class and tool for one of my customers (to fullfil their needs).

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: How to get data from DICOM file receiver in C++

#4 Post by Michael Onken »

Since you addressed me directly: I could not say it better :)

Best regards,
Michael

ruben.cruz
Posts: 43
Joined: Fri, 2019-05-03, 15:06

Re: How to get data from DICOM file receiver in C++

#5 Post by ruben.cruz »

Thank you so much for your time, i have been looking into the documentation and the links you provide but can't figure it out how to solve the main issue.

have been using the "setDatasetStorageMode(DcmStorageSCP::DGM_StoreToFile)" but what is exactly need is a way to get the PatientID and StudyDate, for example, and from there i would be able to use the SOPInstanceUID and manage files storing this info into a file or a log.

Or maybe a way to use the protect funcions like: notifyInstanceStored ?

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: How to get data from DICOM file receiver in C++

#6 Post by J. Riesmeier »

Sounds like you want to derive your own class from DcmStorageSCP and overwrite the notifyInstanceStored() method.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 1 guest