Syntax error in function but everything seems correct
If you use Python earlier than 3.6 f-strings are not available, and that code has an incorrect syntax. In that case you can use the format method of the strings instead like that (2 lines are modified):
def  saveSlice(img, fname, path):
     img  = np.uint8(img * 255)
     fout = os.path.join(path, '{}.png'.format(fname))
     cv2.imwrite(fout, img)
     print('[+] Slice saved: {}'.format(fout), end='\r')