The invention provides for a medical instrument (200, 300, 400, 500, 600, 700) comprising a magnetic resonance imaging system (204) operable for acquiring magnetic resonance data (266) from a subject (236) within an imaging zone (232) and an external beam radiotherapy system (202) operable for irradiating a target zone (238) within the imaging zone. The medical instrument further has a radiation beam generation system (208, 302, 302′, 302″) operable for generating a radiation beam (242, 304, 304′, 304″) and a radiation beam detection system (243, 502, 502′) operable for acquiring radiation beam detection data (270) descriptive of the radiation beam. Instructions cause a processor (248) controlling the instrument to receive (100) planning data (260) descriptive of a spatially dependent radiation dose and generate (102) external beam radiotherapy control commands (264) using the radiation dose. The instructions causes the processor to repeatedly: control (106) the external beam radiotherapy system to irradiate the target zone using the external beam radiotherapy system control commands; generate (108) the radiation beams using the radiation beam generation system; measure (110) the radiation beam detection data using the radiation beam detection system; acquire (112) the magnetic resonance imaging data using the magnetic resonance imaging system, generate (114) a magnetic resonance image (268) using the magnetic resonance image data, determine (116) a registration (274) of the magnetic resonance image to the radiation beam detection data; calculate (118) a mapping (276) using the registration; and modify the external beam radiotherapy system control commands using the mapping.