From: "Ofek Shilon" <ofek@REMOVETHISananas-music.com>
Path: news.mathworks.com!newsfeed-00.mathworks.com!webcrossing
Newsgroups: comp.soft-sys.matlab
Subject: dicominfo bug?
Message-ID: <ef4a04a.-1@webcrossing.raydaftYaTP>
Date: Tue, 2 Jan 2007 12:54:03 -0500
Lines: 36
NNTP-Posting-Host: 88.155.46.127
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Xref: news.mathworks.com comp.soft-sys.matlab:385758



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