Generate fat and water MHA files in python from in-/out-phase exported MHA files

I would like to know if I can ask in this forum some problems I am having in getting some water and fat images from the in-phase and out-of-phase images. I know this forum is dedicated to 3dSlicer and it is partly related because I have exported the files from there, but I am trying equations and code done in python from which I am not getting the desired results.

I am looking for help to solve the effects in the images that do not match the data displayed in 3D Slicer.

I don’t know if it is because of the file format (MHA) and the metadata.