Skip to content

Commit

Permalink
Merge pull request #41 from psobolewskiPhD/update_binder
Browse files Browse the repository at this point in the history
Update binder config and instructions
  • Loading branch information
psobolewskiPhD authored Oct 19, 2024
2 parents d9224f0 + 4bb5f0f commit 79d6c96
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 20 deletions.
4 changes: 3 additions & 1 deletion binder/apt.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
dbus-x11
firefox
xfce4
xfce4-panel
xfce4-session
xfce4-settings
xorg
xubuntu-icon-theme
tigervnc-standalone-server
tigervnc-xorg-extension
libegl1
libx11-xcb-dev
libglu1-mesa-dev
libxrender-dev
Expand Down
13 changes: 8 additions & 5 deletions binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ name: binder
channels:
- conda-forge
dependencies:
- python=3.9
- jupyter-server-proxy>=1.4
- python=3.11
- jupyterlab
- jupytext
- pip
- jupyterlab-myst
- napari
- pyqt
- jupyter-book
- websockify
- libxcb
- pip
- pip:
- jupyter-desktop-server
- jupyter-remote-desktop-proxy
3 changes: 0 additions & 3 deletions binder/postBuild

This file was deleted.

2 changes: 1 addition & 1 deletion napari-workshops/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ logo: logo.ico
only_build_toc_files: true

launch_buttons:
notebook_interface : classic # The interface interactive links will activate ["classic", "jupyterlab"]
notebook_interface : "jupyterlab" # The interface interactive links will activate ["classic", "jupyterlab"]
binderhub_url : https://mybinder.org # The URL of the BinderHub (e.g., https://mybinder.org)

# Force re-execution of notebooks on each build.
Expand Down
28 changes: 18 additions & 10 deletions napari-workshops/docs/launching_binder.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
# How to open your notebooks using [mybinder.org](https://mybinder.org)
# How to open the notebooks in the cloud using [mybinder.org](https://mybinder.org)

If you can't install the Jupyter notebook application locally, or if you prefer using a cloud instance of Jupyter to execute and interact with your workshop notebooks, you can follow this guide.
If you can't install napari and the Jupyter notebook application locally, or if you prefer using a cloud instance of Jupyter to execute and interact with the workshop notebooks, you can follow this guide.

```{note}
Because this will launch a virtual machine in the cloud and install everything needed to run the notebook, it could take *several minutes* to spin up!
```

## Open a single notebook in Binder

To open a single notebook in Binder, click the rocketship badge at the top of each notebook, and click on "Binder".
To open a notebook in Binder, click on the rocketship badge at the top of a notebook and click on "Binder".

![Binder badge shown in the "Bioimage visualization in Python" notebook](./images/binder_button.png)

This will open the notebook in Markdown format, but it will not be runnable. Further, because napari is a desktop application, we need a "Desktop" tab to see the napari GUI interface. To do this, close the Markdown notebook and return to the Jupyter launcher.

## Open desktop tab

Because napari is a desktop application, we need a "Desktop" tab to see the napari GUI interface. In the Jupyter launcher tab, click on "Desktop".
In the Jupyter launcher tab, click on the "Desktop" tile.

![Desktop tab button in Jupyter launcher tab](./images/desktop_tab.png)

After this, you should see a new tab open up in your browser window called "noVNC", with a basic desktop interface.
After this, you should see a new tab open up in your browser window called "Jupyter Remote Desktop Proxy", with a basic Linux desktop interface. Note if at first it doesn't connect, just close the tab and click the `D` tile a second time.

![Desktop interface shown in browser tab](./images/desktop.png)

By moving your mouse pointer inside this desktop interface, you should be able to interact with it. We will use it to host the napari GUI window.

## Run notebook cells

Now that our desktop is set up, we can proceed to running each of the cells in the notebooks.
Now that our desktop is set up, we can proceed to running each of the cells in the notebook. You can access them from the file browser on the left side, in the `notebooks` folder.

To open a notebook from this Jupyter interface, right click the notebook name in the file navigation panel from the Jupyter interface, and click "Open with -> Notebook".
```{important}
To open these workshop notebooks in this Jupyter interface, right click the notebook name in the file navigation panel from the Jupyter interface, and click "Open with -> Notebook".
![Right click on "intro_bioimage_visualization.md" file, and select "Open with -> Notebook"](./images/open_with_notebook.png)
You will note that these notebooks contain a code cell which needs to be run to enable the Binder interface.
Additionally, all of these notebooks contain a code cell which needs to be run to enable the napari window to be displayed in the Binder Desktop tab.
![First code cell for all notebooks, required to run the notebooks on Binder](./images/prepare_binder.png)
```

Note that every napari operation will be shown in the desktop tab of your browser, and will only be visible in the notebook interface after the `nbscreenshot` function is called. After running any cell which opens the napari viewer from the Jupyter notebook, you should now see the napari GUI window in the Desktop tab on your browser.
After running any cell which opens the napari viewer from the Jupyter notebook, you should now see the napari GUI window in the Desktop tab on your browser.

![napari interface in Desktop tab](./images/napari_desktop.png)

## Interact with the notebook!

You should now be able to interact with this notebook, by executing all cells and observing the results in the napari GUI window. You can also edit the code cells to experiment with different napari concepts and its API.
You should now be able to interact with this notebook, by executing all cells and observing the results in the napari GUI window. You can also edit the code cells to experiment with different napari concepts and its API. You can save a snapshot of the viewer status to the notebook using the `nbscreenshot` function.
15 changes: 15 additions & 0 deletions napari-workshops/notebooks/spot_detection_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ There are a number of ways to go about creating your own widgets, you can see [a

In this module, we will implement elements of our previous workflow as functions and then use [`magicgui.magicgui`](https://pyapp-kit.github.io/magicgui/api/magicgui/#magicguimagicgui) decorator on those functions to return us compound widgets that we can use to make exploring the parameters easier in the GUI. For a nice overview of the `magicgui` decorators, see [the official documentation](https://pyapp-kit.github.io/magicgui/decorators/).

## `binder` setup

```{code-cell} ipython3
:tags: [remove-output]
# this cell is required to run these notebooks on Binder. Make sure that you also have a desktop tab open.
import os
if 'BINDER_SERVICE_HOST' in os.environ:
os.environ['DISPLAY'] = ':1.0'
```

## Loading data

Let's get everything set up, based on the previous notebook:

```{code-cell} ipython3
Expand All @@ -45,6 +58,8 @@ viewer.add_image(nuclei, colormap = 'I Forest', blending = 'minimum')
viewer.add_image(spots, colormap = 'I Orange', blending='minimum')
```

## A basic filtering function

Now let's write a function that takes an array and a `sigma` value and performs the
high-pass operation.

Expand Down

0 comments on commit 79d6c96

Please sign in to comment.