It changes electrolyte balance from what I’ve experienced, so that’s another likely way. Try being dehydrated and depressed. You can’t! The will to live kicks in and overrides depression. Like the guy who jumped off Golden Gate Bridge who on hitting the water was filled with sudden will to live. Near death is a good cure for a lot of things. That’s why keto works.