soft-matter / pims_nd2

Python nd2 reader based on the ND2 SDK
Other
16 stars 8 forks source link

Error while parsing some nd2 files #17

Open bellonet opened 5 years ago

bellonet commented 5 years ago

The reader works well for most nd2 files, however some of my nd2 files are not parsed correctly and I get an error: Exception: LIM_ERR_NOTFOUND

I think that this error occurs when the end of the file is corrupt due to the microscope crashing. Importantly, I have huge nd2 files holding multiple images so the images that were acquired before the crash are valuable. Those (maybe corrupt) files can be successfully opened/viewed/resaved as tifs using ImageJ bio-formats plugin.

I will be happy to send you an example file that fails (~8GB).

tacaswell commented 5 years ago

It looks like those errors are coming out of the vendored .so rather than any code we cantrol....

IIRC (and my personal experience is now ~10 years out of date!), nd2 is a valid tiff file with a bunch of extra metadata shoved into the headers as XML. Have you tried using tifffile to open them?

rbnvrw commented 5 years ago

Hi @bellonet , @tacaswell I'm the author of the Python package https://github.com/rbnvrw/nd2reader/ which reads ND2 files and also plays nicely with PIMS. In contrast to this package, it is not based on the Nikon SDK but the ND2 is reversed engineered.

The bug is also reported here: https://github.com/rbnvrw/nd2reader/issues/23 In summary, it seems to be caused by the fact that the software crashed before the whole file could be written. I think it is possible to workaround this, but I don't have the time at this point. If anyone wants to try, please see the issue above.

bellonet commented 5 years ago

Thanks @tacaswell . When I try to open a valid nd2 file (meaning, a file that can be opened using ND2_Reader) with tifffile I get the following error: not a TIFF file

Did it ever work for you in the past? Do you know which parameters I should pass?

tacaswell commented 5 years ago

As I said, my knowledge is 10+ years out of date... It has been long enough that I may be confusing the output files I had from the nikon software and the output from metamorph....

Sorry if I sent you down a blind alley :/

forestrywhale commented 2 months ago

I also had the same issue when reading nd2 files. Then I double checked my file, and found that my .nd2 file failed to finish transfer. Thus though the .nd2 is readable by Fiji, it is not for the pims_nd2. The failed file probably have an incomplete ending. The remedy could be using the .nd2 processing tools to crop and re-save the file if the original file is incomplete. For my case, I'll re-transfer my file and it should work.