extract rescale slope value
Show older comments
Hi all,
I want to extract the RescaleSlope value from dicominfo for each slice. But I have 135 slice images. This is my code to extract RescaleSlope. But still failed.
P = zeros(256, 256, 135);
for K = 1 : 135
petname = sprintf('PET_I1001_PT%03d.dcm', K);
P(:,:,K) = dicominfo(petname);
end
info=dicominfo(P(:,:,K));
[r,c,slice] = findND (info.RescaleSlope);
Anyone who can help me solve this problem???
Accepted Answer
More Answers (1)
mohd akmal masud
on 8 Nov 2018
5 Comments
mohd akmal masud
on 8 Mar 2019
Walter Roberson
on 8 Mar 2019
projectdir = 'I:\12. FIZIK NUKLEAR\Jadual Bulanan Kerja PSF 2018\75ct';
numslices = 75; %assume this
rawslices = cell(numslices, 1);
slices = cell(numslices, 1);
for K = numslices : -1 : 1
petname = fullfile(projectdir, sprintf('ct%d.dcm', K));
thisinfo = dicominfo(petname);
fn = fieldnames(thisinfo);
for N = 1 : length(fn)
thisfield = fn{N};
info(K).(thisfield) = thisinfo.(thisfield);
end
this_slice = dicomread(petname);
if ~isfield(info(K), 'RescaleSlope') || isempty(info(K).RescaleSlope)
info(K).RescaleSlope = 1;
end
if ~isfield(info(K), 'RescaleIntercept') || isempty(info(K).RescaleIntercept)
info(K).RescaleIntercept = 0;
end
rawslices{K} = this_slice;
slices{K} = double(this_slice) * info(K).RescaleSlope + info(K).RescaleIntercept;
end
Now rawslices is a cell array containing the data as read in from the file (probably int16 datatype), and slices is a cell array containing the data rescaled, as double datatype.
You do not need to do any of that post-processing to find empty values because it is already done inside the reading loop: the isempty() causes empty values to be replaced with known values.
mohd akmal masud
on 9 Mar 2019
Walter Roberson
on 9 Mar 2019
What extension does it have?
This is a Question about DICOM, dealing with the DICOM-specific matter of RescaleSlope and RescaleIntercept. If you are not using DICOM images then your question should have been posted separately and should have included detail of what you were trying to achieve.
mohd akmal masud
on 24 Mar 2019
Categories
Find more on Convert Image Type in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!