Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load histology image - object of type 'NoneType' has no len() #11

Open
JHartig opened this issue Oct 3, 2022 · 12 comments
Open

Comments

@JHartig
Copy link

JHartig commented Oct 3, 2022

Hey guys. I installed HERBS a few days ago via Anaconda and python 3.8.
However, now I am unable to load any histological image, be it .tiff, .png or a .czi file.
It always gives me the following error type:

TypeError: object of type 'NoneType' has no len()

Also, after loading the atlas volume (Mouse brain, Allen, 10um), the atlas is properly display and everything's working in 3D, however there are these 2 error lines popping up. Any idea what this means:

Traceback (most recent call last):
File "C:\Users\AG Ip\Anaconda3\envs\herbs\lib\site-packages\herbs\herbsgui.py", line 5084, in load_previous_atlas
self.load_volume_atlas(atlas_folder)
File "C:\Users\AG Ip\Anaconda3\envs\herbs\lib\site-packages\herbs\herbsgui.py", line 5037, in load_volume_atlas
self.set_volume_atlas_3d(unique_label, meshdata, small_meshdata_list)
File "C:\Users\AG Ip\Anaconda3\envs\herbs\lib\site-packages\herbs\herbsgui.py", line 4952, in set_volume_atlas_3d
mesh = gl.GLMeshItem(meshdata=small_meshdata_list[str(id)], smooth=True,
KeyError: '545'
test multi series
Traceback (most recent call last):
File "C:\Users\AG Ip\Anaconda3\envs\herbs\lib\site-packages\herbs\herbsgui.py", line 4753, in load_image
self.load_single_image_file(self.current_img_path, image_file_type)
File "C:\Users\AG Ip\Anaconda3\envs\herbs\lib\site-packages\herbs\herbsgui.py", line 4808, in load_single_image_file
self.image_view.set_data(image_file)
File "C:\Users\AG Ip\Anaconda3\envs\herbs\lib\site-packages\herbs\image_view.py", line 262, in set_data
self.volume_img = copy.deepcopy(self.image_file.data['scene 0'])
KeyError: 'scene 0'

All the best,

Johannes

@JingyiGF
Copy link
Owner

JingyiGF commented Oct 3, 2022 via email

@JHartig
Copy link
Author

JHartig commented Oct 3, 2022

Python 3.8.13, 64bit, windows 10 pro, pyqt5 =5.15.7, pyqtgraph=0.12.3, Version of HERBS should be the most current one

@JHartig
Copy link
Author

JHartig commented Oct 3, 2022

For some I couldn't pull 3.8.10, but I hope that's not the issue, as generally everything is running. So whenever I open the downloaded 10um Allen mouse brain atlas, it gives me this error:

Traceback (most recent call last):
File "C:\Users\AG Ip\Anaconda3\envs\herbs\lib\site-packages\herbs\herbsgui.py", line 5052, in load_atlas_clicked
self.load_volume_atlas(atlas_folder)
File "C:\Users\AG Ip\Anaconda3\envs\herbs\lib\site-packages\herbs\herbsgui.py", line 5037, in load_volume_atlas
self.set_volume_atlas_3d(unique_label, meshdata, small_meshdata_list)
File "C:\Users\AG Ip\Anaconda3\envs\herbs\lib\site-packages\herbs\herbsgui.py", line 4952, in set_volume_atlas_3d
mesh = gl.GLMeshItem(meshdata=small_meshdata_list[str(id)], smooth=True,
KeyError: '545'

@JHartig
Copy link
Author

JHartig commented Oct 3, 2022

If you tell me how to find out which version of HERBS I downloaded, I'll happily tell you (Coding beginner here ;) )

@JHartig
Copy link
Author

JHartig commented Oct 3, 2022

UPDATE @JingyiGF : So the importing of images works now. Don't ask me why it works now. But the '545' error is still there after I imported the atlas. However until now that didn't affect functionality.

I'd be interested nonetheless in what the 'scene 0' and '545' errors mean, in case I encounter them again.

Many thanks.

Best,

Johannes :)

@JingyiGF
Copy link
Owner

JingyiGF commented Oct 4, 2022

Hi Johannes,

Sorry for the late reply. And thank you for the checking and clear error messages and updates. it is a bit difficult for me to test and reply out of working hours.

There were basically two errors, one is for '545' and the other one is for 'scene 0'. '545' is a the label for a brain region, this label exists in the segmentation/annotation file. However, if you check the meshes that can be downloaded from http://download.alleninstitute.org/informatics-archive/current-release/mouse_ccf/annotation/ccf_2017/structure_meshes

you will see that there is no 545.obj file. This is because this brain region is labeled on only two voxels, which can not be made as a 3D mesh.

Since there is no such a mesh file for label with id==545, I basically just ignore this file in the old code while processing it. But apparently it shows an error while loading the atlas. I update the code to deal with it now.

Well, I had another open issue also stated the same problem while loading histological images. However I could not re-produce the error message, I am still debugging to see what the problem is. But for 'scene 0', it is the key I use to store multiple images when the loading file has .czi format. As .czi file can contains multiple images and each image can be viewed separately (with different scene), so 'scene x' indicates which image is displayed. When only one .jpg file loaded, there is only 'scene 0' as the whole file is considered to be as one image.

I hope my explanation is clear and this helps. Please let me know when there is other issues or you find the problem while loading histological images. And please update the code and reprocess the atlas.

Do you still have the problem while loading histological images?

Best,
Jingyi

@JHartig
Copy link
Author

JHartig commented Oct 4, 2022 via email

@JingyiGF
Copy link
Owner

JingyiGF commented Oct 4, 2022

Good idea. I will try to make one when I finish other things :-)

I remember I have seen .czi file with the same type of problems. It was a file that contains no images, but only notes for scanning.

Ok let us see how it looks, if you run the following code, where czi_path is a string of the path of your .czi file.

from aicspylibczi import CziFile

czi = CziFile(czi_path)
czi_info = czi.dims
dimensions = czi.get_dims_shape()
is_mosaic = czi.is_mosaic()
pixel_type = czi.pixel_type

len(dimensions)

if you print out and show me czi_info, dimensions, is_mosaic, and pixel_type, we probably can find the problem :-)

@JingyiGF
Copy link
Owner

JingyiGF commented Oct 4, 2022

I was thinking to screen shot some anaconda updates thing and how to control packages thing when I was at work. But I eventually left work a bit earlier today.... you don't have to create a new env, just go to the terminal in the env you have, pip install herbs==0.0.17, other packages will be checked, but not installed again (because they are already there). I only have PyCharm and virtualenv at home, I will take screen shot for you tomorrow when I am at work.

@JingyiGF
Copy link
Owner

JingyiGF commented Oct 5, 2022

I made 2 screenshots and make a file 'create environment using Anaconda' in Tutorial on GitHub. Please go to HERBS-code to check. Hope this helps.

@JHartig
Copy link
Author

JHartig commented Oct 13, 2022

Hey Jingyi. Thanks a lot for the detailed info. I got the new version running, and everything's going smoothly for now! I will let you know regarding the CZI thing, when I've got time to test it out

@JHartig
Copy link
Author

JHartig commented Oct 13, 2022

Hey! Came across another error. I saved a project and tried to reload it.
Didn't work and it spit out the following error lines

Traceback (most recent call last):
File "C:\Users\AG Ip\Anaconda3\envs\herbs\lib\site-packages\herbs\herbsgui.py", line 5733, in load_project_called
p_dict = pickle.load(infile)
EOFError: Ran out of input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants