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 6

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 6

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 6

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 6

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 6

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 6

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.

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

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com