Booritas / slideio

BSD 3-Clause "New" or "Revised" License
49 stars 2 forks source link

ios_base::failbit set: iostream stream error #7

Closed mrymsadeghi closed 1 year ago

mrymsadeghi commented 1 year ago

I get this error for some czi slides, when I use this command slideio.open_slide(slidepath, "CZI") But for some slides this error does not happen. Do you know what could be the problem?

Complete error: Traceback (most recent call last): File "E:\PyProjects\src\testfile.py", line 6, in slide = slideio.open_slide(slidepath, "CZI") File "E:\PyProjects\venv39\lib\site-packages\slideio\py_slideio.py", line 229, in open_slide slide = Slide(path, driver) File "E:\PyProjects\venv39\lib\site-packages\slideio\py_slideio.py", line 164, in init self.slide = sld.open_slide(path, driver) RuntimeError: ios_base::failbit set: iostream stream error

Booritas commented 1 year ago

Hi, it is hard to say why this happens without images. Would it be possible to share an image that triggers the error? Best regards, Stanislav

mrymsadeghi commented 1 year ago

Hi Stanislav,

here is the link to the slide: https://drive.google.com/file/d/11YWkktAovgnqSmYFkjKrKQ9q3pluhYxK/view?usp=sharing

thanks for your help.

Booritas commented 1 year ago

Thanks for the file! I can reproduce the problem. At the first look, the internal file structure references regions outside of the file. I will investigate it in details and see what I can do. Original zeiss software can open the file, so should the library. I'll keep you posted. I would expect some info in a week or two, maybe even a fix.

Booritas commented 1 year ago

I investigated the problem. It appears that the file is corrupted. It contains 4 scenes. First 3 scenes are ok. The last scene contains reference to regions outside the file (the file was trimmed or the scanner did not save the complete file). I checked it with the original Zeiss software. It shows the last scene as an empty rectangle. It throws an error if you try to zoom.

Nevertheless, I applied some fix that avoids crashing and allows working with all valid regions. The library is already deployed with version 1.0.4. Now you can open the file and see 4 scenes. The last one will be presented only partially because of the file corruption.

You mentioned that it happens with several other files. The fix should work for them as well unless the files were corrupted differently. I would appreciate if you share such a file should a new problem appear.

Please let me know if the fix works for you.

Please consider giving a star to the repository if you like the library. Best regards, Stanislav

mrymsadeghi commented 1 year ago

Yes I tried it out now and it works. Thank you very much. I appreciate your help and support.