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: spm_read_hdr.m
    path of file: ./repos/bspm/thirdparty/spm12/compat
    
    the code of the file until where you have to start completion: function [hdr,otherendian] = spm_read_hdr(fname)
% Read (SPM customised) Analyze header
% FORMAT [hdr,otherendian] = spm_read_hdr(fname)
% fname       - .hdr filename
% hdr         - structure containing Analyze header
% otherendian - byte swapping necessary flag
%_______________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% John Ashburner
% $Id: spm_read_hdr.m 4418 2011-08-03 12:00:13Z guillaume $


fid         = fopen(fname,'r','native');
otherendian = 0;
if (fid > 0)
    dime = read_dime(fid);
    if dime.dim(1)<0 || dime.dim(1)>15, % Appears to be other-endian
        % Re-open other-endian
        fclose(fid);
        if spm_platform('bigend'), fid = fope
    
function dime = read_dime(fid)
% read (struct) image_dimension
%-----------------------------------------------------------------------
fseek(fid,40,'bof');
dime.dim        = fread(fid,8,'int16')';
dime.vox_units  = mysetstr(fread(fid,4,'uchar'))';
dime.cal_units  = mysetstr(fread(fid,8,'uchar'))';
dime.unused1    = fread(fid,1,'int16');
dime.datatype   = fread(fid,1,'int16');
dime.bitpix     = fread(fid,1,'int16');
dime.dim_un0    = fread(fid,1,'int16');
dime.pixdim     = fread(fid,8,'float')';
dime.vox_offset = fread(fid,1,'float');
dime.funused1   = fread(fid,1,'float');
dime.funused2   = fread(fid,1,'float');
dime.funused3   = fread(fid,1,'float');
dime.cal_max    = fread(fid,1,'float');
dime.cal_min    = fread(fid,1,'float');
dime.compressed = fread(fid,1,'int32');
dime.verified   = fread(fid,1,'int32');
dime.glmax      = fread(fid,1,'int32');
dime.glmin      = fread(fid,1,'int32');
if isempty(dime.glmin), error(['Problem reading "dime" of header file (' fopen(fid) ').']); end