kushalkolar / MESmerize

Platform for Calcium Imaging analysis. DEPRECATED.
GNU General Public License v3.0
58 stars 14 forks source link

[BUG] <Loading k-shape project plot error> #69

Closed pr4deepr closed 1 year ago

pr4deepr commented 2 years ago

Describe the bug I've performed the K-shape analysis and saved the plot within the project as a .ptrn file. If I reopen Mesmerize and try to access the k_shape plot again, I get the error:

Screenshots image


Traceback (most recent call last):
  File "D:\Anaconda3\envs\mesmerize\lib\site-packages\mesmerize\common\qdialogs.py", line 52, in fn
    return func(self, *args, **kwargs)
  File "D:\Anaconda3\envs\mesmerize\lib\site-packages\mesmerize\plotting\widgets\base.py", line 229, in open_plot
    self.set_plot_opts(plot_state)
  File "D:\Anaconda3\envs\mesmerize\lib\site-packages\mesmerize\plotting\widgets\kshape\widget.py", line 933, in set_plot_opts
    setattr(self, k, opts[k])
  File "D:\Anaconda3\envs\mesmerize\lib\site-packages\mesmerize\plotting\widgets\kshape\widget.py", line 481, in _ksgrid_json
    self.ksgrid = kga
  File "D:\Anaconda3\envs\mesmerize\lib\site-packages\mesmerize\plotting\widgets\kshape\widget.py", line 394, in ksgrid
    if self.n_clusters_out[ij] < self.ksgrid[ij].n_clusters:
IndexError: too many indices for array

If I click OK, I get the main k-shape clustering window with the clusters in the center, but I do not get the interactive plot on the side with clusters of different inertia.

If I run: this.inertia_sorted.head() now, I get this error as well:

    Traceback (most recent call last):
      File "D:\Anaconda3\envs\mesmerize\lib\site-packages\mesmerize\pyqtgraphCore\console\Console.py", line 167, in execSingle
        output = eval(cmd, self.globals(), self.locals())
      File "<string>", line 1, in <module>
    AttributeError: 'NoneType' object has no attribute 'head'

I will have to re-run the clustering if I'd like to view the interactive plot for choosing clusters.

Operating System & specs (CPU, RAM etc.). Please complete the following information:

Details about your Mesmerize install

Thanks

Pradeep

kushalkolar commented 2 years ago

Thanks for providing details! I can take a look at this next week, I have an important exam this weekend.

@DanielDondorp you could check this out if you have time.

DanielDondorp commented 2 years ago

I will try and see if I can reproduce this or say something sensible about it.

kushalkolar commented 2 years ago

@pr4deepr @DanielDondorp I think that the gridsearch isn't saved to file, only the iteration which you have chosen. You really only need the final iteration which was the best and I don't see the purpose of looking through the other iterations on the grid again.

pr4deepr commented 2 years ago

Thanks @kushalkolar and @DanielDondorp Ahh, thats good to know. So, as long as we make a selection after the analysis it should be saved, right?

The reason I asked is I think it would be useful feature if:

However, instead of saving the gridsearch, is there a way to document or share the choice of the grid?

Cheers Pradeep

kushalkolar commented 2 years ago

@pr4deepr Sorry for the late response (been cleaning up issues this weekend). Let me know if you want to chat sometime for help on implementing this.

pr4deepr commented 2 years ago

I'm not sure how to go about it, but happy to give it a try.. If you could give me some pointers on where to look and how you'd approach it, that would give me a good start!

kushalkolar commented 2 years ago

All the kshape related code is here: https://github.com/kushalkolar/MESmerize/tree/master/mesmerize/plotting/widgets/kshape

So the ksgrid is saved as a json string within the .ptrn hdf5 file structure: https://github.com/kushalkolar/MESmerize/blob/master/mesmerize/plotting/widgets/kshape/widget.py#L950

You might want to play around here to set the ksgrid_json directly: https://github.com/kushalkolar/MESmerize/blob/master/mesmerize/plotting/widgets/kshape/widget.py#L843

I'm pretty busy until mid/late April but I could help you sometime in the latter half of April