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: cat_stat_nanstat1d.m
    path of file: ./repos/ExploreASL/External/SPMmodified/toolbox/cat12
    
    the code of the file until where you have to start completion: function x=cat_stat_nanstat1d(x,action)
% ----------------------------------------------------------------------
% replace nan* functions of the stat toolbox for the 1d case 
% use double, because mean error for large single arrays.
% ----------------------------------------------------------------------

    
function x=cat_stat_nanstat1d(x,action)
% ----------------------------------------------------------------------
% replace nan* functions of the stat toolbox for the 1d case 
% use double, because mean error for large single arrays.
% ----------------------------------------------------------------------
% Robert Dahnke 
% Structural Brain Mapping Group
% University Jena 
% ----------------------------------------------------------------------
% $Id: cat_stat_nanstat1d.m 1036 2016-10-18 14:26:32Z dahnke $

  x=double(x(:)); x(isnan(x) | isinf(x))=[];
  if ~exist('action','var'), action='nanmean'; end