<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def kelly_kapowski(s, g, w, its=50, r=0.025, m=1.5, **kwargs):
 """ Compute cortical thickness using the DiReCT algorithm. Diffeomorphic registration-based cortical thickness based on probabilistic segmentation of an image. This is an optimization algorithm. Arguments --------- s : ANTsimage segmentation image g : ANTsImage gray matter probability image w : ANTsImage white matter probability image its : integer convergence params - controls iterations r : scalar gradient descent update parameter m : scalar gradient field smoothing parameter kwargs : keyword arguments anything else, see KellyKapowski help in ANTs Returns ------- ANTsImage Example ------- w=segs['probabilityimages'][2], its=45, r=0.5, m=1) """

    if isinstance(s, iio.ANTsImage):
        s = s.clone('unsigned int')

    d = s.dimension
    outimg = g.clone()
    kellargs = {'d': d,
                's': s,
                'g': g,
                'w': w,
                'c': its,
                'r': r,
                'm': m,
                'o': outimg}
    for k, v in kwargs.items():
        kellargs[k] = v

    processed_kellargs = utils._int_antsProcessArguments(kellargs)

    libfn = utils.get_lib_fn('KellyKapowski')
    libfn(processed_kellargs)
    return outimg