Load() public method

Loads a dicom file
public Load ( Stream fs, DicomReadOptions options ) : DicomReadStatus
fs Stream File stream to read
options DicomReadOptions DICOM read options
return DicomReadStatus
Esempio n. 1
0
        public void UpdateDicomFile(UpdateData updateData)
        {
            DicomFileFormat dicomFile = new DicomFileFormat();

            dicomFile.Load(updateData.DicomFileName, DicomReadOptions.DeferLoadingLargeElements);

            foreach (KeyValuePair<DicomTag, string> kvp in updateData.UpdateDataset)
            {
                dicomFile.Dataset.SetString(kvp.Key, kvp.Value);
            }

            foreach (KeyValuePair<DicomTag, string> kvp in updateData.UpdateMetadata)
            {
                dicomFile.FileMetaInfo.SetString(kvp.Key, kvp.Value);
            }

            dicomFile.Dataset.PreloadDeferredBuffers();
            dicomFile.Save(updateData.DicomFileName, DicomWriteOptions.Default);

            //if (updateData.DicomFileName != null)
            //{
            //    string path = Path.GetDirectoryName(updateData.DicomFilePath);
            //    File.Move(updateData.DicomFilePath, path + @"\" + updateData.DicomFileName);
            //}
        }
Esempio n. 2
0
		public void UpdateDicomFile(string updateFile, string dicomTag, string newValue)
		{
            try
            {
                DicomFileFormat dicomFile = new DicomFileFormat();
                DicomTag updateDicomTag = DicomTag.Parse(dicomTag);

                dicomFile.Load(updateFile, DicomReadOptions.DeferLoadingLargeElements);
                string what = updateDicomTag.Entry.ToString();

                if (updateDicomTag.Entry.ToString().StartsWith("0002"))
                {
                    dicomFile.FileMetaInfo.SetString(updateDicomTag, newValue);
                }

                else
                {
                    dicomFile.Dataset.SetString(updateDicomTag, newValue);
                }

                dicomFile.Dataset.PreloadDeferredBuffers();
                dicomFile.Save(updateFile, DicomWriteOptions.Default);
            }

            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Esempio n. 3
0
        public void Init()
        {
            var dicomFile = new DicomFileFormat();

            dicomFile.Load(@"Testdata\CT-MONO2-16-chest", DicomReadOptions.Default);
            _instance = new DcmPixelData(dicomFile.Dataset);
        }
Esempio n. 4
0
        public void Setup()
        {
            var ff = new DicomFileFormat();

            ff.Load("Testdata/rtss.dcm", DicomReadOptions.DefaultWithoutDeferredLoading);
            _instances = ff.Dataset.GetSQ(DicomTags.ROIContourSequence).SequenceItems.SelectMany(
                item =>
                (item.Dataset.GetSQ(DicomTags.ContourSequence) ?? new DcmItemSequence(DicomTags.ContourSequence)).
                SequenceItems).Select(item => item.Dataset.GetDS(DicomTags.ContourData)).ToArray();
        }
Esempio n. 5
0
        public List<Dictionary<string,string>> getDicomElementInfo(string fileName, string dirPath)
        {
            try
            {
                DicomFileFormat dff = new DicomFileFormat();
                List<Dictionary<string,string>> elements = new List<Dictionary<string,string>>();
                string loadPath = dirPath + "\\" + fileName;
                dff.Load(loadPath, DicomReadOptions.DeferLoadingLargeElements);
                foreach (DcmItem di in dff.Dataset.Elements)
                {
                    Dictionary<string,string> elementData = new Dictionary<string,string>();
                    elementData.Add("Name", di.Name.ToString());
                    elementData.Add("Tag", di.Tag.ToString());
                    if (dff.Dataset.GetValueString(di.Tag) != "")
                    {
                        elementData.Add("Value", dff.Dataset.GetValueString(di.Tag));
                    }
                    else
                    {
                        elementData.Add("Value", "--Null--");
                    }
                    elements.Add(elementData);
                }

                foreach(DcmItem di in dff.FileMetaInfo.Elements)
                {
                    Dictionary<string, string> elementData = new Dictionary<string, string>();
                    elementData.Add("Name", di.Name.ToString());
                    elementData.Add("Tag", di.Tag.ToString());
                    if (dff.FileMetaInfo.GetValueString(di.Tag) != "")
                    {
                        elementData.Add("Value", dff.FileMetaInfo.GetValueString(di.Tag));
                    }
                    else
                    {
                        elementData.Add("Value", "--Null--");
                    }
                    elements.Add(elementData);
                }

                return elements;
            }
            catch (Exception e)
            {
                string error = e.ToString();
                return null;
            }
        }
Esempio n. 6
0
        private void button2_Click(object sender, EventArgs e)
        {
            /// Globals Connectivity Here
            ///
            Connection connection = null;
             try {

            connection = ConnectionContext.GetConnection();

               if (!connection.IsConnected()) {
               connection.Connect();
            }

               // Open the DICOM File

            DcmDictionary.ImportDictionary("dicom.dic");
            DcmDictionary.ImportDictionary("private.dic");

             var dcmFile = new DicomFileFormat();
             var dcmFileName = textBox1.Text.ToString();
             if (dcmFile.Load(dcmFileName, DicomReadOptions.Default) == DicomReadStatus.Success)
             {

                 var metainfos = dcmFile.FileMetaInfo.Recurse();

                 MessageBox.Show(metainfos.Count().ToString());

             }

               // Need to grab the study instance UID and that will be our Root Node

               // NodeReference studyinstanceuid = connection.CreateNodeReference("dicom");

               // studyinstanceuid.Set(".1.4.7.2.45.6.9");

               // MetaData Information to meta collection

               // DataSet Information to dataset collection

             }

             catch(Exception ee) {

                 MessageBox.Show(ee.ToString());
             }
        }
Esempio n. 7
0
        private void ScanFile(string file)
        {
            try {
                if (!DicomFileFormat.IsDicomFile(file))
                {
                    return;
                }

                DicomFileFormat ff = new DicomFileFormat();
                ff.Load(file, _stopTag, DicomReadOptions.Default);

                if (FileFound != null)
                {
                    FileFound(this, ff.Dataset, file);
                }
            } catch {
                // ignore exceptions?
            }
        }
 private int getSeriesNumberFromDcm(string dcmFile)
 {
     int seriesNumber;
     DicomFileFormat fileRead = new DicomFileFormat();
     fileRead.Load(dcmFile, DicomReadOptions.DeferLoadingLargeElements);
     seriesNumber = Convert.ToInt32(fileRead.Dataset.GetValueString(new DicomTag(DicomConstTags.SeriesNumber)));
     fileRead = null;
     return seriesNumber;
 }
Esempio n. 9
0
        private void UpdateImageBox(DcmImageBox imageBox, String filename, int index)
        {
            try
            {
                DicomFileFormat ff = new DicomFileFormat();
                ff.Load(filename, DicomReadOptions.DefaultWithoutDeferredLoading);
                if (ff.Dataset != null)
                {
                    ff.Dataset.ChangeTransferSyntax(DicomTransferSyntax.ImplicitVRLittleEndian, null);

                    DcmPixelData pixelData = new DcmPixelData(ff.Dataset);
                    PhotometricInterpretation pi = PhotometricInterpretation.Lookup(pixelData.PhotometricInterpretation);

                    // Grayscale only printer?
                    if (pi.IsColor == true && _supportsColorPrinting == false)
                    {
                        pixelData.Unload();
                        return;
                    }

                    // Color only printer?
                    if (pi.IsColor == false && _supportsGrayscalePrinting == false)
                    {
                        pixelData.Unload();
                        return;
                    }

                    DicomUID imageBoxSOPClassUID = null;
                    DcmItemSequence seq = null;
                    DcmItemSequenceItem item = new DcmItemSequenceItem();
                    pixelData.UpdateDataset(item.Dataset);

                    if (pi.IsColor == true)
                    {
                        imageBoxSOPClassUID = DicomUID.BasicColorImageBoxSOPClass;
                        seq = new DcmItemSequence(DicomTags.BasicColorImageSequence);
                    }
                    else
                    {
                        imageBoxSOPClassUID = DicomUID.BasicGrayscaleImageBoxSOPClass;
                        seq = new DcmItemSequence(DicomTags.BasicGrayscaleImageSequence);
                    }
                    seq.AddSequenceItem(item);
                    imageBox.Dataset.AddItem(seq);

                    pixelData.Unload();

                    imageBox.UpdateImageBox(imageBoxSOPClassUID);
                    imageBox.ImageBoxPosition = (ushort)index;
                }
            }
            catch (Exception)
            {
            }
        }
Esempio n. 10
0
File: Program.cs Progetto: GMZ/mdcm
        private static void Main(string[] args)
        {
            if (args.Length == 0 || args.Length > 2 ||
                (args.Length == 2 && args[0].Equals(args[1], StringComparison.InvariantCultureIgnoreCase)))
            {
                Console.WriteLine("usage: dcm2txt dcmfile-in [txtfile-out]");
                return;
            }

            var dcmFileName = args[0];

            if (!File.Exists(dcmFileName))
            {
                Console.WriteLine("dcm2txt: Specified DICOM file '{0}' does not exist or cannot be accessed.",
                                  dcmFileName);
                return;
            }

            if (File.Exists("dicom.dic"))
                DcmDictionary.ImportDictionary("dicom.dic");
            else
                DcmDictionary.LoadInternalDictionary();

            if (File.Exists("private.dic"))
                DcmDictionary.ImportDictionary("private.dic");

            string dump;
            try
            {
                var dcmFile = new DicomFileFormat();
                if (dcmFile.Load(dcmFileName, DicomReadOptions.Default) == DicomReadStatus.Success)
                {
                    var sb = new StringBuilder();

                    if (dcmFile.FileMetaInfo != null)
                        dcmFile.FileMetaInfo.Dump(sb, String.Empty, DicomDumpOptions.None);

                    if (dcmFile.Dataset != null)
                    {
                        dcmFile.Dataset.Dump(sb, String.Empty, DicomDumpOptions.None);
                    }
                    else
                    {
                        Console.WriteLine("dcm2txt: Missing dataset in DICOM file '{0}'.", dcmFileName);
                        return;
                    }
                    dump = sb.ToString();
                }
                else
                {
                    Console.WriteLine("dcm2txt: '{0}' does not appear to be a DICOM file.", dcmFileName);
                    return;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("dcm2txt: Dumping DICOM file to text failed, reason: {0}.", e.Message);
                return;
            }

            try
            {
                if (args.Length == 2)
                {
                    var txtFileName = args[1];
                    File.WriteAllText(txtFileName, dump);
                }
                else
                {
                    Console.Write(dump);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("dcm2txt: Writing DICOM dump to file/console failed, reason: {0}.", e.Message);
            }
        }
Esempio n. 11
0
        private static void CheckDICOMFile(FileInfo FI, TextWriter output, List<DicomTag> DicomTagsToCheck, Dictionary<DicomTag, List<String>> tagTovalues)
        {
            //output.WriteLine("Checking: " + FI.FullName);

            var dcmFile = new DicomFileFormat();
            var dcmFileName = FI.FullName;
            if (dcmFile.Load(dcmFileName, DicomReadOptions.Default) == DicomReadStatus.Success)
            {
                var sb = new StringBuilder();

                if (dcmFile.Dataset != null)
                {
                    foreach(var DT in DicomTagsToCheck) {
                        var Element = dcmFile.Dataset.GetElement(DT);

                        if (Element != null)
                        {
                            var ElementValue = Element.GetValueString();
                            if (ElementValue != null && ElementValue.Length != 0)
                            {
                                //output.WriteLine(Element + " = " + ElementValue);
                                addValue(tagTovalues, DT, ElementValue);
                            }
                        }
                    }

                }
                else
                {
                    Console.WriteLine("dcm2txt: Missing dataset in DICOM file '{0}'.", dcmFileName);

                    return;
                }

                //output.WriteLine(sb.ToString());
            }
            else
            {
                Console.WriteLine("dcm2txt: '{0}' does not appear to be a DICOM file.", dcmFileName);
                return;
            }
        }
Esempio n. 12
0
        private void OnClickPixelDataMD5(object sender, EventArgs e)
        {
            if (_selected == -1)
                return;

            try {
                DicomFileFormat ff = new DicomFileFormat();
                ff.Load(_files[_selected], DicomReadOptions.Default |
                        DicomReadOptions.KeepGroupLengths |
                        DicomReadOptions.DeferLoadingLargeElements |
                        DicomReadOptions.DeferLoadingPixelData);

                DcmPixelData pixels = new DcmPixelData(ff.Dataset);

                if (pixels.NumberOfFrames == 0) {
                    MessageBox.Show(this, "No pixel data", "Pixel Data MD5");
                } else if (pixels.NumberOfFrames >= 1) {
                    MessageBox.Show(this, pixels.ComputeMD5(), String.Format("Pixel Data MD5 [{0} frames]", pixels.NumberOfFrames));
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            } catch {
            }
        }
Esempio n. 13
0
 public void Setup()
 {
     var ff = new DicomFileFormat();
     ff.Load("Testdata/rtss.dcm", DicomReadOptions.DefaultWithoutDeferredLoading);
     _instances = ff.Dataset.GetSQ(DicomTags.ROIContourSequence).SequenceItems.SelectMany(
         item =>
         (item.Dataset.GetSQ(DicomTags.ContourSequence) ?? new DcmItemSequence(DicomTags.ContourSequence)).
             SequenceItems).Select(item => item.Dataset.GetDS(DicomTags.ContourData)).ToArray();
 }
Esempio n. 14
0
        private void ScanFile(string file)
        {
            try {
                if (!DicomFileFormat.IsDicomFile(file))
                    return;

                DicomFileFormat ff = new DicomFileFormat();
                ff.Load(file, _stopTag, DicomReadOptions.Default);

                if (FileFound != null)
                    FileFound(this, ff.Dataset, file);
            } catch {
                // ignore exceptions?
            }
        }
Esempio n. 15
0
        private bool LoadFile(string file)
        {
            bool success = false;
            DicomFileFormat ff = new DicomFileFormat();
            try {
                ClearDump();

                ff.Load(file, DicomReadOptions.Default | DicomReadOptions.KeepGroupLengths);

                success = true;
            }
            catch (Exception e) {
                MessageBox.Show(e.Message + "\n\n" + file, "Error parsing file!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            treeDump.Model = LoadFileFormat(ff);
            treeDump.ExpandAll();

            if (success) {
                if (ff.Dataset.Contains(DicomTags.PixelData)) {
                    tsbViewImage.Enabled = true;
                    tsbExtractPixels.Enabled = true;
                    tsbPixelDataMD5.Enabled = true;
                }
                tsbSaveTS.Enabled = true;
            } else {
                tsbViewImage.Enabled = false;
                tsbExtractPixels.Enabled = false;
                tsbSaveTS.Enabled = false;
                tsbPixelDataMD5.Enabled = false;
            }

            return success;
        }
Esempio n. 16
0
 public void Init()
 {
     var dicomFile = new DicomFileFormat();
     dicomFile.Load(@"Testdata\CT-MONO2-16-chest", DicomReadOptions.Default);
     _instance = new DcmPixelData(dicomFile.Dataset);
 }
Esempio n. 17
0
        private void OnClickExtractPixels(object sender, EventArgs e)
        {
            if (_selected == -1)
                return;

            try {
                DicomFileFormat ff = new DicomFileFormat();
                ff.Load(_files[_selected], DicomReadOptions.Default |
                        DicomReadOptions.KeepGroupLengths |
                        DicomReadOptions.DeferLoadingLargeElements |
                        DicomReadOptions.DeferLoadingPixelData);

                DcmPixelData pixels = new DcmPixelData(ff.Dataset);

                if (pixels.NumberOfFrames == 0)
                    return;
                else if (pixels.NumberOfFrames >= 1) {
                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.RestoreDirectory = true;
                    if (sfd.ShowDialog(this) == DialogResult.OK) {
                        byte[] data = pixels.GetFrameDataU8(0);
                        File.WriteAllBytes(sfd.FileName, data);
                    }
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
            catch {
            }
        }
Esempio n. 18
0
		}

		/// <summary>Width of image in pixels</summary>
		public int Width {
			get { return _pixelData.Width; }
		}

		/// <summary>Height of image in pixels</summary>
Esempio n. 19
0
        private void OnClickSaveWithTransferSyntax(object sender, EventArgs e)
        {
            if (_selected == -1)
                return;

            TransferSyntaxForm tsForm = new TransferSyntaxForm();
            if (tsForm.ShowDialog(this) == DialogResult.OK) {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.RestoreDirectory = true;
                if (sfd.ShowDialog(this) == DialogResult.OK) {
                    DicomFileFormat ff = new DicomFileFormat();
                    ff.Load(_files[_selected], DicomReadOptions.Default);
                    if (tsForm.SelectedTransferSyntax != null)
                        ff.ChangeTransferSytnax(tsForm.SelectedTransferSyntax, null);
                    ff.Save(sfd.FileName, DicomWriteOptions.Default);
                }
            }
        }
Esempio n. 20
0
        private bool ProcessPDataTF(PDataTF pdu)
        {
            try {
                byte pcid = 0;
                foreach (PDV pdv in pdu.PDVs) {
                    pcid = pdv.PCID;
                    if (pdv.IsCommand) {
                        if (_dimse.CommandData == null)
                            _dimse.CommandData = new ChunkStream();

                        _dimse.CommandData.AddChunk(pdv.Value);

                        if (_dimse.Command == null) {
                            _dimse.Command = new DcmCommand();
                        }

                        if (_dimse.CommandReader == null) {
                            _dimse.CommandReader = new DicomStreamReader(_dimse.CommandData);
                            _dimse.CommandReader.Dataset = _dimse.Command;
                        }

                        _dimse.CommandReader.Read(null, DicomReadOptions.Default);

                        _dimse.Progress.BytesTransfered += pdv.Value.Length;
                        _dimse.Progress.EstimatedCommandLength = (int)_dimse.CommandReader.BytesEstimated;

                        if (pdv.IsLastFragment) {
                            _dimse.CloseCommand();

                            bool isLast = true;
                            if (_dimse.Command.Contains(DicomTags.DataSetType)) {
                                if (_dimse.Command.GetUInt16(DicomTags.DataSetType, 0x0101) != 0x0101) {
                                    isLast = false;

                                    DcmCommandField commandField = (DcmCommandField)_dimse.Command.GetUInt16(DicomTags.CommandField, 0);
                                    if (commandField == DcmCommandField.CStoreRequest) {
                                        ushort messageID = _dimse.Command.GetUInt16(DicomTags.MessageID, 1);
                                        DcmPriority priority = (DcmPriority)_dimse.Command.GetUInt16(DicomTags.Priority, 0);
                                        DicomUID affectedInstance = _dimse.Command.GetUID(DicomTags.AffectedSOPInstanceUID);
                                        string moveAE = _dimse.Command.GetString(DicomTags.MoveOriginatorApplicationEntityTitle, null);
                                        ushort moveMessageID = _dimse.Command.GetUInt16(DicomTags.MoveOriginatorMessageID, 1);
                                        OnPreReceiveCStoreRequest(pcid, messageID, affectedInstance, priority,
                                            moveAE, moveMessageID, out _dimse.DatasetFile);

                                        if (_dimse.DatasetFile != null) {
                                            DcmPresContext pres = Associate.GetPresentationContext(pcid);

                                            DicomFileFormat ff = new DicomFileFormat();
                                            ff.FileMetaInfo.FileMetaInformationVersion = DcmFileMetaInfo.Version;
                                            ff.FileMetaInfo.MediaStorageSOPClassUID = pres.AbstractSyntax;
                                            ff.FileMetaInfo.MediaStorageSOPInstanceUID = affectedInstance;
                                            ff.FileMetaInfo.TransferSyntax = pres.AcceptedTransferSyntax;
                                            ff.FileMetaInfo.ImplementationClassUID = Implementation.ClassUID;
                                            ff.FileMetaInfo.ImplementationVersionName = Implementation.Version;
                                            ff.FileMetaInfo.SourceApplicationEntityTitle = Associate.CalledAE;
                                            ff.Save(_dimse.DatasetFile, DicomWriteOptions.Default);

                                            _dimse.DatasetFileStream = new FileStream(_dimse.DatasetFile, FileMode.Open);
                                            _dimse.DatasetFileStream.Seek(0, SeekOrigin.End);
                                            _dimse.DatasetStream = _dimse.DatasetFileStream;
                                        }
                                    }
                                }
                            }
                            if (isLast) {
                                if (_dimse.IsNewDimse)
                                    OnReceiveDimseBegin(pcid, _dimse.Command, _dimse.Dataset, _dimse.Progress);
                                OnReceiveDimseProgress(pcid, _dimse.Command, _dimse.Dataset, _dimse.Progress);
                                OnReceiveDimse(pcid, _dimse.Command, _dimse.Dataset, _dimse.Progress);
                                ProcessDimse(pcid);
                                _dimse = null;
                                return true;
                            }
                        }
                    } else {
                        if (_dimse.DatasetFile != null) {
                            long pos = _dimse.DatasetFileStream.Position;
                            _dimse.DatasetFileStream.Seek(0, SeekOrigin.End);
                            _dimse.DatasetFileStream.Write(pdv.Value, 0, pdv.Value.Length);
                            _dimse.DatasetFileStream.Position = pos;
                        } else {
                            if (_dimse.DatasetData == null) {
                                _dimse.DatasetData = new ChunkStream();
                                _dimse.DatasetStream = _dimse.DatasetData;
                            }
                            _dimse.DatasetData.AddChunk(pdv.Value);
                        }

                        _dimse.Progress.BytesTransfered += pdv.Value.Length;
                        if (!EnableStreamParse)
                            _dimse.Progress.EstimatedDatasetLength += pdv.Value.Length;

                        if (_dimse.Dataset == null) {
                            DicomTransferSyntax ts = _assoc.GetAcceptedTransferSyntax(pdv.PCID);
                            _dimse.Dataset = new DcmDataset(ts);
                        }

                        if ((EnableStreamParse && !_dimse.Dataset.InternalTransferSyntax.IsDeflate) || pdv.IsLastFragment) {
                            if (_dimse.DatasetReader == null) {
                                if (_dimse.Dataset.InternalTransferSyntax.IsDeflate) {
                                    // DicomStreamReader needs a seekable stream
                                    MemoryStream ms = StreamUtility.Deflate(_dimse.DatasetStream, false);
                                    _dimse.DatasetReader = new DicomStreamReader(ms);
                                } else
                                    _dimse.DatasetReader = new DicomStreamReader(_dimse.DatasetStream);
                                _dimse.DatasetReader.Dataset = _dimse.Dataset;
                            }

                            long remaining = _dimse.DatasetReader.BytesRemaining + pdv.Value.Length;
                            if (remaining >= _dimse.DatasetReader.BytesNeeded || pdv.IsLastFragment) {
                                if (_dimse.DatasetReader.Read(null, DicomReadOptions.Default) != DicomReadStatus.Success && pdv.IsLastFragment) {
                                    // ???
                                }

                                _dimse.Progress.EstimatedDatasetLength = (int)_dimse.DatasetReader.BytesEstimated;
                            }
                        }

                        if (pdv.IsLastFragment) {
                            _dimse.Close();

                            if (ReloadFromFile && !String.IsNullOrEmpty(_dimse.DatasetFile)) {
                                DicomFileFormat ff = new DicomFileFormat();
                                ff.Load(_dimse.DatasetFile, DicomReadOptions.DefaultWithoutDeferredLoading);

                                _dimse.Dataset = ff.Dataset;
                            }

                            if (_dimse.IsNewDimse)
                                OnReceiveDimseBegin(pcid, _dimse.Command, _dimse.Dataset, _dimse.Progress);
                            OnReceiveDimseProgress(pcid, _dimse.Command, _dimse.Dataset, _dimse.Progress);
                            OnReceiveDimse(pcid, _dimse.Command, _dimse.Dataset, _dimse.Progress);
                            ProcessDimse(pcid);
                            _dimse = null;
                            return true;
                        }
                    }
                }

                if (_dimse.IsNewDimse) {
                    OnReceiveDimseBegin(pcid, _dimse.Command, _dimse.Dataset, _dimse.Progress);
                    _dimse.IsNewDimse = false;
                } else {
                    OnReceiveDimseProgress(pcid, _dimse.Command, _dimse.Dataset, _dimse.Progress);
                }

                return true;
            } catch (Exception e) {
            #if DEBUG
                Log.Error("{0} -> Error reading DIMSE: {1}", LogID, e.ToString());
            #else
                Log.Error("{0} -> Error reading DIMSE: {1}", LogID, e.ToString());//e.Message);
            #endif
                _dimse.Abort();
                _dimse = null;
                return false;
            }
        }