def generate_outpath(filepath):

    """
    Generates the output name for an input nii.gz file by appending 'noise'
    to file name.
    """

    parts = filepath.split('.')
    prefix = '.'.join(parts[:-2]+['noise'])

    return prefix