extract rescale slope value
조회 수: 10 (최근 30일)
이전 댓글 표시
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???
채택된 답변
Walter Roberson
2018년 2월 19일
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
Walter Roberson
2018년 11월 2일
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.
추가 답변 (1개)
mohd akmal masud
2018년 11월 8일
댓글 수: 5
Walter Roberson
2019년 3월 9일
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!