How can I convert 3d MRI data (128x128x27) into 4d (128x128x1x27) for visualization using montage?
3 次查看(过去 30 天)
显示 更早的评论
I am going to visualize my mri data using the tutorial:
my data size 128x128x27, it is not working with the instructions. it gives the following the error:
"Unrecognized function or variable map"
I found that the data in the give tutorial size is 128x128x1x27.
How can I convert from 128x128x27 to 128x128x1x27?
Thanks
0 个评论
采纳的回答
Voss
2022-4-27
编辑:Voss
2022-4-27
mri.mat is a .mat file included with the MATLAB installation that contains a few variables:
which mri.mat
S = load('mri.mat')
As you can see, mri.mat contains variables D, map and siz. When you load mri.mat into your workspace then those variables become variables in your workspace:
clear
load mri
whos
The error says, "Unrecognized function or variable map". That's because, however you are loading your data (perhaps from your own .mat file or perhaps some other way), there is no variable called map in the workspace.
The error is not caused by your data being the wrong size or having the wrong dimensionality, but you can make it 128x128x1x27 by doing:
data_4D = permute(data_3D,[1 2 4 3]);
You'd still have to define a map variable if you want to use a colormap, but you can make a montage without one. And you can make a montage with 3D data:
subplot(2,2,1)
montage(D,map); % 128x128x1x27, with map
title('4D, with map');
subplot(2,2,2)
montage(D); % 128x128x1x27, no map
title('4D, no map');
subplot(2,2,3)
montage(squeeze(D),map); % 128x128x27, with map
title('3D, with map');
subplot(2,2,4)
montage(squeeze(D)); % 128x128x27, no map
title('3D, no map');
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Biomedical Imaging 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!