extract rescale slope value
15 views (last 30 days)
Show older comments
mohd akmal masud
on 19 Feb 2018
Commented: mohd akmal masud
on 24 Mar 2019
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
Walter Roberson
on 19 Feb 2018
for K = 135 : -1 : 1
petname = sprintf('PET_I1001_PT%03d.dcm', K);
info(K) = dicominfo(petname);
end
rescale_slopes = [info.RescaleSlope];
If, for some reason you need to find the non-zero entries, then
slice_idx = find(rescale_slopes);
Note: the above code has a limitation that the dicominfo returned by each slice must have exactly the same set of fields. If that assumption is violated then the info(K) assignment will give you an error about assignment between dissimilar structures.
14 Comments
Walter Roberson
on 2 Nov 2018
If you have read in all of the values, then
rescale_slopes(20:31)
If for some reason you only want to read in a subset of the slices, then
slices_to_read = 20:31;
num_slices = length(slices_to_read);
for slice_idx = num_slices: -1 : 1
slice_number = slices_to_read(slice_idx);
petname = sprintf('PET_I1001_PT%03d.dcm', slice_number);
info(slice_idx) = dicominfo(petname);
if ~isfield(info(slice_idx), 'RescaleSlope') || isempty(info(slice_idx).RescaleSlope)
info(slice_idx).RescaleSlope = 1;
end
end
The looping from the last backwards towards the first is done for efficiency: it forces the last info() entry to be assigned to first, so afterwards it is not necessary to expand the info() struct the way it would be if you had not pre-allocated the info struct and you were looping forwards.
More Answers (1)
mohd akmal masud
on 8 Nov 2018
5 Comments
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.
See Also
Categories
Find more on Explore and Edit Images with Image Viewer App 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!