JingyiGF / HERBS

MIT License
18 stars 15 forks source link

Unable to load project with cell object #28

Closed mwawra closed 1 year ago

mwawra commented 1 year ago

When I save and reload a project with an object with manually marked cells I get the following error: Traceback (most recent call last): File "C:\Users\Matthias\Documents\Neurophys-INSERM\herbs_git\herbs\herbsgui.py", line 5555, in load_project_called self.load_project(p_dict) File "C:\Users\Matthias\Documents\Neurophys-INSERM\herbs_git\herbs\herbsgui.py", line 5429, in load_project self.set_hist_layer_to_hist_view(da_link, layer_data['2d_data'][i]) File "C:\Users\Matthias\Documents\Neurophys-INSERM\herbs_git\herbs\herbsgui.py", line 5131, in set_hist_layer_to_hist_view self.image_view.img_stacks.image_dict[layer_link].setData( File "C:\Users\Matthias\anaconda3\envs\conda_herbs\lib\site-packages\pyqtgraph\graphicsItems\ScatterPlotItem.py", line 499, in setData self.addPoints(*args, **kargs) File "C:\Users\Matthias\anaconda3\envs\conda_herbs\lib\site-packages\pyqtgraph\graphicsItems\ScatterPlotItem.py", line 601, in addPoints setMethod(kargs[k], update=False, dataSet=newData, mask=kargs.get('mask', None)) File "C:\Users\Matthias\anaconda3\envs\conda_herbs\lib\site-packages\pyqtgraph\graphicsItems\ScatterPlotItem.py", line 725, in setSymbol raise Exception("Number of symbols does not match number of points (%d != %d)" % (len(symbols), len(dataSet))) Exception: Number of symbols does not match number of points (0 != 5)

JingyiGF commented 1 year ago

just update code on GitHub, did finishing all testing. The logic for cells is a bit strange I think (hmmm, I think I am not the best coder), When users click on Histological image window, the cell count increases, and a hidden vector (say it is named A) contains the corresponding symbols for cell points in Histological image window also increases. When transferring cells into atlas window, the A is cleared and the actual values of the the corresponding symbols for cell points transferred to a hidden vector (say B) for atlas window. When make a cell piece, B is cleared again. This part of code has been modified so many times, the 1st version is that, when make a piece, the corresponding layer is deleted automatically. In this way, empty A and B will not generate any problem. But.. There was a request wants to keep all layers even after transferring and making pieces. Then the old saving and loading cell projects will leads to the error you got. I modify the code, and will write more on this in the tutorial later. Let me know if anything goes wrong.

mwawra commented 1 year ago

Hi, thanks for the fix. As far as I can see it works no as expected. Only thing I realized is that "Total Count" is always 1. Correct me if I'm wrong, but probably len(data['data']) on line 188 in object_control.py should be len(data['data'][0]).

JingyiGF commented 1 year ago

You are right. Before data['data'] was a concatenated ndarray of all pieces. Now after modifying the un-merging, data['data'] is a list of all pieces data. so should first concatenate all list together and then take len. Will change it later.

JingyiGF commented 1 year ago

fixed total count.

mwawra commented 1 year ago

Thanks, while you are at it, you maybe can push self.object_3d_list = object_data['object_3d_list'] on line 5523 in herbsgui.py behind the if object_data is not None:. Prevents errors when loading projects without objects.

JingyiGF commented 1 year ago

Sure. Thanks! Will do it after dinner 😄

在 2022年11月23日,15:52,Matthias Dipper-Wawra @.***> 写道:

 Thanks, while you are at it, you maybe can push self.object_3d_list = object_data['object_3d_list'] on line 5523 in herbsgui.py behind the if object_data is not None:. Prevents errors when loading projects without objects.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

mwawra commented 1 year ago

Bon appétit :)