Trouble writing and saving .nii files

149 次查看(过去 30 天)
Grace
Grace 2024-8-8,15:51
评论: Umar 2024-8-15,15:42
I have a working MATLAB code that produces 5 T1 maps for 5 different angles from an MRI data set of (512 512 170 5). When I look at them in MATLAB Figures they show the right values and look fine (see attached). However, when I try and save them using the code below, they save like the images shown in FSLeyes, where they are being split into different slices (5 x 34 slices = 170). I can't understand why?
% Loop to save each flip angle as an individual NIfTI file
for i = 1:size(T1, 4)
% Convert the T1 data to double
Data = double(T1(:, :, :, i));
% Define voxel size
VoxSize = [0.6, 0.6, 1];
% Create a name for the NIfTI file
NameForSaving = sprintf('T1_Map_Angle%d.nii', i);
% Define the file location for saving
filelocation = 'location_hidden';
fullpath = fullfile(filelocation, NameForSaving);
% Save the data as a NIfTI file
Nii_Saver(Data, VoxSize, fullpath);
end
  19 个评论
Cris LaPierre
Cris LaPierre 2024-8-15,2:57
Thank you, but I think we need to know how Nii_Saver is doing it.
Umar
Umar 2024-8-15,15:42
Hi @ Cris LaPierre,
Well, in this case, we have to wait for @Gracec to provide the missing piece of puzzle.

请先登录,再进行评论。

回答(0 个)

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by