An algorithm is described that localizes a set of simultaneously activated coils using MEG detectors. These coil positions are used for continuous or intermittent head position registration during long MEG sessions, to coregistrate MR and MEG data and to localize EEG electrodes attached to the scalp, when EEG and MEG are recorded simultaneously. The algorithm is based on a mathematical model in which the coils are described as stationary magnetic dipoles with known source time functions. This knowledge makes it possible to detect and remove bad channels automatically. It is also assumed that the source time functions are orthogonal. Therefore, the localization problem splits into independent localization problems. for each coil. The method is validated in a phantom experiment, where the relative coil positions were known. From this experiment it is found that the average error is 0.25 cm. An error of 0.23 cm was found in an experiment where 64 electrode positions were measured four times independently. Examples of the applications of the method are presented. Our method eliminates the use of an external 3D digitizer and maps the MEG directly onto other modalities. This is not only a practical advantage, but it also reduces the gross registration error. Furthermore, head motions can be monitored and MEG data can be corrected for these motions.