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: resample_time.m
    path of file: ./repos/CanlabCore/CanlabCore/@image_vector
    
    the code of the file until where you have to start completion: function obj = resample_time(obj, source_TR, target_TR, varargin)
% Resample the time-series images (source_time_interval) in an fmri_data object (obj) 
% to the different time series (target_time_interval). Works for all image_vector objects.
%
%   - obj = resample_time(obj, source_time_interval, target_time_interval, varargin)
%
% :Optional Inputs:
%
%   **meth (Interpolation methods):**

    
function obj = resample_time(obj, source_TR, target_TR, varargin)
% Resample the time-series images (source_time_interval) in an fmri_data object (obj) 
% to the different time series (target_time_interval). Works for all image_vector objects.
%
%   - obj = resample_time(obj, source_time_interval, target_time_interval, varargin)
%
% :Optional Inputs:
%
%   **meth (Interpolation methods):**
%        You can enter resampling method as optional input. Takes any input to
%          - 'nearest' - nearest neighbor interpolation
%          - 'linear'  - linear interpolation (default)
%          - 'spline'  - spline interpolation
%          - 'cubic'   - cubic interpolation as long as the data is uniformly
%                       spaced, otherwise the same as 'spline'
%   **slice:**
%      A fraction of the slice timing correction.
%      The default is 0.5, meaning if your TR is 2s, the time point of your TR image
%      will be considered as the middle point of the TR bins. You can use this option
%      to use different time points. If you are upsampling your data (i.e.,
%      your target TR is shorter than your source TR), you need to discard the
%      first column of your data. This function will return the first time point data as NaN. 
%
%
% :Examples:
% ::
%
%    dat = fmri_data('/Volumes/RAID1/labdata/current/BMRK3/Imaging/spatiotemp_biomarker/STmarker1.img');
%    dat = resample_time(dat, 2, 1.3) 
%
%    % with options:
%    dat = resample_time(dat, 2, 1.3, 'meth', 'linear', 'slice', .3)
%

slice_frac = .5;
intp_meth = [];

for i = 1:length(varargin)
    if ischar(varargin{i})
        switch varargin{i}
            case {'meth', 'methods'}
                intp_meth = varargin{i+1};
            case {'slice'}
                slice_frac = varargin{i+1};
            otherwise
        end