International audienceContext. The connection between the prestellar core mass function (CMF) and the stellar initial mass function (IMF) lies at the heart of all star formation theories, but it is inherently observationally unreachable.Aims. In this paper we aim to elucidate the earliest phases of star formation with a series of high-resolution numerical simulations that include the formation of sinks from high-density clumps. In particular, we focus on the transition from cores to sink particles within a massive molecular filament, and work towards identifying the factors that determine the shape of the CMF and the IMF.Methods. We have compared the CMF and IMF between magnetized and unmagnetized simulations, and between different resoluti...