Creating intermediate slices in a 3D MRI volume with MATLAB [closed]

余生长醉 提交于 2019-12-01 13:25:14

问题


I have 9 MRI images and would like to make a 3D volume out of these images. From there, I would like to interpolate in between each slice. Given two slices in the volume, I would like to create an intermediate frame in between that interpolates between the two slices. The goal is to create an 18 MRI volume that performs this interpolation.

How would I accomplish this in MATLAB?


回答1:


Assuming that your MRI images are in a 3D stacked volume, you can accomplish what you want by using interp3. The rows and columns of a slice will stay the same when choosing the sampling points, but the temporal or Z direction will simply double in size. So something like this, assuming that MRI is your volume:

[rows,cols,slices] = size(MRI);
[X,Y,Z] = meshgrid(1:cols, 1:rows, 1:slices);
[X2,Y2,Z2] = meshgrid(1:cols, 1:rows, 0.5:0.5:slices);
out = interp3(X, Y, Z, MRI, X2, Y2, Z2, 'linear', 0);

The above will generate a volume that has twice as many slices, keeping the rows and columns the same and using bilinear interpolation. The extra 0 ensures that if we are creating values that are outside of the original sampling points, we will extrapolate these points to 0.

If your images are not a 3D volume, you'll need to place this into a 3D matrix. Assuming that they're called MRI1 up to MRI9, you can do:

MRI = cat(3, MRI1, MRI2, MRI3, MRI4, MRI5, MRI6, MRI7, MRI8, MRI9);

You can then use the above code. Once you're finished, you can grab the intermediate slices by doing:

final_slices = MRI(:,:,1:2:end);

You can then access each intermediate slice with final_slices.


As a quick example seeing this working, let's assume that our volume is a bunch of random numbers in a 3 x 3 x 3 volume:

rng(123123);
MRI = rand(3,3,3)

MRI(:,:,1) =

    0.3002    0.8302    0.1768
    0.9946    0.7214    0.0678
    0.2901    0.4627    0.5201


MRI(:,:,2) =

    0.2323    0.8516    0.7838
    0.3251    0.5326    0.6377
    0.7220    0.4735    0.0717


MRI(:,:,3) =

    0.3202    0.1259    0.3360
    0.1004    0.9260    0.6287
    0.6922    0.3191    0.9011

Running the above interpolation code, we get:

out(:,:,1) =

     0     0     0
     0     0     0
     0     0     0


out(:,:,2) =

    0.3002    0.8302    0.1768
    0.9946    0.7214    0.0678
    0.2901    0.4627    0.5201


out(:,:,3) =

    0.2662    0.8409    0.4803
    0.6598    0.6270    0.3527
    0.5060    0.4681    0.2959


out(:,:,4) =

    0.2323    0.8516    0.7838
    0.3251    0.5326    0.6377
    0.7220    0.4735    0.0717


out(:,:,5) =

    0.2763    0.4887    0.5599
    0.2127    0.7293    0.6332
    0.7071    0.3963    0.4864


out(:,:,6) =

    0.3202    0.1259    0.3360
    0.1004    0.9260    0.6287
    0.6922    0.3191    0.9011

As you can see, the code certainly does create intermediate slices correctly. You see that every even position is one of the original MRI images, while the odd positions are the interpolated results. The first slice doesn't mean anything as we are trying to extrapolate from outside the known volume. You probably want to concentrate on the third slice and its odd positions after this point up until the end of the new volume.



来源:https://stackoverflow.com/questions/28667286/creating-intermediate-slices-in-a-3d-mri-volume-with-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!