Hello! I want to know what kind of coordinates are the individual MRI coordinates, SCS or MRI ?
I write the following code to get the mask of sources using the MRI coordinates, but I got the mask.nii empty, I want to know why is it, thank you!
%back to image space of Original T1
clear all;
nii2 = load_untouch_nii('sub-jimingda_T1w.nii.gz');
load('P_mri.mat');
coord2 = P_mri*1000;
R = [nii2.hdr.hist.srow_x(1:3); nii2.hdr.hist.srow_y(1:3); nii2.hdr.hist.srow_z(1:3)];
T = [nii2.hdr.hist.srow_x(4); nii2.hdr.hist.srow_y(4); nii2.hdr.hist.srow_z(4)];
Rinv = inv(R);
for i = 1:3
coord2(:,i) = coord2(:,i) - T(i);
end;
coord2 = coord2*Rinv';
for i = 1:3
coord2(:,i) = coord2(:,i)./nii2.hdr.dime.pixdim(i+1);
end;
sizeImg = size(nii2.img);
maskImg = zeros(sizeImg(1), sizeImg(2), sizeImg(3));
y = round(coord2);
[maskImg(y(:,1), y(:,2), y(:,3))] = 1;
nii2.img=maskImg;
save_untouch_nii(nii2,'P_mri.nii.gz');
This is the mask.nii I got: