Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
A bug in dicomread.m

Subject: A bug in dicomread.m

From: dai zhengguo

Date: 25 Aug, 2010 10:29:05

Message: 1 of 7

I found a bug in dicomread.m in the line:756. I suggested that:
X = reshape(metadata.InstanceData(1:numPixels), metadata.Columns,... metadata.Rows, 1, metadata.NumberOfFrames)
should be replaced by
X = reshape(metadata.InstanceData,metadata.Columns,...
metadata.Rows, 1, metadata.NumberOfFrames).
It is clear that it is always set up a message 'out of memory' when you use a large dicom file if you do not change the code.
However, I am not clear that why should do this change.

Subject: A bug in dicomread.m

From: Oleg Komarov

Date: 25 Aug, 2010 12:46:04

Message: 2 of 7

"dai zhengguo" <zhgdai@126.com> wrote in message <i52r9h$l2e$1@fred.mathworks.com>...
> I found a bug in dicomread.m in the line:756. I suggested that:
> X = reshape(metadata.InstanceData(1:numPixels), metadata.Columns,... metadata.Rows, 1, metadata.NumberOfFrames)
> should be replaced by
> X = reshape(metadata.InstanceData,metadata.Columns,...
> metadata.Rows, 1, metadata.NumberOfFrames).
> It is clear that it is always set up a message 'out of memory' when you use a large dicom file if you do not change the code.
> However, I am not clear that why should do this change.

I don't think the out of memory problem is linked to the line you're pointing at.

Oleg

Subject: A bug in dicomread.m

From: Jeff Mather

Date: 25 Aug, 2010 14:39:19

Message: 3 of 7

"dai zhengguo" <zhgdai@126.com> wrote in message <i52r9h$l2e$1@fred.mathworks.com>...
> I found a bug in dicomread.m in the line:756. I suggested that:
> X = reshape(metadata.InstanceData(1:numPixels), metadata.Columns,... metadata.Rows, 1, metadata.NumberOfFrames)
> should be replaced by
> X = reshape(metadata.InstanceData,metadata.Columns,...
> metadata.Rows, 1, metadata.NumberOfFrames).
> It is clear that it is always set up a message 'out of memory' when you use a large dicom file if you do not change the code.
> However, I am not clear that why should do this change.

Are you actually seeing an out-of-memory error at that line? The line is written that way because some DICOM files incorrectly put more data into the image attribute than they should.

Jeff Mather
Image Processing Group

Subject: A bug in dicomread.m

From: dai zhengguo

Date: 27 Aug, 2010 03:24:05

Message: 4 of 7

"Jeff Mather" <jeff.mather@mathworks.com> wrote in message <i539un$lcr$1@fred.mathworks.com>...
> "dai zhengguo" <zhgdai@126.com> wrote in message <i52r9h$l2e$1@fred.mathworks.com>...
> > I found a bug in dicomread.m in the line:756. I suggested that:
> > X = reshape(metadata.InstanceData(1:numPixels), metadata.Columns,... metadata.Rows, 1, metadata.NumberOfFrames)
> > should be replaced by
> > X = reshape(metadata.InstanceData,metadata.Columns,...
> > metadata.Rows, 1, metadata.NumberOfFrames).
> > It is clear that it is always set up a message 'out of memory' when you use a large dicom file if you do not change the code.
> > However, I am not clear that why should do this change.
>
> Are you actually seeing an out-of-memory error at that line? The line is written that way because some DICOM files incorrectly put more data into the image attribute than they should.
>
> Jeff Mather
> Image Processing Group

Yes, I'm sure of this problem. Please get a large dicom which size is more than 150MB and try to use dicomread to read this dicom. You will find the same problem which is ' out of memory ' .

Subject: A bug in dicomread.m

From: dai zhengguo

Date: 27 Aug, 2010 05:48:20

Message: 5 of 7

"Oleg Komarov" <oleg.komarovRemove.this@hotmail.it> wrote in message <i533ac$spq$1@fred.mathworks.com>...
> "dai zhengguo" <zhgdai@126.com> wrote in message <i52r9h$l2e$1@fred.mathworks.com>...
> > I found a bug in dicomread.m in the line:756. I suggested that:
> > X = reshape(metadata.InstanceData(1:numPixels), metadata.Columns,... metadata.Rows, 1, metadata.NumberOfFrames)
> > should be replaced by
> > X = reshape(metadata.InstanceData,metadata.Columns,...
> > metadata.Rows, 1, metadata.NumberOfFrames).
> > It is clear that it is always set up a message 'out of memory' when you use a large dicom file if you do not change the code.
> > However, I am not clear that why should do this change.
>
> I don't think the out of memory problem is linked to the line you're pointing at.
>
> Oleg

You can check it out.

Subject: A bug in dicomread.m

From: Jeff Mather

Date: 27 Aug, 2010 17:06:06

Message: 6 of 7

> > Are you actually seeing an out-of-memory error at that line? The line is written that
> > way because some DICOM files incorrectly put more data into the image attribute than
> > they should.
> >
> > Jeff Mather
> > Image Processing Group
>
> Yes, I'm sure of this problem. Please get a large dicom which size is more than 150MB
> and try to use dicomread to read this dicom. You will find the same problem which is
> ' out of memory ' .

So we do actually have some test code that reads files that large -- larger, actually -- without encountering memory errors.

The prevalence of incorrect DICOM files that this is trying to work around is probably quite rare. It's worth putting a small check before the reshape code to decide whether to index the pixels, which creates a temporary memory allocation.

Jeff Mather
Image Processing Group
MathWorks

Subject: A bug in dicomread.m

From: Arso

Date: 8 Feb, 2012 09:42:10

Message: 7 of 7

"Jeff Mather" <jeff.mather@mathworks.com> wrote in message <i58r9t$p4m$1@fred.mathworks.com>...
> > > Are you actually seeing an out-of-memory error at that line? The line is written that
> > > way because some DICOM files incorrectly put more data into the image attribute than
> > > they should.
> > >
> > > Jeff Mather
> > > Image Processing Group
> >
> > Yes, I'm sure of this problem. Please get a large dicom which size is more than 150MB
> > and try to use dicomread to read this dicom. You will find the same problem which is
> > ' out of memory ' .
>
> So we do actually have some test code that reads files that large -- larger, actually -- without encountering memory errors.
>
> The prevalence of incorrect DICOM files that this is trying to work around is probably quite rare. It's worth putting a small check before the reshape code to decide whether to index the pixels, which creates a temporary memory allocation.
>
> Jeff Mather
> Image Processing Group
> MathWorks

I have the same problem with reading big DICOMS. Is there any solution or the problem is in dicoms?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us