Skip to content

Instantly share code, notes, and snippets.

@robertoostenveld
Created March 2, 2018 08:36
Show Gist options
  • Save robertoostenveld/dca2e176daebf5bda02bba14b01ffe78 to your computer and use it in GitHub Desktop.
Save robertoostenveld/dca2e176daebf5bda02bba14b01ffe78 to your computer and use it in GitHub Desktop.
logical flow in ft_read_xxx to support the plugin of new file formats
hdr = ft_read_header(filename, varargin)
filetype = ft_getopt(varargin, 'filetype');
if isempty(filetype)
filetype = ft_filetype(filename);
end
switch filetype
case 'aaa':
% do whatever it used to be doing
case 'bbb':
% do whatever it used to be doing
otherwise:
% try adding fieldtrip/external/"filetype" to the path
% it should contain the function read_header_"filetype" and that function should have the same API as ft_read_header
if ft_hastoolbox(filetype, 3)
funname = sprintf("read_header_%s", filetype);
hdr = feval(funname, filename, varargin)
end
end % switch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment