flatironinstitute / neurosift

Browser-based NWB visualization and DANDI exploration
Apache License 2.0
45 stars 6 forks source link

[Feature] Trial-aligned ROIResponseSeries #115

Closed weiglszonja closed 2 months ago

weiglszonja commented 11 months ago

For datasets that have behavioral trials, it would be good addition to have a trial-aligned view for ROIResponseSeries

CodyCBakerPhD commented 9 months ago

@magland I have some good examples for this now

draft dandiset is https://dandiarchive.org/dandiset/000728/draft - reuploads are likely so links to assets may not be entirely persistent but I will try to keep links here up to date

Current example: https://flatironinstitute.github.io/neurosift/?p=/nwb&url=https://api.dandiarchive.org/api/assets/5fe35951-5480-4fd0-94f8-7b139c994c9e/download/&dandisetId=000728&dandisetVersion=draft

Lots of RoiResponseSeries with a TimeIntervals we'd like to align to. In the dandiset, file names have 'Stim' for easy indication of experiment type, types B/C have a single TimeIntervals currently located in 'acquisition' (but in the future this will change to be located in 'stimuli' but type A only has the natural/spontaneous stimuli (which I'll file in a separate issue)

Would be really great to visualize average roi traces relative to this. Structure should also I think generally apply to any TimeSeries not just RoiResponseSeries

See NWB Widgets examples and discussion for an existing reference of particulars: https://github.com/NeurodataWithoutBorders/nwbwidgets/pull/232#issuecomment-1339253533

magland commented 9 months ago

Thanks. Maybe we should have a meeting about this?

CodyCBakerPhD commented 9 months ago

Sure, just grab a time on my calendly

magland commented 9 months ago

@CodyCBakerPhD @weiglszonja Here's my crack at it https://flatironinstitute.github.io/neurosift/?p=/nwb&url=https://api.dandiarchive.org/api/assets/5fe35951-5480-4fd0-94f8-7b139c994c9e/download/&dandisetId=000728&dandisetVersion=draft&tab=view:TrialAlignedSeries|/acquisition/static_gratings^/processing/ophys/DfOVerF/DfOverF

I don't see any interesting patterns in that particular dataset. I hope I am plotting it correctly. Would be nice to be able independently to compare this with plots prepared a different way. Is there a different dataset that we know has an interesting signal?

BTW, right now it only works for RoiResponseSeries/TimeIntervals pairs.

CodyCBakerPhD commented 9 months ago

@magland The plugin should support the 'group by' behavior for all those categorical columns; the table in question has three conditions (orientation, spatial_frequency, phase)

Quite possible that a patterns might only emerge under some selection of those conditions

BTW, would it be possible to for this group by to allow shift+selection of more than one condition, and in that event spawn a num_conditions x num_conditions grid of alignment plots for each ROI (or empty cell in grid if no joint occurrence of certain conditions)? That's also something I've wanted for the PSTH for a while; feel free to raise as separate issue if beyond this scope

CodyCBakerPhD commented 9 months ago

As far as past examples, I believe @h-mayorquin might have/know of some, but I forget if those files are public on DANDI yet (or still embargoed)?

h-mayorquin commented 9 months ago

The ones were I worked on this are not published yet. There were not that clear either if I remember well. As in, you needed to know what to group by so the patterns would emerge.

CodyCBakerPhD commented 7 months ago

@magland I have an explicit example for this

See this notebook: https://github.com/dandi/example-notebooks/blob/b02078be21acd03d6ac974933f8ddd5807b9a72c/000728/AllenInstitute/visual_coding_ophys_tutorial.ipynb

Towards the bottom (Part 4)

The Dandifile is sub-495727015/sub-495727015_ses-501559087-StimB_ophys.nwb: https://neurosift.app/?p=/nwb&url=https://api.dandiarchive.org/api/assets/694999ad-2005-421a-9c6f-f949283b9b59/download/&dandisetId=000728&dandisetVersion=draft

magland commented 7 months ago

Thanks @CodyCBakerPhD

https://neurosift.app/?p=/nwb&url=https://api.dandiarchive.org/api/assets/694999ad-2005-421a-9c6f-f949283b9b59/download/&dandisetId=000728&dandisetVersion=draft&tab=view:TrialAlignedSeries%7C/intervals/epochs%5E/processing/ophys/DfOverF/DfOverF

But I guess the group by option is important here?

Otherwise, is there anything else that needs to be added to make this more useful?

CodyCBakerPhD commented 7 months ago

The figure from part 4 of the notebook is not aligned to epochs, it's aligned to repeated stimulus times from one of the stimuli in the 'stimulus' section of the NWB file

Even for epochs, I also don't see the plugin button to get to this visualization - also, it might not just be DfOverF, as shown in part 4, it could be any RoiResponseSeries, such as an even further filtering from DfOverF

Group by would then also apply to various aspects of the stimulus - for the IndexSeries ones, one of the group by would be the 'index' (the data of that series) - for the other tables, it could be one of the one of the repeated parameters from the extra custom columns

magland commented 2 months ago

@CodyCBakerPhD @weiglszonja

I am revisiting this now. The trial aligned series has been improved to have all of the features of the PSTH, including grouping by variables.

Here's the above example now

https://neurosift.app/?p=/nwb&url=https://api.dandiarchive.org/api/assets/694999ad-2005-421a-9c6f-f949283b9b59/download/&dandisetId=000728&dandisetVersion=draft&tab=view:TrialAlignedSeries|/intervals/epochs^/processing/ophys/DfOverF/DfOverF

And another more recent example from 001084

https://neurosift.app/?p=/nwb&url=https://api.dandiarchive.org/api/assets/bca70a25-e5a5-4a40-b36f-fe1088b85eb2/download/&dandisetId=001084&dandisetVersion=draft&tab=view:TrialAlignedSeries|/processing/behavior/TimeIntervals^/processing/ophys/DfOverFFiberPhotometryResponseSeriesGreenIsosbestic&tab-state=H4sIAAAAAAAAA2WQT2vcMBBHv4vOr6D%2FkveYXJLrpu0llOLGilewlhdb2yWE%2Fe6RN7RQehlGb37zBPMu1nRMLzUN30quj8Mqds8%2F%2BAv3c34sQ35JG5coVCutapRBWZRDeVRARVSHRku0QrfGoC3aoT06oCO6w2AkRmE0pvUW4zAeEzAR02GxEquwGmuw7emwHhuwEdvhcBKncBpncBbXiMcFXMR1eLzEK7zGG7zFO3yDAR%2FxHYEgCYqgCYZgCY7gCY1HQkckSqKiayfoj3ksX%2Bfv%2FZL7X8fbAcRa%2B6X%2BrHlKoiXGZT6f7t7%2BJMROpN%2BptPnbKYn%2Fxvd9TeO85E%2FTPl36Zdgsl1yG%2BbLvy5ie6iJ275%2B%2FNNsX3SypDK214oo4Lel1vQUO28JaU4vX5Zy4kYe8tq3X%2FrhuYJrnekjDP%2FCQ8njYzFMa8nlq9nKe7nJpUiOv1w%2FwnTXDDAIAAA%3D%3D

CodyCBakerPhD commented 2 months ago

Cool! Thanks

LGTM