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: saveplots.m
    path of file: ./repos/CanlabCore/CanlabCore/@fmri_data
    
    the code of the file until where you have to start completion: function saveplots(fmri_dat, varargin)

% Output dir
if isempty(varargin)
    savedir = pwd;
else

    
function saveplots(fmri_dat, varargin)

% Output dir
if isempty(varargin)
    savedir = pwd;
else
savedir = varargin{1};
end

if ~exist(savedir, 'dir'), mkdir(savedir); end


% Register of possible plot names associated with this object type

plotnames = {'fmri data matrix' ...
    'Orthviews_means_by_unique_Y' ...
    'means by condition (unique Y values)' ...
    'Montage_coeff_of_var_across_conditions' ...
    'Montage_mean_across_conditions' ...
    'Orthviews_fmri_data_mean_and_std'
    };

for j = 1:length(plotnames)
    
    han = findobj('Name', plotnames{j});
    
    if isempty(han), continue, end