Hi, @jhuguetn. First, I think you'll get better help for a question like this on the nibabel issues page.
You can get the data object through
img.dataobj, which will be an
ArrayProxy which keeps track of the underlying array and the scale/intercept, in order to produce the data you get with
Assuming what you care about is the values, not the specific slope/intercept that gets stored in the header, what you could do is:
import nibabel as nib
img = nib.load(orig_fname)
scaled_data = new_inter + new_slope * img.dataobj.get_unscaled()
new_img = nib.Nifti1Image(scaled_data, img.affine, img.header)
If you want to specifically replace the values, you may be able to set them in the
new_img header. If this doesn't get you all the way to where you're trying to go, I'd again recommend moving over to Github.