【发布时间】:2013-08-26 23:43:37
【问题描述】:
我有一个解剖体积图像 (B),它是一个索引图像 i,j,k:
B(1,1,1)=0 %for example.
该文件仅包含 0 和 1。
我可以用等值面正确地可视化它:
isosurface(B);
我想在 j 中的某个坐标处切割体积(每个体积都不同)。
问题是体积是垂直倾斜的,它可能有 45% 度,所以切割不会跟随解剖体积。
我想为数据获取一个新的正交坐标系,因此我在坐标 j 中的平面将以更准确的方式切割解剖体积。
有人告诉我用 PCA 来做,但我不知道如何做,阅读帮助页面也没有帮助。欢迎任何方向!
编辑: 我一直在遵循建议,现在我得到了一个以零为中心的新卷,但我认为轴没有按照应有的解剖图像。这些是前后图像:
这是我用来创建图像的代码(我从答案和 cmets 的想法中获取了一些代码):
clear all; close all; clc;
hippo3d = MRIread('lh_hippo.mgz');
vol = hippo3d.vol;
[I J K] = size(vol);
figure;
isosurface(vol);
% customize view and color-mapping of original volume
daspect([1,1,1])
axis tight vis3d;
camlight; lighting gouraud
camproj perspective
colormap(flipud(jet(16))); caxis([0 1]); colorbar
xlabel x; ylabel y; zlabel z
box on
% create the 2D data matrix
a = 0;
for i=1:K
for j=1:J
for k=1:I
a = a + 1;
x(a) = i;
y(a) = j;
z(a) = k;
v(a) = vol(k, j, i);
end
end
end
[COEFF SCORE] = princomp([x; y; z; v]');
% check that we get exactly the same image when going back
figure;
atzera = reshape(v, I, J, K);
isosurface(atzera);
% customize view and color-mapping for the check image
daspect([1,1,1])
axis tight vis3d;
camlight; lighting gouraud
camproj perspective
colormap(flipud(jet(16))); caxis([0 1]); colorbar
xlabel x; ylabel y; zlabel z
box on
% Convert all columns from SCORE
xx = reshape(SCORE(:,1), I, J, K);
yy = reshape(SCORE(:,2), I, J, K);
zz = reshape(SCORE(:,3), I, J, K);
vv = reshape(SCORE(:,4), I, J, K);
% prepare figure
%clf
figure;
set(gcf, 'Renderer','zbuffer')
% render isosurface at level=0.5 as a wire-frame
isoval = 0.5;
[pf,pv] = isosurface(xx, yy, zz, vv, isoval);
p = patch('Faces',pf, 'Vertices',pv, 'FaceColor','none', 'EdgeColor',[0.5 1 0.5]);
% customize view and color-mapping
daspect([1,1,1])
axis tight vis3d;view(-45,35);
camlight; lighting gouraud
camproj perspective
colormap(flipud(jet(16))); caxis([0 1]); colorbar
xlabel x; ylabel y; zlabel z
box on
任何人都可以提供一个提示可能发生的事情吗?看来问题可能出在 reshape 命令上,是否有可能我取消了之前完成的工作?
【问题讨论】:
-
问题在于您的数据表示。尝试做
newRepresentation = [1,1,1,0;1,1,2,0;1,1,3,1;…;1,1,nk,0;1,2,1,0;…;1,nj,1,1;…;ni,nj,nk,0]并对其应用内置pca。您的新表示将出现在该函数返回的score变量中。 -
3D 图像是 4D 观察数据数组。
-
@Werner 谢谢!我会尝试实现它。我还不能投票,这是我的第一篇文章!
-
没关系,这只是一个想法,我仍然怀疑你将如何继续这种方法,但我还有许多其他问题要解决......只是想帮助 x)
标签: matlab pca coordinate-transformation volume-rendering