Thread Subject: Out of memory- Try to read dicom file

Subject: Out of memory- Try to read dicom file

From: merdim

Date: 20 Dec, 2006 12:53:53

Message: 1 of 7

Hi all,
I have a dicom file which is 258MB. When I try to read this file
using "dicomread" comand, matlab gives error "Out of memory ". I
increased virtual memory of windows but this did not work. Does
anyone have any idea how can I read the dicom file?
thank you

Subject: Out of memory- Try to read dicom file

From: Ofek Shilon

Date: 22 Dec, 2006 15:48:52

Message: 2 of 7

try and debug-step dicomread as you run it. where *exactly* does it
break? (step-in as needed)

 merdim wrote:
>
>
> Hi all,
> I have a dicom file which is 258MB. When I try to read this file
> using "dicomread" comand, matlab gives error "Out of memory ". I
> increased virtual memory of windows but this did not work. Does
> anyone have any idea how can I read the dicom file?
> thank you

Subject: Out of memory- Try to read dicom file

From: merdim

Date: 23 Dec, 2006 08:47:48

Message: 3 of 7

Here is the error massage:

??? Out of memory. Type HELP MEMORY for your options.

Error in ==> dicomread>processRawPixels at 657
  X = reshape(metadata.InstanceData(1:numPixels), metadata.Columns,
...

Error in ==> dicomread>newDicomread at 222
  X = processRawPixels(metadata);

Error in ==> dicomread at 82
  [X, map, alpha, overlays] = newDicomread(msgname, varargin{:});
 I use matlab version of 7.0.4.365 (R14) Service Pack 2
 
Ofek Shilon wrote:
>
>
> try and debug-step dicomread as you run it. where *exactly* does it
> break? (step-in as needed)
>
> merdim wrote:
>>
>>
>> Hi all,
>> I have a dicom file which is 258MB. When I try to read this
file
>> using "dicomread" comand, matlab gives error "Out of memory ".
I
>> increased virtual memory of windows but this did not work. Does
>> anyone have any idea how can I read the dicom file?
>> thank you

Subject: Out of memory- Try to read dicom file

From: Ofek Shilon

Date: 2 Jan, 2007 13:01:52

Message: 4 of 7

what happens if you replace lines 657-658 with :

X = metadata.InstanceData; % temp duplicity
rmfield(metadata,'InstanceData'); % remove duplicity
X=reshape(X, metadata.Columns, metadata.Rows, 1, ...
          metadata.NumberOfFrames);

does it break in the first line? (true memory problem)
or afterwards? (some reshape-related issue)

Ofek

 merdim wrote:
>
>
> Here is the error massage:
>
> ??? Out of memory. Type HELP MEMORY for your options.
>
> Error in ==> dicomread>processRawPixels at 657
> X = reshape(metadata.InstanceData(1:numPixels), metadata.Columns,
> ...
>
> Error in ==> dicomread>newDicomread at 222
> X = processRawPixels(metadata);
>
> Error in ==> dicomread at 82
> [X, map, alpha, overlays] = newDicomread(msgname, varargin{:});
> I use matlab version of 7.0.4.365 (R14) Service Pack 2
>
> Ofek Shilon wrote:
>>
>>
>> try and debug-step dicomread as you run it. where *exactly*
does
> it
>> break? (step-in as needed)
>>
>> merdim wrote:
>>>
>>>
>>> Hi all,
>>> I have a dicom file which is 258MB. When I try to read this
> file
>>> using "dicomread" comand, matlab gives error "Out of memory
> ".
> I
>>> increased virtual memory of windows but this did not work.
> Does
>>> anyone have any idea how can I read the dicom file?
>>> thank you

Subject: Out of memory- Try to read dicom file

From: Matt Latourette

Date: 4 Jan, 2007 12:13:04

Message: 5 of 7

merdim wrote:
>
>
> Hi all,
> I have a dicom file which is 258MB. When I try to read this file
> using "dicomread" comand, matlab gives error "Out of memory ". I
> increased virtual memory of windows but this did not work. Does
> anyone have any idea how can I read the dicom file?
> thank you
  
258MB is really large for a single DICOM image, no matter what the
modality is. I'm guessing that your data is not a single image, but
rather many images stored as one file using one of the multiframe SOP
classes and that may be related to the "out of memory" problem. I
have seen a few situations before where I got an "out of memory"
message from MATLAB when a lack of memory was not the real problem.
In some circumstances, "out of memory" can really mean "the catch-all
error message you get when something has gone wrong and MATLAB can't
figure out what to tell you". I don't know for sure whether or not
multiframe data is supported by MATLAB, but it is quite possible that
it may not be. Have you tried setting "dbstop if error" and then
running the program so you can examine your variables after the out
of memory error occurs and execution halts?

-Matt

Subject: Out of memory- Try to read dicom file

From: Jeff Mather

Date: 4 Jan, 2007 13:48:32

Message: 6 of 7

merdim wrote:
 >>
 >> Here is the error massage:
 >>
 >> ??? Out of memory. Type HELP MEMORY for your options.
 >>
 >> Error in ==> dicomread>processRawPixels at 657
 >> X = reshape(metadata.InstanceData(1:numPixels), metadata.Columns,
 >> ...
 >>
 >> Error in ==> dicomread>newDicomread at 222
 >> X = processRawPixels(metadata);
 >>
 >> Error in ==> dicomread at 82
 >> [X, map, alpha, overlays] = newDicomread(msgname, varargin{:});
 >> I use matlab version of 7.0.4.365 (R14) Service Pack 2
 >>

Ofek Shilon wrote:
> what happens if you replace lines 657-658 with :
>
> X = metadata.InstanceData; % temp duplicity
> rmfield(metadata,'InstanceData'); % remove duplicity
> X=reshape(X, metadata.Columns, metadata.Rows, 1, ...
> metadata.NumberOfFrames);


It's likely that you need some combination of the original
implementation and Ofek's suggestion. In particular, the code may need
to index into InstanceData. (Certain naughty "DICOM" file writers put
too much data into the pixel data.)

It's entirely possible that the combination of indexing into the array
and performing the reshape is overwhelming your system's memory. The
indexing makes a copy of the data and reshaping makes at least one more.
  Add that to the original InstanceData field and you're talking about
258*3 MB or 258*4 MB required for that line. Consider splitting the
line like this:

   if (numel(metadata.InstanceData) > numPixels)
       metadata.InstanceData((numPixels+1):end) = [];
   elseif (numel(metadata.InstanceData) < numPixels)
       error('Not enough pixel data')
   end

   X = reshape(metadata.InstanceData, ...
               metadata.Columns, ...
               metadata.Rows, ...
               1, ...
               metadata.NumberOfFrames);

Jeff Mather
Image Processing Group
The MathWorks, Inc.

Subject: Out of memory- Try to read dicom file

From: Arso

Date: 8 Feb, 2012 12:45:16

Message: 7 of 7

Hi there :)

same problem here, i can read info of dicom but not frames(dicom over 1000 frames)

from my experience problem is memory. To read huge dicoms matlab need more memory than you have(i have 2GB).

Possible solutions are:
-use 64bit version
-increase ram memory
-use external software to divide dicom at many images(jpgs). Then read frames as jpgs from folder instead of using dicomread('filename', 'frames', [vector frames]). I use Sante Dicom viewer it is free open source.

If someone have better solution of problem please share :)

greetings,

Arso.

merdim <merdim06@yahoo.com> wrote in message <ef4915a.-1@webcrossing.raydaftYaTP>...
> Hi all,
> I have a dicom file which is 258MB. When I try to read this file
> using "dicomread" comand, matlab gives error "Out of memory ". I
> increased virtual memory of windows but this did not work. Does
> anyone have any idea how can I read the dicom file?
> thank you

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com