How can I convert 3d MRI data (128x128x27) into 4d (128x128x1x27) for visualization using montage?
5 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Voss
on 27 Apr 2022
Edited: Voss
on 27 Apr 2022
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 Comments
More Answers (1)
See Also
Categories
Find more on MRI in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!