Command line bfconvert to convert nd2 to tif java error

Hi,

Does anyone get java exception when converting nd2 to tif when using command line bfconvert in Ubuntu 20.04 LTE?

This is the Exception I got when calling bfconvert

Parsing block 'ND2 FILEMAP ' 99%
Exception in thread "main" java.lang.NullPointerException
	at loci.formats.in.ND2Handler.parseKeyAndValue(ND2Handler.java:894)
	at loci.formats.in.ND2Handler.parseKeyAndValue(ND2Handler.java:882)
	at loci.formats.in.NativeND2Reader.parseText(NativeND2Reader.java:2437)
	at loci.formats.in.NativeND2Reader.initFile(NativeND2Reader.java:974)
	at loci.formats.FormatReader.setId(FormatReader.java:1392)
	at loci.formats.DelegateReader.setId(DelegateReader.java:291)
	at loci.formats.ImageReader.setId(ImageReader.java:849)
	at loci.formats.tools.ImageConverter.testConvert(ImageConverter.java:506)
	at loci.formats.tools.ImageConverter.main(ImageConverter.java:1095)

The java version I am using in Ubuntu 20.04 LTE:

openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)

Hi @Borease, this looks as though it is caused by an empty Power metadata tag, however Bio-Formats should be able to handle this without failing and throwing an exception like that would be considered a bug. Would you be able to upload the file to https://www.openmicroscopy.org/qa2/qa/upload/ so that we can use it for testing and put a fix in place to handle this better?

Hi @dgault

I uploaded the sample image file. Please kindly check it out. The uploaded file ID is 29634.

Also , the similar problem occurs when I was using bfmatlab tools from matlab environment. The error was something like this:

Error using bfGetReader (line 85)
Java exception occurred:
java.lang.NullPointerException
	at loci.formats.in.ND2Handler.parseKeyAndValue(ND2Handler.java:894)
	at loci.formats.in.ND2Handler.parseKeyAndValue(ND2Handler.java:882)
	at loci.formats.in.NativeND2Reader.parseText(NativeND2Reader.java:2437)
	at loci.formats.in.NativeND2Reader.initFile(NativeND2Reader.java:974)
	at loci.formats.FormatReader.setId(FormatReader.java:1392)
	at loci.formats.DelegateReader.setId(DelegateReader.java:291)
	at loci.formats.ImageReader.setId(ImageReader.java:849)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
	at loci.formats.ChannelFiller.setId(ChannelFiller.java:223)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
	at loci.formats.ChannelSeparator.setId(ChannelSeparator.java:293)

Error in bfopen (line 114)
r = bfGetReader(id, stitchFiles);

Error in main_script (line 7)
img_stack_cell_array = bfopen([input_path
'20201007_2_OCT4DBD-Halo_PA64625nM_1kframe_tail_7ms_40pert_008.nd2']);

Thank you for your kind support!

Thanks @Borease, I was able to reproduce the bug with the file provided. I have opened a PR which should resolve the issue and will be included with a future Bio-Formats release: https://github.com/ome/bioformats/pull/3627