extract rescale slope value

10 ビュー (過去 30 日間)
mohd akmal masud
mohd akmal masud 2018 年 2 月 19 日
コメント済み: mohd akmal masud 2019 年 3 月 24 日
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???
  2 件のコメント
Image Analyst
Image Analyst 2018 年 2 月 19 日
mohd akmal masud
mohd akmal masud 2018 年 2 月 19 日
Thank you Image Analyst

サインインしてコメントする。

採用された回答

Walter Roberson
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
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.
mohd akmal masud
mohd akmal masud 2019 年 3 月 24 日
Sorry all, another question i have but i wrote at this space. please help me
Dear all,
this is my code to view CT image by slice
P = zeros(256, 256, 72);
for K = 1 : 72
petname = sprintf('I4%03d.dcm', K);
P(:,:,K) = dicomread(petname);
end
imshow3D(P)
then, this is my code for view SPECT image by slice,
Noted: all my 42 slice SPECT image stored in one file.
[spect map]=dicomread('128x128');
info = dicominfo('128x128');
gp=info.SliceThickness;
spect=(squeeze(spect));%smooth3
aa=size(spect);aa=aa(3);
imshow3D(spect);
Anybody can help me to fuse both SPECT and CT images for all slice?

サインインしてコメントする。

その他の回答 (1 件)

mohd akmal masud
mohd akmal masud 2018 年 11 月 8 日
Hi Walter
I Have This Code
P = zeros(256, 256, 47);
for K = 20 : 31
petname = sprintf('PETWB001_PT%03d.dcm', K);
P(:,:,K) = dicomread(petname);
end
numOfPixels = numel(P(:));
max(P(:));
sum(P(:));
mask = (P >= 20000 & P <= 32767);
numPixelsInRange = sum(mask(:));
sum(P(P>=20000 & P<=32767));
[r,c,slice] = findND(P >= 20000 & P <= 32767);
val=P(P(:)>=20000 & P(:)<=32767 )
how to multiply the val with RescaleSlope itself?
i have try the code you given like below. its work, but separately. So have to multiply manually. So how to me make automatically?
for K = 47 : -1 : 1
petname = sprintf('PETWB001_PT%03d.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);
slices{K} = this_slice;
if ~isfield(info(K), 'RescaleSlope') || isempty(info(K).RescaleSlope)
info(K).RescaleSlope = 1;
end
end
rescale_slopes = {info.RescaleSlope};
mask = cellfun(@isempty, rescale_slopes);
rescale_slopes(mask) = {0}; %set missing entries to 0
rescale_slopes = cell2mat(rescale_slopes);
inrange_mask = cellfun(@(M) any(M(:) >= 25000 & M(:) <= 32767), slices);
idx_of_inrange = find(inrange_mask);
rescale_slope_of_inrange = rescale_slopes(20:31)
  5 件のコメント
Walter Roberson
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.
mohd akmal masud
mohd akmal masud 2019 年 3 月 24 日
Sorry all, another question i have but i wrote at this space. please help me
Dear all,
this is my code to view CT image by slice
P = zeros(256, 256, 72);
for K = 1 : 72
petname = sprintf('I4%03d.dcm', K);
P(:,:,K) = dicomread(petname);
end
imshow3D(P)
then, this is my code for view SPECT image by slice,
Noted: all my 42 slice SPECT image stored in one file.
[spect map]=dicomread('128x128');
info = dicominfo('128x128');
gp=info.SliceThickness;
spect=(squeeze(spect));%smooth3
aa=size(spect);aa=aa(3);
imshow3D(spect);
Anybody can help me to fuse both SPECT and CT images for all slice?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeExplore and Edit Images with Image Viewer App についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by