A method of exciting nuclear spins in a sample, wherein a plurality of transmit coils are driven in parallel to emit respective radio-frequency excitation pulses, the method comprising computing the phases and/or amplitudes of said excitation pulses by solving an optimization problem for minimizing the difference between the excitation distribution within said sample and a target excitation distribution, and being characterized in that: said optimization problem includes a cost function depending on the power emitted by said transmit coils through respective coil-dependent weighting coefficients and in that the phases and/or amplitudes of the excitation pulses are computed iteratively, each iteration step comprising: solving said optimization problem based on present values of the weighting coefficient, and subsequently updating the value of at least one of said coefficients so as to control in a predetermined way the local specific absorption rate—SAR—distribution within the sample. The method of the invention allows, in particular, reducing the local SAR maximum value within the sample and/or ensuring that the local SAR takes its maximum value within a predetermined region of the sample.