Open zoccoler opened 2 years ago
@zoccoler if you want to plot images with a time dimension you could take a look at napari-time-series-plotter
.
This widget uses napari-matplotlib
as basis for its plotting and has multiple modes to visualise time series.
Just for transparency I'm the maintainer of napari-time-series-plotter
.
Thanks for the suggestion, it sounds super interesting! I don't have time to properley think about this (but I didn't go immediately to no), but in the new year I will be working on napari-matplotlib
with a CZI grant, so I will get back to you then - I hope that's okay! 😃
Hi Christopher @ch-n, thanks for the hint! It seems you have quite some functionalities there for time-series! I am actually aiming in something more general, I mentioned time-series as a good example, but I would like to leave it to whatever array a developer would put in the layer metadata.
@dstansby congratulations for the grant!! That's totally fine, I put the code in this branch (https://github.com/zoccoler/napari-matplotlib/tree/line_plot_widget). I would PR to move discussion there if that's OK.
Looking forward for this functionality!
Hey @zoccoler I'm just looping back to this and wanted to understand use cases. There is currently a features scatter widget that can be used to scatter two features against each other. Would you like to have exactly the same functionality here, but with the points connected with a line?
Overall, yes! I started around the layer metadata to be able to work with the Image layer, but as I mentioned in the PR just now I would be more interested in the features
I just released a napari plugin which may better show where I would like to go with this: https://github.com/zoccoler/napari-signal-selector
Maybe a part of the code there could/should belong here.
I'm still slightly confused about https://github.com/matplotlib/napari-matplotlib/pull/200, and have some suggestions that might help that I could add to that PR. However my intuition is that the widget in #200 is a bit more specialised than the other existing widgets, therefore I'm not 100% on whether it should go in.
Is all the functionality you want now implemented in https://github.com/zoccoler/napari-signal-selector? If so would you still like to push for #200 to go in napari-matplotlib
or not? I'm happy to try and understand #200 a bit more and suggest improvements, but I'm not completely sold on it at the moment.
Sure, let me try to explain my reasoning and you check what makes sense for napari-matplotlib or not.
LineBaseWidget
would be a simple base class for drawing line plots, similar to what you have as ScatterBaseWidget
but it employs .plot
instead of .scatter
or .hist2d
to have Line2D
artists.FeaturesLineWidget
would be similar to FeaturesScatterWidget
with the difference that, since line plots better relate to ordered data, there is a need for a grouping part based on some object_id
column (like in this line).Both these classes I have put in my line.py
file for now and those are the same suggested in #200. I thought they could belong here because they are basic line plots and IMO they differ from what you have in slice.py
where you plot line profiles directly from the image.
Now, what I am bringing extra on my plugin is making these line plots interactive, basically creating a special Line2D
class here and a derived widget class to have more methods and toolbuttons here, which allow selection and annotation of these lines.
The only "problem" is that eventually I had to overwrite the draw
method to be able to store, keep track and update these new InteractiveLine2D
instances (for example here) using axes.add_line
here.
Hi @dstansby , hi all,
I currently have a couple local implementations of a plotter with line plots based on metadata. Data are stored in metadata because sometimes I generate data from intensity images which in napari, as far as I know, do not have 'properties' or 'features'. I would like to have a general line plotter to import from. Thus, I naturally thought about napari-matplotlib!
To encompass all layer types, including the Image layer, I thought about storing the plotting data as a nested dictionary in the layer metadata, somtehing like:
I have some code that works with that kind of structure. Would that be an interesting contribution here? From a plugin developer's perspective, storing data as a two level dictionary would allow filtering data origin (by 'plugin_name', so different plugins could fit) apart from regular image metadata and then axes would come from the internal keys. @kevinyamauchi , do you think such structure would be interesting?
Here is an example:
For example, for plotting a time series, a developer could include a time dimension array there as well.
If this should not belong here, that's also OK, I could place it somewhere else, just let me know ;) I can make a Draft PR to further discuss this.
Best, Marcelo