我有一个解剖体积图像(B),它是一个索引图像I,J,K:PCA的3D图像上,以获得3个主轴
B(1,1,1)=0 %for example.
的文件只包含0和1。
我可以与等值面正确地进行可视化: isosurface(B);
我想切断以J一些坐标的体积(它是为每个卷不同)。
问题是体积是垂直倾斜的,它可能有45%的度数,所以切口不会跟随解剖体积。
我想为数据获得一个新的正交坐标系,所以我的坐标系j中的平面将以更准确的方式切割解剖体积。
我被告知要用PCA来做,但我不知道如何去做,并且阅读帮助页面并没有帮助。任何方向都将受到欢迎!
编辑: 我一直在遵循这些建议,现在我得到了一个新的体积,以零为中心,但我认为这些轴并不像他们应该那样遵循解剖图像。这些都是前置和后置图片:
这是我用来创建图像的代码(我从答案的一些代码和注释的想法):
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
任何人都可以提供什么可能发生的提示吗?看起来问题可能是重塑命令,是否有可能取消以前完成的工作?
问题在于你的数据表示。试着做'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]'并应用builtin'pca'。你的新表示将在该函数返回的'score'变量中出现。 – Werner
3D图像是观察的4D数据阵列。 – Werner
@Werner谢谢你!我会尽力实施它。我还无法支持任何东西,这是我的第一篇文章! – gari