Octave crash when dicominfo some files

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Octave crash when dicominfo some files

soapkwan
My OS: Win 10
I had tried these combinations:
Octave 5.1 or 5.2
dicom 0.2.1 or dicom 0.3.0

For some dicom files, I can use dicomread, but when I use dicominfo, the
octave crash.
I can see the dicominfo does return something right before it crashes.
I am using 'factory' dictionary.

And the files can be read by other software (e.g. ImageJ).
I also have some dicom files which are working as expected.

Any guidance is welcome! Thx




--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Octave crash when dicominfo some files

soapkwan
I had tried on two different windows: 7 & 10
And both have the same behaviour.

What I do is simply:
pkg load dicom;
inf = dicominfo(filepath);


This is the file doesn't cause a crash:
83633438.83633438
<https://octave.1599824.n4.nabble.com/file/t373731/83633438.83633438>  
And This is one of the files cause a crash:
17.17 <https://octave.1599824.n4.nabble.com/file/t373731/17.17>  



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Re: Octave crash when dicominfo some files

John Donoghue-3
In reply to this post by soapkwan
On 4/15/20 1:55 AM, [hidden email] wrote:

> Message: 4
> Date: Tue, 14 Apr 2020 22:57:20 -0500 (CDT)
> From: soapkwan<[hidden email]>
> To:[hidden email]
> Subject: Re: Octave crash when dicominfo some files
> Message-ID:<[hidden email]>
> Content-Type: text/plain; charset=us-ascii
>
> I had tried on two different windows: 7 & 10
> And both have the same behaviour.
>
> What I do is simply:
> pkg load dicom;
> inf = dicominfo(filepath);
>
>
> This is the file doesn't cause a crash:
> 83633438.83633438
> <https://octave.1599824.n4.nabble.com/file/t373731/83633438.83633438>  
> And This is one of the files cause a crash:
> 17.17<https://octave.1599824.n4.nabble.com/file/t373731/17.17>  
>
>
It also does the same crash in linux.

The issue a empty sequence of items in the dicom file, which dicominfo
should probally be checking for but doesnt.


Changes in the source to (diff) fix the crash:


diff -r 6509b74e7d14 src/dicominfo.cpp
--- a/src/dicominfo.cpp Wed Apr 15 07:41:52 2020 -0400
+++ b/src/dicominfo.cpp Wed Apr 15 07:57:21 2020 -0400
@@ -394,7 +394,10 @@
         } else if (vr & gdcm::VR::SQ) {
                 if(chatty) octave_stdout << " reading sequence. "; //
\n provided in dumpSequence fn
                 gdcm::SmartPointer<gdcm::SequenceOfItems> sqi =
elem->GetValueAsSQ();
-               dumpSequence(ov, sqi, chatty, sequenceDepth+1);
+               if(sqi)
+                       dumpSequence(ov, sqi, chatty, sequenceDepth+1);
+               else
+                       *ov = octave_map();
         } else if (vr & gdcm::VR::AT) { // attribute tag
                 intNDArray<octave_uint16> uint16pair(dim_vector(1,2));
                 uint16_t *p=(uint16_t *)elem->GetByteValue()->GetPointer();





Reply | Threaded
Open this post in threaded view
|

Re: Re: Octave crash when dicominfo some files

soapkwan
The fix works beautifully.

All I need to do is to modify the "dicominfo.cpp" inside dicom-0.3.0.tar.gz.
Then, pkg install dicom_patched.tar.gz.

Thanks for your effort, John.




--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html