coerce_outpath_extension#

petpal.utils.useful_functions.coerce_outpath_extension(path: str, ext: str) str#

Coerce a path to the same absolute path with a provided filetype extension.

Parameters:
  • path (str) – Path to a file.

  • ext (str) – Desired output extension.

Returns:

abs_path_with_extension (str) – Absolute path of the input file with the modified extension.

Example

from petpal.utils.useful_functions import coerce_outpath_extension

my_path = 'my_file.nii.gz'
my_csv_file = coerce_outpath_extension(my_path, '.csv')
print(my_csv_file) # prints '/current/working/directory/my_file.csv'