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: bspm_harvest_contrast.m
    path of file: ./repos/bspm/utilities
    
    the code of the file until where you have to start completion: function [data connam roinam] = bspm_harvest_contrast(analysisdirs, rois, conidx, conpat, plotflag)
% BSPM_HARVEST_CONTRAST
%
%   USAGE: [data connam roinam] = bspm_harvest_contrast(analysisdirs, rois, conidx, conpat, plotflag)
%
%   ARGUMENTS
%       analysisdirs: analysis directory containing contrast images
%       rois: paths to region of interest images from which to extract data
%       conidx: option to harvest a subset of contrasts indexed here
%       plotflag: option to plot bargraph of contrasts for each ROI (default = 0)
%
%   OUTPUTS
%       data: a cell array of the contrast values (each cell contains data
%       matrix for a different roi corresponding to order of roinam;
%       subjects are rows and contrasts are columns)
%       connam: a cell array of contrast names
%       roinam: a cell array of ROI names

    
function [data connam roinam] = bspm_harvest_contrast(analysisdirs, rois, conidx, conpat, plotflag)
% BSPM_HARVEST_CONTRAST
%
%   USAGE: [data connam roinam] = bspm_harvest_contrast(analysisdirs, rois, conidx, conpat, plotflag)
%
%   ARGUMENTS
%       analysisdirs: analysis directory containing contrast images
%       rois: paths to region of interest images from which to extract data
%       conidx: option to harvest a subset of contrasts indexed here
%       plotflag: option to plot bargraph of contrasts for each ROI (default = 0)
%
%   OUTPUTS
%       data: a cell array of the contrast values (each cell contains data
%       matrix for a different roi corresponding to order of roinam;
%       subjects are rows and contrasts are columns)
%       connam: a cell array of contrast names
%       roinam: a cell array of ROI names
%       
% Created March 29, 2013 - Bob Spunt

% ---------------------------------------- Copyright (C) 2014 ----------------------------------------
%	Author: Bob Spunt
%	Affilitation: Caltech
%	Email: spunt@caltech.edu
%
%	$Revision Date: Aug_20_2014

if nargin<5, plotflag = 0; end