Trouble writing and saving .nii files
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);
endI 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 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 .nii, save MATLAB Answers — New Questions