create 3D image from coordinates
16 views (last 30 days)
I have got a 3D nifti image (img) that is a breast MRI. For the same image, there are NX3 coordinates (x,y,z) in the file coordsV2f. I need to substitute these coordinates to new values that are in the file pred.txt, in order to highlight some pxels and show them marked in the original 3D image. It works and now I have my zeros image with some highlighted pixel. How can I visualize the marked pixels on the original one (img) and scroll down the slices?
many thanks !!!
img = niftiread([fCompletePath '_image']);
x = RCS(:,1);
y = RCS(:,2);
z = RCS(:,3);
new_img = zeros(size(img));
k = 1;
for slice = 1 : length(z)
f = z(slice); %3rd dimension of RCS
newX= (x(k)); % get x
newY= (y(k)); % get y
new_img(newX,newY,f) = pred(k); %assign new value on a zeros image
k = k+1;
save new_img %save in workspace
niftiwrite(new_img, [fName '_prediction.nii.gz']); %save as .nii
Image Analyst on 24 Dec 2019
You can extract each slice of the image in a for loop and call imshow(), then call hold on, and plot() to plot a red spot (or whatever) over the changed pixels. Then at the bottom of the loop call questdlg() to let the user see the image and spots before proceeding with the next image.