flatironinstitute / neurosift

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

Viewing a local running instance of neurosift using the jupyterhub proxy. #194

Open ovalerio opened 2 months ago

ovalerio commented 2 months ago

Hello Jeremy,

Thank you for developing neurosift. I think is a great software, to get to learn & debug NWB files.

I hope you can help me getting it to run locally. Let me explain what I am doing. I got an NWB that I am able to read inside a jupyter notebook: image

The file is in the staging jupyterhub from dandi.

I have installed neurosift using pip to be the latest version and run it from a jupyterhub terminal window passing the path of the nwb file. It looks as follows:

image

Then, I opened a second tab in the browser and enter the port and path that I got from neurosift:

https://hub-staging.dandiarchive.org/user/ovalerio/proxy/58981/tmp/view_nwb_sSXSRYZn

and it is showing empty: image

In the terminal where I run neurosift there is no error messages:

(suite2p) jovyan@jupyter-ovalerio:~$ neurosift view-nwb results_orig/suite2p/ophys.nwb 
npm version: 10.8.1
node version: v22.4.1

up to date, audited 65 packages in 2s

12 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Opening https://flatironinstitute.github.io/neurosift/?p=/nwb&url=http://localhost:58981/files/ophys.nwb

> local-file-access-js@0.0.1 start
> node src/index.js /tmp/view_nwb_sSXSRYZn

Serving files in /tmp/view_nwb_sSXSRYZn
Serving files in /tmp/view_nwb_sSXSRYZn on port 58981.

For the record, I am using Firefox in Ubuntu: image

Best, Omar

ovalerio commented 2 months ago

I also tried using the neurosift.app URL suggested on the command line and gave me a CORS. image

magland commented 2 months ago

Hi @ovalerio . The issue is that the server is listening on that port on the dandihub instance, not on your local machine. So it's not going to work if you open a new tab on your browser.

I can see the appeal of using neurosift to view an .nwb file that is local to dandihub. But I can't think of a way to do it right now.

magland commented 2 months ago

@ovalerio

I thought of how you can do this!

In your jupyter notebook (on dandihub), run the following cell

from IPython.display import IFrame
ns_url = 'https://neurosift.app?p=/nwb&url=...'
display(IFrame(ns_url, width='100%', height=800))

where you'd fill in the appropriate url. Adjust the height as appropriate.

ovalerio commented 2 months ago

@magland Thanks!

I will try this once dandihub is back online and come back here to share the result.

ovalerio commented 2 months ago

@magland

Hello again, I tried your suggestion and it is working as far as I can see. :+1:

The neurosift window was showing for a brief second (it was showing also the left navigation panels) and then I got an error message: "Problem loading file. Unable to load root group."

I'm not sure if the problem is due to my NWB file. I'm not getting that error when opening the file using the pynwb.NWBHDFIO module.

image

magland commented 2 months ago

First, make sure you have the latest neurosift python package

pip install --upgrade neurosift

If that doesn't work, is that file something you could share? Maybe email to me or put it in a downloadable location?

Alternatively, could you downloaded it to your local machine and try to view it without jupyter?