Thread Subject: dicominfo bug?

Subject: dicominfo bug?

From: Ofek Shilon

Date: 2 Jan, 2007 12:54:03

Message: 1 of 2

Note to dicom function users (and authors?)

I recommend the following modification to dicominfo code
go to the function getItemNames on line 554 of dicominfo,
and replace it with the following code:

%%%%%%%%% start snipping:
function itemNames = getItemNames(numberOfItems)

% Create a cell array of item names, which can be quickly used.
persistent namesCell maxItemsPreStored
if (isempty(namesCell))
    
    maxItemsPreStored = 300;
    namesCell = cell(1, maxItemsPreStored);
    for idx = 1:maxItemsPreStored
        namesCell{idx} = sprintf('Item_%d', idx);
    end
      
end

% Return the first n item names.
if numberOfItems <= maxItemsPreStored
    itemNames = namesCell(1:numberOfItems);
else % slow but necessary fallback
    itemNames = cell(1, numberOfItems);
    for idx = 1:numberOfItems
        itemNames{idx} = sprintf('Item_%d', idx);
    end
end
%%%%%%%%% snip end

the original code lacks a fallback for the case of more than 300
items - which is not too rare, e.g. in DICOMDIR files.

Ofek

Subject: dicominfo bug?

From: Jeff Mather

Date: 4 Jan, 2007 13:05:35

Message: 2 of 2

Ofek Shilon wrote:
>
> the original code lacks a fallback for the case of more than 300
> items - which is not too rare, e.g. in DICOMDIR files.

We just recently fixed this in our code base. A fix will appear in a
future release of the Image Processing Toolbox. The attached code
should perform a little better than the previous suggestion.

Jeff Mather
Image Processing Group
The MathWorks, Inc.


%% In toolbox/images/medformats/dicominfo.m

function itemNames = getItemNames(numberOfItems)

% Create a cell array of item names, which can be quickly used.
persistent namesCell
if (isempty(namesCell))
     namesCell = generateItemNames(50);
end

% If the number of cached names is too small, expand it and recache.
if (numberOfItems > numel(namesCell))
     namesCell = generateItemNames(numberOfItems);
end

% Return the first n item names.
itemNames = namesCell(1:numberOfItems);



function namesCell = generateItemNames(numberOfItems)

namesCell = cell(1, numberOfItems);
for idx = 1:numberOfItems
     namesCell{idx} = sprintf('Item_%d', idx);
end

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