Starting a new image analysis project#
If you have set up Python and installed Napari and Jupyter lab, you can start prototyping something for your image analysis project.
One of the first challenges you’ll face is deciding how to organize the structure of your project. A simple way to get started would be as outlined below.
Create a new folder for your project.
Create a sub-folder called
datain which you’re going to keep your image(s). Move your data there.Create a Jupyter notebook file with an extension
.ipynbfor your analysis.
my_project/
├── data/
├── image.tif
analysis.ipynb
Tip
By keeping data close to your code, it’s easier to refer to it via relative paths in your code.
Then, open your terminal and follow the steps below.
From the command-line, navigate to the folder you just created using
cd. For example:
cd ~/Desktop/my_project/
Activate your
Python environment.
conda activate napari-env
Start the
Jupyter Labapplication.
jupyter lab
Jupyter Lab will open in a web browser window. There, you can open your analysis notebook and start working on it.
A good start would be to add a title for your analysis in a Markdown cell, import a few libraries, and load an image from your data subfolder.
import skimage.io
image = skimage.io.imread('data/image.tif')
print(f'Loaded image in an array of shape: {image.shape}.')
print(f'Intensity range: [{image.min()} - {image.max()}]')
In the next cell, create a Napari viewer and open your image in it.
import napari
viewer = napari.view_image(image)
If you run these two cells, Napari should open in a separate window. You should be able to see your image in the viewer. From here, you’re ready to start developing an image analysis pipeline based on your project objectives.
Going further#
To complete the structure of your project, you can add, for example
a
README.mdfile to document your project.a
requirements.txtfile to specify the Python dependencies for your project.a
LICENSEfile to specify your project’s license.
Learn more about good practices coding projects by reading EPFL ENAC-IT’s Code Publishing Cheat Sheet.
In addition, you might consider tracking changes to your project using git for version control and hosting your project on a platform such as GitHub or GitLab. You can keep your project private or make it public to share it with others.