How to get the intensity values (data stored) that is stored in the voxels (3D image) at the certain distances from the origin of the sphere?

조회 수: 3 (최근 30일)
Hello, I have a 3D medical image with data values stored in its each voxel. I would like to pull out the data values of image at certain radial distances. The origin of my image is (0, 0, 0) and radius of the sphere is 20 mm. I would like to generate 19 concentric shells of equal thickness 1 mm (so total is 20 mm) in between center of sphere and its surface. At each concentric shell, I am interested to extract the value of the data stored in 3D image. How to write simple Matlab code for this situation? Has anyone done this before? Please provide me some ideas and suggestions, may be a little piece of code as well.
  댓글 수: 3
blues
blues 2018년 8월 31일
편집: Walter Roberson 2018년 9월 1일
Thank you Walter for your reply. Image is in MetaImage (.mhd and .raw) format. The header files looks as follows:
ObjectType = Image
NDims = 3
BinaryData = True
BinaryDataByteOrderMSB = False
CompressedData = False
TransformMatrix = 1 0 0 0 1 0 0 0 1
Offset = -0.156024 -0.156024 -0.156024
CenterOfRotation = 0 0 0
ElementSpacing = 0.034672 0.034672 0.034672
DimSize = 10 10 10
AnatomicalOrientation = ???
ElementType = MET_FLOAT
ElementDataFile = dose1e6events-Dose.raw
Walter Roberson
Walter Roberson 2018년 9월 1일
It looks like the ElementSpacing has the relevant information about pixel sizes.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 9월 1일
filename = ...;
info = mha_readheader(filename);
V = mha_read_volume(info);
spx = info.ElementSpacing(1);
spy = info.ElementSpacing(2);
spz = info.ElementSpacing(3);
%careful, first dimension is y not x.
sx = size(V,2);
sy = size(V,1);
sz = size(V,3);
cx = sx/2; cy = sy/2; cz = sz/2;
xv = ((1:sx) - cx) * spx;
yv = ((1:sy) - cy) * spy;
zv = ((1:sz) - cz) * spz;
[X, Y, Z] = ndgrid(xv, yv, zv);
D = sqrt(X.^2 + Y.^2 + Z.^2);
rvals = 0 : 19;
rthick = 1;
Nr = length(rvals);
shells = cell(Nr, 2);
for ridx = 1 : Nr
r = rvals(ridx);
mask = (D >= r & D < r+thick);
shells{ridx, 2} = mask;
shells{ridx, 1} = V(mask);
end
Now the first column of the cell array shells contain the extracted data values, and the second column contains the mask of locations that were extracted (in case you need it later.)
  댓글 수: 6
blues
blues 2018년 9월 2일
This avgpixelvals is just the mean values of pixel data stored in whole sphere, not at each concentric shells, right?
But I want to extract average pixel values at each concentric shells. In brief; average pixel values of data in a spherical shell of radius 1 mm, average pixel (it should be cumulated value) values of data in a spherical shell of radius 2 mm and so on, up to 20 mm. Hope I describe my question clearly.
Thank you very much for your great help.
Walter Roberson
Walter Roberson 2018년 9월 2일
No, avgpixelvals is the mean for each concentric shell. shells is a cell array in which the first column contains only values that lie within the particular concentric sphere for that one radius.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

blues
blues 2018년 9월 3일
One more baby query: my avgpixelvals min and max values are 5*10^-11 and 8*10^-8 (in y-axis), so I tried to set axis([0 120 5.^(-11) 8.^(-8)]); but this is not working. How to set this y-axis?
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 9월 3일
Your graph appears to show a y value peaking about 8.4*10^-8
Anyhow, you used the wrong numeric syntax
axis([0 120 5E-11 8E-8])
or
axis([0 120 5*10.^(-11) 8*10.^(-8)]);
With 5E-11 being only about 1/1600 of 8E-8, you should expect that MATLAB will probably round the lower bound to 0. After all, you would need your y resolution to be at least 1600 for it to make a 1 pixel difference.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by