Externalize function transform_single_niimg