function [data] = nic_read_vols(V)
% Read data using SPM5 functions

% get the correct spm path
[spmPath] = nic_getSPMPath(V(1));

addpath(spmPath);

oldDir = pwd;

try
    
    cd(spmPath);
    
    % Initialise data
    data = zeros([V(1).dim(1:3), length(V)]);

    % read the data
    for ii = 1:length(V) 
        data(:, :, :, ii) = nic_spm_read_vols(V(ii));
    end

    cd(oldDir);

catch

    cd(oldDir);
    nic_displayErrorMsg;

end

