def remove_extension(filepath):
    """Removes all extensions of the filename pointed by filepath.

    :Example:

    >>> remove_extension('home/user/t1_image.nii.gz')
    'home/user/t1_image'
    >>> remove_extension('home/user/t1_image.nii.gz') + '_processed.nii.gz'
    'home/user/t1_image_processed.nii.gz'
    """
    paths = filepath.split('/')
    if '.' not in paths[-1]:  # No extension found in filepath
        return filepath
    filename_noext = paths[-1].split('.')[0]
    filepath_noext = '/'.join(paths[:-1] + [filename_noext])
    return filepath_noext