Clear Filters
Clear Filters

Trouble writing and saving .nii files

149 views (last 30 days)
Grace
Grace on 8 Aug 2024 at 15:51
Commented: Umar on 15 Aug 2024 at 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 Comments
Cris LaPierre
Cris LaPierre on 15 Aug 2024 at 2:57
Thank you, but I think we need to know how Nii_Saver is doing it.
Umar
Umar on 15 Aug 2024 at 15:42
Hi @ Cris LaPierre,
Well, in this case, we have to wait for @Gracec to provide the missing piece of puzzle.

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!