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: loreta2fieldtrip.m
    path of file: ./repos/spm12/external/fieldtrip
    
    the code of the file until where you have to start completion: function [source] = loreta2fieldtrip(filename, varargin)

% LORETA2FIELDTRIP reads and converts a LORETA source reconstruction into a
% FieldTrip data structure, which subsequently can be used for statistical
% analysis or other analysis methods implemented in Fieldtrip.
%
% Use as
%   [source]  =  loreta2fieldtrip(filename, ...)
% where optional arguments can be passed as key-value pairs.
%
% filename can be the binary file from LORETA or a LORETA file exported as
% a text file (using the format converter in LORETA-KEY).
%
% The following optional arguments are supported
%   'timeframe'  =  integer number, which timepoint to read (default is to read all)

    
function [source] = loreta2fieldtrip(filename, varargin)

% LORETA2FIELDTRIP reads and converts a LORETA source reconstruction into a
% FieldTrip data structure, which subsequently can be used for statistical
% analysis or other analysis methods implemented in Fieldtrip.
%
% Use as
%   [source]  =  loreta2fieldtrip(filename, ...)
% where optional arguments can be passed as key-value pairs.
%
% filename can be the binary file from LORETA or a LORETA file exported as
% a text file (using the format converter in LORETA-KEY).
%
% The following optional arguments are supported
%   'timeframe'  =  integer number, which timepoint to read (default is to read all)
%
% See also EEGLAB2FIELDTRIP, SPM2FIELDTRIP, NUTMEG2FIELDTRIP, SPASS2FIELDTRIP

% This function depend