MRI-based treatment planning in radiotherapy is limited by the lack of electron density information and by the difficulty to differentiate air from bone regions. A completely automatic method to produce a pseudo-CT from a 3D gradient-echo dataset through voxel-wise assignment of computed tomography (CT) numbers (Hounsfield unit (HU)) was developed. The HU assignment is based on a combination of relative fat and water content and magnetic susceptibility estimates. The proposed method avoids registration errors and allows for HU variability in each tissue class. An improved quantitative susceptibility mapping algorithm for regions with large susceptibility and negligible signal is also presented.