The Ni-Mn-Ga shape memory alloy displays the largest shape change of all known magnetic Heusler alloys with a strain of the order of 10% in an external magnetic field of less than one Tesla. In addition, the alloys exhibit a sequence of intermediate martensites with the modulated structures usually appearing at c/a < 1 while the low-temperature non- modulated tetragonal structures have c/a > 1. Typically, in the Ni-based alloys, the martensitic transformation is accompanied by a systematic change of the electronic structure in the vicinity of the Fermi energy, where a peak in the electronic density of states from the non-bonding Ni states is shifted from the occupied region to the unoccupied energy range, which is associated with a reconstruction of the Fermi surface, and, in most cases, by pronounced phonon anomalies. The latter appear in high-temperature cubic austenite, premartensite but also in the modulated phases. In addition, the modulated phases have highly mobile twin boundaries which can be rearranged by an external magnetic field due to the high magnetic anisotropy, which builds up in the martensitic phases and which is the origin of the magnetic shape memory effect. This overall scenario is confirmed by first-principles calculations.