Path: news.mathworks.com!not-for-mail
From: Jeff Mather <jeff.mather@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: dicominfo bug?
Date: Thu, 04 Jan 2007 13:05:35 -0500
Organization: The MathWorks, Inc.
Lines: 40
Message-ID: <enjflf$646$1@fred.mathworks.com>
References: <ef4a04a.-1@webcrossing.raydaftYaTP>
NNTP-Posting-Host: matherj.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1167933935 6278 144.212.219.188 (4 Jan 2007 18:05:35 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 4 Jan 2007 18:05:35 +0000 (UTC)
User-Agent: Thunderbird 1.5.0.8 (Windows/20061025)
In-Reply-To: <ef4a04a.-1@webcrossing.raydaftYaTP>
Xref: news.mathworks.com comp.soft-sys.matlab:386036



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