How to save an average voxel values from multiple ROIs in a dicom slice?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to extract an average voxel values form each ROIs drawn on dicom slice. How can I do that? Using the following code I read the dicom slice, then draw 4 rois, now I want to save the ROI intensty statistics such as the average, minimum, maximum and standard deviation in voxel values within the ROI. How to complete the code below to get that done?
close all; clear; clc;
%% load and read dicom slice
info_ct = dicominfo('37.100.dcm');
Height = info_ct.Height;
Width = info_ct.Width;
slope = info_ct.RescaleSlope;
intercept = info_ct.RescaleIntercept;
ct_matrix = slope * double(dicomread(info_ct)) + intercept; % respect slope and intercept
%% Now, draw 4 ROIs on dicom slice
figure
N = 4;
I = imshow(ct_matrix(:,:,1), [-800 1000]);
% Define the Region of Interest
e = drawcircle(gca, 'Label', '1'); % draw 1 ROI
f = drawcircle(gca, 'Label', '2'); % draw 2 ROI
g = drawcircle(gca, 'Label', '3'); % draw 3 ROI
h = drawcircle(gca, 'Label', '4'); % draw 4 ROI
% Create a Mask
BW1 = createMask(e, I); % 1s at ROI and 0s everywhere
BW1 = double(BW1);
BW2 = createMask(f, I);
BW2 = double(BW2);
BW3 = createMask(g, I);
BW3 = double(BW3);
BW4 = createMask(h, I);
BW4 = double(BW4);
....
0 comentarios
Respuesta aceptada
Rik
el 16 de Mzo. de 2020
Editada: Rik
el 17 de Mzo. de 2020
BW1 = createMask(e, I);
Data=I(BW1);
Now you can calculate the statistics you need.
I would suggest using a struct array:
% Generate example data (yes, it is an MRI, but the code works)
D=load('mri');D=double(D.D);
ct_matrix= ( D/max(D(:)) *1800 ) -800;
f=figure(1);clf(f)
N = 4;
IM=ct_matrix(:,:,1);
I = imshow(IM, [-800 1000]);
set(f,'WindowState','maximized')
% Define the Region of Interests
H=cell(N,1);
for n = 1:N
H{n} = drawcircle(gca, 'FaceAlpha', 0.05, 'Label', sprintf('%d',n));
end
% Extract parameters
output=struct;
for n = 1:N
BW = createMask(H{n}, IM);
data = IM(BW);
%or:
% BW = createMask(H{n}, I.CData);
% data = I.CData(BW);
output(n).mean = mean(data);
output(n).SD = std(data);
end
7 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre DICOM Format en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!