Skip to content
Snippets Groups Projects
Commit 1a7afaf7 authored by Marvin Albert's avatar Marvin Albert
Browse files

WIP

parent ef6637bb
No related branches found
No related tags found
No related merge requests found
......@@ -2,4 +2,5 @@
/.vscode/
*checkpoints*
/2021/
/additional/
\ No newline at end of file
/additional/
_build/
# Full project: https://gitlab.com/pages/jupyterbook
stages:
- build
- deploy
jupyter-build:
stage: build
image: python:slim
script:
- pip install -U jupyter-book
- jupyter-book clean .
- jupyter-book build .
artifacts:
paths:
- _build/
pages:
stage: deploy
image: busybox:latest
script:
- mv _build/html public
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/guiwitz/PyImageCourse_beginner/master?urlpath=lab)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/guiwitz/PyImageCourse_beginner/blob/master)
[![launch - renku](https://img.shields.io/badge/launch-renku-2ea44f?logo=python)](https://renkulab.io/projects/guillaume.witz2/pyimagecourse-beginner/sessions/new?autostart=1)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/m-albert/PyImageCourse_beginner/master?urlpath=lab)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/m-albert/PyImageCourse_beginner/blob/master)
[![launch - renku](https://img.shields.io/badge/launch-renku-2ea44f?logo=python)](https://renkulab.io/projects/marvin.albert/pyimagecourse-beginner/sessions/new?autostart=1)
[![DOI](https://zenodo.org/badge/173477371.svg)](https://zenodo.org/badge/latestdoi/173477371)
# Image processing for beginners
This repository contains a set of Jupyter notebooks to learn how to do basic image processing using Python and the scientific packages Numpy, scikit-image, Matplotlib and Pandas.
The material assumes no pre-existing knowledge in programming but some familiarity with concepts of image processing. The goal of the course is not to learn all the details of Python, but to reach as fast as possible the ability to write short image processing scripts. The course therefore focuses only on essential knowledge and is not at all *exhaustive*.
## Running the notebooks
## Installation / Running the notebooks
### Alternative: Run the notebooks in the cloud
The notebooks in this repository can be run interactively using different cloud services. You can use the badges at the top of this Readme to run the notebooks either
- in the classical Jupyter environment via
- MyBinder
- Renkulab
- as Google Colab notebooks
The Mybinder and Renkulab sessions are only temporary, i.e. changes you make to notebooks or new notebooks are *erased* between sessions. When using Colab, to keep your changes, you need to *save a copy* of the notebook you are modifying. The saving is done in your Google Drive.
## Acknowledgements / Copyright
The material for this course and this repository has been copied from [this course](https://github.com/guiwitz/PyImageCourse_beginner) created by Guillaume Witz [![DOI](https://zenodo.org/badge/173477371.svg)](https://zenodo.org/badge/latestdoi/173477371). All credit goes to Guillaume Witz.
You don't need to install anything on your computer to interactively run the notebooks. You can use the badges at the top of this Readme to run the notebooks either in the classical Jupyter environment via MyBinder or as Google Colab notebooks. The Mybinder sessions are only temporary, i.e. changes you make to notebooks or new notebooks are *erased* between sessions. When using Colab, to keep your changes, you need to *save a copy* of the notebook you are modifying. The saving is done in your Google Drive.
Installation instructions have been taken from the [Open Image Data Handbook](https://kevinyamauchi.github.io/open-image-data/intro.html) by Kevin Yamauchi.
## Data
......
format: jb-book
root: README
chapters:
- file: book/setup_environment.md
- file: 01-Python_essentials
- file: 02-Images_as_arrays
- file: 03-More_on_images
......
# Downloading the course material
## Downloading the notebooks.
During this tutorial, we will be working through a set of notebooks. On this page, we will download the notebooks and launch jupyter notebook. There are two ways to download the notebooks: download as a .zip from github. Follow the instructions below for either "downloading zip" (recommended for beginners) or "cloning via git".
### Downloading .zip
You can download the notebooks as a .zip file. To do so, please do the following:
1. Navigate your web browser to: [https://github.com/kevinyamauchi/neubias-napari-workshop](https://github.com/kevinyamauchi/neubias-napari-workshop)
2. Click the green "Code" button to open the download menu and then "Download ZIP"
![download code](./resources/download_code.png)
3. Choose the location you would like to download the .zip.
4. Open your file browser and double click on the .zip file to uncompress it.
5. You have downloaded the notebooks! Proceed to the "Launching jupyter notebook" section.
### Cloning via git
You can use git to clone the repository containing the tutorial materials to your computer. We recommend cloning the materials into your Documents folder, but you can choose another suitable location. First, open your Terminal navigate to you the folder you will download the course materials into
```bash
cd ~/Documents
```
and then clone the repository. This will download all of the files necessary for this tutorial.
```bash
git clone https://github.com/kevinyamauchi/neubias-napari-workshop.git
```
## Launch jupyter notebook
Open your terminal and navigate to the `notebooks` subdirectory of the `embl-napari-workshop` directory you just downloaded.
```
cd <path to neubias-napari-tutorial>/notebooks
```
Now activate your `napari-tutorial` conda environment you created in the installation step.
```
conda activate napari-tutorial
```
We will perform the analysis using Jupyter Notebook. To start Jupyter Notebook, enter
```bash
jupyter notebook
```
Jupyter Notebook will open in a browser window and you will see the following notebooks:
- `part_0_spot_detection_tutorial_<beginner, advanced, solution>.ipynb`: in this notebook you will write a custom function to perform spot detection.
![jupyter notebook](./resources/jupyter_notebook.png)
# Install python
## Overview
This how-to teaches how to install python on your computer using `mambaforge`. `mambaforge` is a python distribution pre-installed with the [`mamba`package manager](https://mamba.readthedocs.io/en/latest/index.html) and pre-configured to use the `conda-forge` channel. I generally recommend installing this route, as I find it to be the most straight forward and I prefer to use `mamba` over `conda`, as it is much faster.
**Prerequisites**
- You have a computer with linux, MacOS, or Windows installed
**Related reading**
- [mamba documentation](https://mamba.readthedocs.io/en/latest/index.html)
## Instructions
Select the installation instructions for your operating system and processor from the tabs below.
````{tab-set}
```{tab-item} Linux
1. In your web browser, navigate to the [miniforge page](https://github.com/conda-forge/miniforge#mambaforge).
2. Scroll down to the "Mambaforge" header of the "Downloads" section. Click the link to download link for `Mambaforge-Linux-x86_64`.
3. Open your terminal application
4. Navigate to the folder you downloaded the installer to (usually this is in your Downloads folder). If the file was downloaded to your Downloads folder, you would enter:
```bash
cd ~/Downloads
```
5. Execute the installer with the command below. You can use your arrow keys to scroll up and down to read the license agreement and enter "yes" if you agree.
```bash
bash Mambaforge-Linux-x86_64.sh
```
6. After installation, you will be asked if you would like to initialize your terminal with "conda init". Enter "yes" to initalize your terminal.
7. To verify your installation worked, close your Terminal window and open a new one. You should see `(base)` to the left of your prompt.
```{admonition} Don't see (base)?
You can manually initialize conda by entering the command below and re-opening your terminal application.
```bash
conda init
```
```
```{tab-item} Mac OS (Intel)
1. In your web browser, navigate to the [miniforge page](https://github.com/conda-forge/miniforge#mambaforge).
2. Scroll down to the "Mambaforge" header of the "Downloads" section. Click the link to download link for `Mambaforge-MacOSX-x86_64`.
3. Open your Terminal (you can search for it in spotlight - `cmd` + `space`)
4. Navigate to the folder you downloaded the installer to (usually this is in your Downloads folder). If the file was downloaded to your Downloads folder, you would enter:
```bash
cd ~/Downloads
```
5. Execute the installer with the command below. You can use your arrow keys to scroll up and down to read the license agreement and enter "yes" if you agree.
```bash
bash Mambaforge-MacOSX-x86_64.sh
```
6. After installation, you will be asked if you would like to initialize your terminal with "conda init". Enter "yes" to initalize your terminal.
7. To verify your installation worked, close your Terminal window and open a new one. You should see `(base)` to the left of your prompt.
```{admonition} Don't see (base)?
You can manually initialize conda by entering the command below and re-opening your terminal application.
```bash
conda init
```
```
```{tab-item} Mac OS (M1/M2)
1. In your web browser, navigate to the [miniforge page](https://github.com/conda-forge/miniforge#mambaforge).
2. Scroll down to the "Mambaforge" header of the "Downloads" section. Click the link to download link for `Mambaforge-MacOSX-arm64`.
3. Open your Terminal (you can search for it in spotlight - `cmd` + `space`)
4. Navigate to the folder you downloaded the installer to (usually this is in your Downloads folder). If the file was downloaded to your Downloads folder, you would enter:
```bash
cd ~/Downloads
```
5. Execute the installer with the command below. You can use your arrow keys to scroll up and down to read it/agree to it.
```bash
bash Mambaforge-MacOSX-arm64.sh
```
6. After installation, you will be asked if you would like to initialize your terminal with "conda init". Enter "yes" to initalize your terminal.
7. To verify your installation worked, close your Terminal window and open a new one. You should see `(base)` to the left of your prompt.
```{admonition} Don't see (base)?
You can manually initialize conda by entering the command below and re-opening your terminal application.
```bash
conda init
```
```
```{tab-item} Windows
1. In your web browser, navigate to the [miniforge page](https://github.com/conda-forge/miniforge#mambaforge).
2. Scroll down to the "Mambaforge" header of the "Downloads" section. Click the link to download link for `Mambaforge-Windows-x86_64`.
3. Find the file you downloaded (Mambaforge-Windows-x86_64.exe) and double click to execute it. Follow the instructions to complete the installation.
4. Once the installation has completed, you can verify it was correctly installed by searching for the "mambaforge prompt" in your Start menu.
```
````
\ No newline at end of file
# Downloading and launching the notebooks
## Downloading the notebooks.
During this tutorial, we will be working through a set of notebooks. On this page, we will download the notebooks and launch jupyter notebook. There are two ways to download the notebooks: download as a .zip from github. Follow the instructions below for either "downloading zip" (recommended for beginners) or "cloning via git".
### Downloading .zip
You can download the notebooks as a .zip file. To do so, please do the following:
1. Navigate your web browser to: [https://github.com/kevinyamauchi/neubias-napari-workshop](https://github.com/kevinyamauchi/neubias-napari-workshop)
2. Click the green "Code" button to open the download menu and then "Download ZIP"
![download code](./resources/download_code.png)
3. Choose the location you would like to download the .zip.
4. Open your file browser and double click on the .zip file to uncompress it.
5. You have downloaded the notebooks! Proceed to the "Launching jupyter notebook" section.
### Cloning via git
You can use git to clone the repository containing the tutorial materials to your computer. We recommend cloning the materials into your Documents folder, but you can choose another suitable location. First, open your Terminal navigate to you the folder you will download the course materials into
```bash
cd ~/Documents
```
and then clone the repository. This will download all of the files necessary for this tutorial.
```bash
git clone https://github.com/kevinyamauchi/neubias-napari-workshop.git
```
## Launch jupyter notebook
Open your terminal and navigate to the `notebooks` subdirectory of the `embl-napari-workshop` directory you just downloaded.
```
cd <path to neubias-napari-tutorial>/notebooks
```
Now activate your `napari-tutorial` conda environment you created in the installation step.
```
conda activate napari-tutorial
```
We will perform the analysis using Jupyter Notebook. To start Jupyter Notebook, enter
```bash
jupyter notebook
```
Jupyter Notebook will open in a browser window and you will see the following notebooks:
- `part_0_spot_detection_tutorial_<beginner, advanced, solution>.ipynb`: in this notebook you will write a custom function to perform spot detection.
![jupyter notebook](./resources/jupyter_notebook.png)
<!---
BSD License
Copyright (c) 2022, Kevin Yamauchi
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
-->
# Setting up your python environment
## Installing python via mambaforge
In this tutorial, we will install python via mambaforge, a distribution of anaconda python. However, if you already have anaconda, miniconda, mambaforge, or miniforge installed, those will work as well and you can skip to the next section.
To install python via mambaforge, follow the instructions [here](install_python.md).
## Setting up your environment
```{admonition} Using conda instead of mamba?
The following assumes that you have installed python using Mambaforge as [described above](content:references:napari_python_installation). If you are using a pre-existing installation of python via anaconda, miniconda, or miniforge, you can simply replace the `mamba` commands with `conda`.
```
1. Open your terminal.
- **Windows**: Open the "miniforge prompt" from your start menu
- **Mac OS**: Open Terminal (you can search for it in spotlight - cmd + space)
- **Linux**: Open your terminal application
2. We use an environment to encapsulate the python tools used for this workshop. This ensures that the requirements for this workshop do not interfere with your other python projects. To create the environment (named `pyimagecourse`), enter the following command.
```bash
mamba create -n pyimagecourse python=3.9
```
3. Once the environment setup has finished, activate the environment. If you successfully activated the environment, you should now see `(pyimagecourse)` to the left of your command prompt.
```bash
mamba activate pyimagecourse
```
4.
4. Install the dependencies with the commands below
```bash
mamba env update -n pyimagecourse --file environment.yml
```
6. Test that your notebook installation is working. We will be using notebook for interactive analysis. Enter the command below and it should launch jupyter notebook book in a web browser.
```bash
jupyter notebook
```
7. Test your napari installation. Enter the command below and an empty napari viewer should open. You can close the window after it opens. Please note that it takes a bit of extra time to launch napari the first time.
```bash
napari
```
\ No newline at end of file
name: pyimagecourse
channels:
- conda-forge
dependencies:
- napari
- pip
- pip:
- matplotlib
- jupyter
- pyzmq<25 # jupyter problems: https://discourse.jupyter.org/t/jupyter-notebook-zmq-message-arrived-on-closed-channel-error/17869/27
- jupyter_client<8 # jupyter problems
- ipympl
- cellpose
- stardist
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment