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: icatb_talairach.m
    path of file: ./repos/gift/GroupICAT/icatb/icatb_talairach_scripts
    
    the code of the file until where you have to start completion: function icatb_talairach(files, threshold, convertToZ, sample_size)
%% Write talariach tables using Dae Il Kim's script and talariach daemon.
% 1. file - Input image file/files
% 2. threshold - Default is 3.5.
% 3. convertToZ - Options are 0 and 1.
% 4. sample_size - Distance between contiguous voxels in mm.
%

% Defaults
icatb_defaults;
global TALAIRACH_DIST;
global TALAIRACH_THRESHOLD;

isGUI = 0;
if ~exist('files', 'var')
    isGUI = 1;
    files = icatb_selectEntry('typeSelection', 'multiple', 'typeEntity
    
function write_tal(flagCheck, outputDir, file_name, data, sample_size, threshold, xdim, ydim, zdim, voxel1, voxel2, voxel3, origin, volStr, valStr)
% Write talairach coords

TALAIRACH_FILE = 'talairach';
TALAIRACH_EXCEL = 'talairach_final';

if ~strcmpi(flagCheck, 'pos')
    data = -data;
end

% voxel size dependent on sample_size
voxsize = (sample_size^3)/1000;

% Location of the Talairach Program
tal_prog_file = fullfile(fileparts(which('gift.m')), 'icatb_talairach_scripts', 'talairach', 'talairach.jar');

talairach = fullfile(outputDir, [file_name, '_', flagCheck, '_', TALAIRACH_FILE, '.txt']);
talairach_z = fullfile(outputDir, [file_name, '_', flagCheck, '_', TALAIRACH_FILE, '_z.txt']);
talairach_excel = fullfile(outputDir, [file_name, '_', flagCheck, '_', TALAIRACH_EXCEL, '.xls']);
excel_file = [talairach_z, '.td'];

% Clean up files
cleanup_files({talairach, talairach_z, talairach_excel, excel_file});

check_ind = find(data > threshold);

if isempty(check_ind)
    disp(['No voxels found for this threshold (', num2str(threshold), ')']);
    return;
end