function [success,msg] = ConvertMotr2JAABA(varargin)

success = false;
msg = {};  %#ok<NASGU>

% Parse inputs
[inmoviefile,seqindexfile,...
  intrxfile,...
  expdir,moviefilestr,trxfilestr,perframedirstr,...
  arenatype,arenacenterx,arenacentery,...
  arenaradius,arenawidth,arenaheight,...
  pxpermm,...
  dofliplr,doflipud,dotransposeimage,...
  dosoftlink,frameinterval,...
  sex,roi2] = myparse(varargin,...
  'inmoviefile','','seqindexfile','',...
  'intrxfile','',...
  'expdir','','moviefilestr','movie.ufmf','trxfilestr','trx.mat','perframedirstr','perframe',...
  'arenatype','None','arenacenterx',0,'arenacentery',0,...
  'arenaradius',123,'arenawidth',123,'arenaheight',123,...
  'pxpermm',1,...
  'fliplr',false,'flipud',false,'dotransposeimage',false,...
  'dosoftlink',false,...
  'frameinterval',[],...
  'sex',{},'roi2',[]);  %#ok<NASGU,ASGLU>

% Check that required inputs are given
if isempty(intrxfile),
  msg = 'Input trx mat file is empty';
  return
end

% Figure out whether it's a raw Motr _tracks.mat file or a Catalytic .ctc file by looking
% for the critical fields
td = load('-mat',intrxfile);
if isfield(td,'astrctTrackers') ,
    [success,msg] = ConvertRawMotr2JAABA(varargin{:});
elseif isfield(td,'trx') ,
    [success,msg] = ConvertMotrCtc2JAABA(varargin{:});
else
    msg='Input trx file doesn''t have astrctTrackers or trx field';
    return
end

end
