For anyone who finds this error using a web search, this issue is a replication of 2075. Specifically, when dcm2niix generates the warning Interslice distance varies for a Siemens fieldmap, it typically suggests that one of your tools that handles DICOM images has deleted some of the images. You can fix this by getting the images directly off of the console, or checking the tools that archive your DICOM images. It is not a problem with dcm2niix, but reflects data loss upstream. The core issue is that Siemens will generate identical Session, Series and Instance IDs for each echo in a field map. Many tools assume this means that these “identical” images are redundant, and randomly deletes one of the echoes. Which echo is deleted varies randomly for the 2D slices in a 3D stack. While it is unhelpful and misleading for Siemens to generate identical Instance numbers (and UIDs) for two different images, is is technically legal. When you get this error, you really want to check the providence of your images, and remove or update the tool that is deleting some of your data. You may also want to lobby your Siemens Research Collaboration manager: tell them it would be helpful if a unique instance number is generated for each unique image.
To re-iterate: this is not a problem with dcm2niix. dcm2niix was not provided with all the images since some were deleted. No converter can cope with this situation. Generating an exit code and warning the users to update their data archiving is the appropriate response. While dcm2nii may not be generating an error, it is most likely combining slices with different echo times that can cause issues down stream.