How can I convert 3d MRI data (128x128x27) into 4d (128x128x1x27) for visualization using montage?
조회 수: 10(최근 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?
Voss 2022년 4월 27일
편집: Voss 2022년 4월 27일
mri.mat is a .mat file included with the MATLAB installation that contains a few variables:
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:
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:
montage(D,map); % 128x128x1x27, with map
title('4D, with map');
montage(D); % 128x128x1x27, no map
title('4D, no map');
montage(squeeze(D),map); % 128x128x27, with map
title('3D, with map');
montage(squeeze(D)); % 128x128x27, no map
title('3D, no map');