I found these sort of diminished after upping my magnesium. I was having two Epsom salt baths a day at one point. However, I kept getting cramps until I increased my potassium too.
Now I just drink electrolytes and oral rehydration solution throughout the day which seems to minimise most of it. It's possible, too, that it was all OI related, perhaps due to low blood flow, and that by increasing my blood volume it's helped. That's a common explanation I've seen.
Dr Worthley at the ME Trust recommended Banana Bags ORS as a popular OI treatment, but they're quite expensive. I found an alternative online that was much cheaper. He also said I should do lower leg stretches when laid up to lessen OI. I just point my toes and rotate my feet regularly.
Obviously, this is only for me, so I can't say what will work for you. It could be adrenal, thyroid-related, or something else.