필터 지우기
필터 지우기

Replace unwanted voxels with nearest neighbor labeled values

조회 수: 5 (최근 30일)
banikr
banikr 2020년 5월 3일
댓글: darova 2020년 5월 15일
Hello Matlab experts,
I am trying to remove unwanted electrode voxels from 3D labeled images by replacing the electrodes with nearest skin, bone or other labeled tissue voxels. I experimented with the function here: https://www.mathworks.com/matlabcentral/fileexchange/24723-nearest_neighbour_3d
But that didn't generate the result I expected. The function takes given points(electrodes) and their minimum distant nearest candidate points(other tissue voxels). It considers Euclidean distance.
%sz is the size of the 3D label=> lab
[cxx, cyy, czz] = ind2sub(sz, find(lab==10|lab==4)); % candidate points from either skin(10) or bones(4) or other tissues
[gxx, gyy, gzz] = ind2sub(sz, find(lab==20)); % given poinst from electrodes(20)
[nxx, nyy, nzz] = ind2sub(sz, compute_nearest_neighbour([cxx,cyy,czz], [gxx,gyy,gzz])); % nearest points
lab(gxx,gyy,gzz) = lab(nxx,nyy,nzz);
Any other ways?
Thanks in advance.

채택된 답변

darova
darova 2020년 5월 15일
Solution
lab = lab_superior; % the data shared
elec = zeros(size(lab));
elec(lab==20)=1; % select electrodes
BB = lab;
BB(BB==20) = 0; % remove electrodes
nb = unique(BB); % unique regions
nb(nb==0) = []; % remove '0' from list of regions
[EE,ne] = bwlabeln(elec);
II = BB*0;
for i = 1:ne
E1 = EE == i;
E2 = imdilate(E1,strel('sphere', 4));
for j = nb(:)'
B1 = BB == j; % select one region
tmp = B1 & E2; % compare electrode and region
if any(tmp(:)) % if region and electrode are close
II = II+j*E1;
break
end
end
end
A = II + BB;
Original After processing

추가 답변 (1개)

Image Analyst
Image Analyst 2020년 5월 3일
The position of x and y are swapped, which makes a difference if the volume is not equal lengths in the x and y direction. Remember ind2sub() returns (row, column) which is NOT (x, y) -- it's (y, x).
  댓글 수: 36
banikr
banikr 2020년 5월 15일
@darova,
I think it worked.
The electrode voxels were replaced with mostly skin(brown) voxels.
Thanks for the support!
darova
darova 2020년 5월 15일
Can you accept the answer?

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

Community Treasure Hunt

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

Start Hunting!

Translated by