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 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.
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.