We apply transition path sampling to the simulation of nanoparticles under pressure. As a barostat we use a bath of ideal gas particles that form a stochastically updated atmosphere around the nanoparticle. We justify this algorithm by showing that it preserves the distribution of an ideal gas at constant temperature and pressure by satisfying detailed balance. Based on this result, we present a simple and efficient transition path sampling scheme for the study of activated processes in nanoparticles under pressure. As a first application, we investigate the h-MgO to rocksalt transformation in faceted CdSe nanocrystals. Starting from an artificial mechanism involving a uniform motion of all atoms, trajectories quickly converge towards the dominant mechanism of nucleation and growth along parallel (100) planes. (C) 2007 American Institute of Physics.