I have various .nd2 files that I am trying to convert to .tiff or .ome.tiff using the bfconvert command line utility. Whereas all the files open without any problem using the bioformats import module of Fiji, the command line tool fails to convert them, for various reasons.
One file for instance (uploaded), having three channels and 22 z-planes per channel, fails conversion (bfconvert -channel 0 in.nd2 out.tif) with the following error: "Exception in thread "main" java.lang.IllegalArgumentException: Invalid image index: 24/22"
The bfconvert routine seems to misread the input file and tries to load more than 22 z-planes per channel.
For other files having a single channel and either multiple z-planes or multiple time points (but not both), the conversion completes without raising an error but the resulting TIFF stacks are clearly corrupted: while the first image in the series appears normal, the subsequent images appear as a 4-piece moving jigsaw. Each image in the converted stack comprises variably sized parts of four other planes which change in relative size and position, moving in a NW to SE direction, when scanning through the stack. There are also white and black horizontal lines appearing between the upper and lower two sub-images which move in a north to south direction. If the recommendations on how to avoid the problem described in the preceding paragraph do not also ameliorate this problem, then I will also post an example .nd2 file illustrating this specific behavior.
I again wish to emphasize that the files display normally when opened using the bioformats import module of Fiji, so the problem resides neither with the input .nd2 files nor the bioformats package per se, but rather with the command line utility bfconvert (or possibly my invocation thereof).
Edit: The second problem is resolved, at least in one instance, by writing to an .ome.tiff file rather than a .tiff file. Given that the output is 1D (either z or t), an ordinary tiff should work as well, so I am surprised that conversion succeeds only when OME-TIFF is selected as the output format.