How to resolve "Unable to open file (Truncated file)" error in an iPython notebook

372 Views Asked by At

I'm trying to follow the example of brain observatory ipython notebook.

However, I became stuck loading the nwb file like below.

from allensdk.core.brain_observatory_cache import BrainObservatoryCache
boc = BrainObservatoryCache(manifest_file='boc/manifest.json')

data_set = boc.get_ophys_experiment_data(501940850)  # problem here

So, I opened the nwb file by HDFview.

All of the brain observatory nwb files were not opened except for 502376461.nwb.

It threw the following error:

IOError: Unable to open file (Truncated file: eof = 82280448, sblock->base_addr = 0, stored_eoa = 204046519)

When I tried to open the 502376461.nwb in the ipython notebook example from allen, it worked!! But the others (501940850, 503820068...) failed like above.

1

There are 1 best solutions below

0
On

Summarizing the thread from github:

https://github.com/AllenInstitute/AllenSDK/issues/22

The files were partially downloaded or corrupted somehow. No exceptions were reported during the download, so urllib must not have noticed a problem.

AllenSDK developers are investigating some sort of file consistency check and/or a different HTTP library.

https://github.com/AllenInstitute/AllenSDK/issues/28

If others run into this, you can delete the bad file and re-run the download function (BrainObservatoryCache.get_ophys_experiment_data). Files are downloaded into a subdirectory of the BrainObservatoryCache manifest file, which defaults to the current working directory if unspecified.