Creating .nrrd/.mha files from the sequence of tracked raw images for 3D reconstruction

Hi everyone,
I want to do offline 3D reconstruction from parallel ultrasound slices tracked by robotic arm encoders using volume reconstructor application. It requires the input sequence either in .nrrd or .mha format, but I only have, for example, 1000 raw images (each image is an array 512x512) and corresponding 1000 positions of those slices in my world frame (array of doubles). Does anybody know any python library or other software which can help with such a task? I am a complete newbie in ultrasound acquisition and these file formats; so some links on how the data is organized in these file formats would also be helpful.