You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: out_mri_nii.m
    path of file: ./repos/brainstorm3/toolbox/io
    
    the code of the file until where you have to start completion: function [fid, nifti] = out_mri_nii( sMri, OutputFile, typeMatlab, Nt )
% OUT_MRI_NII: Exports a MRI to a NIFTI-1 file (.NII or .HDR/.IMG)).
% 
% USAGE:        out_mri_nii( sMri, OutputFile, typeMatlab)         : Write a full file
%         fid = out_mri_nii( sMri, OutputFile, typeMatlab, Nt=1 )  : Write the header and do not close the file before returning
%         ... = out_mri_nii( BstMriFile, ...)
%
% INPUT: 
%    - sMri       : Brainstorm MRI structure
%    - BstMriFile : Path to a MRI file in the Brainstorm database
%    - OutputFile : full path to output file (with '.img' or '.nii' extension)
%    - typeMatlab : string, type of data to write in the file: uint8, int16, int32, float32, double
%    - Nt         : Number of time points to write in the file
%                   If specified, writes only the header of the file (time frames will be written from calling function)
%
% NOTE: store binary files in Little Endian only

% @=============================================================================
% This function is part of the Brainstorm software:
% https://neuroimage.usc.edu/brainstorm
% 
% Copyright (c) University of Southern California & McGill University
% This software is distributed under the terms of the GNU General Public License
% as published by the Free Software Foundation. Further details on the GPLv3
% license can be found at http://www.gnu.org/copyleft/gpl.html.
% 
% FOR RESEARCH PURPOSES ONLY. THE SOFTWARE IS PROVIDED "AS IS," AND THE
% UNIVERSITY OF SOUTHERN CALIFORNIA AND ITS COLLABORATORS DO NOT MAKE ANY
% WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
% MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, NOR DO THEY ASSUME ANY
% LIABILITY OR RESPONSIBILITY FOR THE USE OF THIS SOFTWARE.
%
% For more information type "brainstorm license" at command prompt.
% =============================================================================@
%
% Authors: Francois Tadel, 2008-2021

    
function [fid, nifti] = out_mri_nii( sMri, OutputFile, typeMatlab, Nt )
% OUT_MRI_NII: Exports a MRI to a NIFTI-1 file (.NII or .HDR/.IMG)).
% 
% USAGE:        out_mri_nii( sMri, OutputFile, typeMatlab)         : Write a full file
%         fid = out_mri_nii( sMri, OutputFile, typeMatlab, Nt=1 )  : Write the header and do not close the file before returning
%         ... = out_mri_nii( BstMriFile, ...)
%
% INPUT: 
%    - sMri       : Brainstorm MRI structure
%    - BstMriFile : Path to a MRI file in the Brainstorm database
%    - OutputFile : full path to output file (with '.img' or '.nii' extension)
%    - typeMatlab : string, type of data to write in the file: uint8, int16, int32, float32, double
%    - Nt         : Number of time points to write in the file
%                   If specified, writes only the header of the file (time frames will be written from calling function)
%
% NOTE: store binary files in Little Endian only

% @=============================================================================
% This function is part of the Brainstorm software:
% https://neuroimage.usc.edu/brainstorm
% 
% Copyright (c) University of Southern California & McGill University
% This software is distributed under the terms of the GNU General Public License
% as published by the Free Software Foundation. Further details on the GPLv3
% license can be found at http://www.gnu.org/copyleft/gpl.html.
% 
% FOR RESEARCH PURPOSES ONLY. THE SOFTWARE IS PROVIDED "AS IS," AND THE
% UNIVERSITY OF SOUTHERN CALIFORNIA AND ITS COLLABORATORS DO NOT MAKE ANY
% WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
% MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, NOR DO THEY ASSUME ANY
% LIABILITY OR RESPONSIBILITY FOR THE USE OF THIS SOFTWARE.
%
% For more information type "brainstorm license" at command prompt.
% =============================================================================@
%
% Authors: Francois Tadel, 2008-2021

% ===== PARSE INPUTS =====
% Write header of full file
if (nargin < 4) || isempty(Nt)
    Nt = [];
    isHdrOnly = 0;
else
    isHdrOnly = 1;
end