You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support visualizing multiple SpatialData objects #112
@melonora , would you be able to take this one? @LucaMarconato has some demo code already on the spatialdata branch. @LucaMarconato , can please link the code?
I have this also in follow up PRs which I did not open yet. I keep track of the spatialdata object in the layer metadata, similar to what Luca did on the spatialdata branch.
@kevinyamauchi@LucaMarconato After #120, I will add the possibility of having multiple spatialdata objects being visualized in one napari-spatialdata instance. This requires a few changes overall. This serves as an initial proposal.
Proposal
There are several ways by which a user could load multiple SpatialData objects.
Interactive(sdatas: list[SpatialData])
SpatialDataViewer.add_sdata(sdata: SpatialData)
Drag and drop interaction.
I believe the SpatialData objects ultimately can live as an EventedSet in SdataWidget. This allows us to create callbacks upon add, remove and discard
events among others. Currently other emitted events wouldn't be important I think.
Populating CoordinateSystemWidget and ElementWidget
In the SdataWidget initialization, the CoordinateSystemWidget and ElementWidget are both created. The widgets do not hold a reference to the SdataWidget, but callbacks can be created in the respective widgets and connected to the event in the SdataWidget. The respective callbacks would take care of populating the items of the widgets also when later adding or removing new data.
Of note is that elements of multiple spatialdata objects can have the same name. We would have to choose to either disallow it, be ok with napari showing "copied" names (integer between parentheses) or come up with an appropriate suffix. Dependent on choice there would be additional functionality of the callbacks in this section. Personally, I think the latter would have preference.
Thanks Wouter, I prefer 1. since it was what we used so far, but we could also allow the user to use add_sdata() later (this is actually what happens in the spatialdata branch: there is an equivalent private function that allows for that).
Drag and drops interactions would be also nice, but we can add it later.
Re the multiple names I would prefer having napari automatically handle it so that we don't have to add extra suffix logic.
I would say both option 1 and 2 are very doable, as initially the only thing that happens when adding a SpatialData object should be populating the CoordinateSystemWidget and the ElementWidget. This can be done by just adding items.
Regarding the names I think it would be nice to modify the copy names of the layer in such a way that it at least indicates which layers share the SpatialData object, but I would have to find out first what would be the best way to achieve that.
Activity
kevinyamauchi commentedon Jun 9, 2023
@melonora , would you be able to take this one? @LucaMarconato has some demo code already on the spatialdata branch. @LucaMarconato , can please link the code?
LucaMarconato commentedon Jun 9, 2023
Yes, for instance the commented line here is an example (the paths above needs to be adjusted): https://github.com/scverse/napari-spatialdata/blob/2590e1e8191091820478b470ef7aee8bfd322be8/src/napari_spatialdata/interactive.py#LL687C1-L687C42
melonora commentedon Jun 9, 2023
I have this also in follow up PRs which I did not open yet. I keep track of the spatialdata object in the layer metadata, similar to what Luca did on the spatialdata branch.
melonora commentedon Jun 9, 2023
I can open them, but they are branched from the layer_visibility branch so that was why I was waiting a bit.
melonora commentedon Jul 4, 2023
@kevinyamauchi @LucaMarconato After #120, I will add the possibility of having multiple spatialdata objects being visualized in one napari-spatialdata instance. This requires a few changes overall. This serves as an initial proposal.
Proposal
There are several ways by which a user could load multiple SpatialData objects.
Interactive(sdatas: list[SpatialData])SpatialDataViewer.add_sdata(sdata: SpatialData)I believe the
SpatialDataobjects ultimately can live as an EventedSet inSdataWidget. This allows us to create callbacks uponadd,removeanddiscardevents among others. Currently other emitted events wouldn't be important I think.
Populating
CoordinateSystemWidgetandElementWidgetIn the
SdataWidgetinitialization, theCoordinateSystemWidgetandElementWidgetare both created. The widgets do not hold a reference to theSdataWidget, but callbacks can be created in the respective widgets and connected to the event in theSdataWidget. The respective callbacks would take care of populating the items of the widgets also when later adding or removing new data.Of note is that elements of multiple spatialdata objects can have the same name. We would have to choose to either disallow it, be ok with napari showing "copied" names (integer between parentheses) or come up with an appropriate suffix. Dependent on choice there would be additional functionality of the callbacks in this section. Personally, I think the latter would have preference.
What do you think?
LucaMarconato commentedon Jul 4, 2023
Thanks Wouter, I prefer 1. since it was what we used so far, but we could also allow the user to use
add_sdata()later (this is actually what happens in thespatialdatabranch: there is an equivalent private function that allows for that).Drag and drops interactions would be also nice, but we can add it later.
Re the multiple names I would prefer having napari automatically handle it so that we don't have to add extra suffix logic.
melonora commentedon Jul 5, 2023
I would say both option 1 and 2 are very doable, as initially the only thing that happens when adding a
SpatialDataobject should be populating theCoordinateSystemWidgetand theElementWidget. This can be done by just adding items.Regarding the names I think it would be nice to modify the copy names of the layer in such a way that it at least indicates which layers share the
SpatialDataobject, but I would have to find out first what would be the best way to achieve that.melonora commentedon Sep 1, 2023
closed by #136