Skip to content

ai4life-opencalls/oc-1-project-6

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Project #6: Murine skeletal muscle analysis

DOI


This page was created by the AI4Life project using data provided by Emiliana Giacomello at University of Trieste. All the images demonstrated in this tutorial are provided under CC-BY licence.

If any of the instructions are not working, please open an issue or contact us at ai4life@fht.org!

Project challenges: sample alignment, cell instance segmentation, cell linking.

Table of Contents

  1. Introduction
  2. Installation
  3. Pipeline overview
  4. Step #1: Data-specific preprocessing in Fiji
  5. Step #2: Align the images with BigWarp
  6. Step #3: Link the cells with TrackMate
  7. How to train your own Cellpose model
  8. Conclusion

Introduction

Researchers from the University of Trieste are studying the regulation of the metabolical properties in murine skeletal muscles. They want to analyze a series of sections of a single muscle stained with different markers and imaged with light microscopy. The goal of the analysis is to segment all cells in each section and identify them across different acquired images. Although the cells should be present in each section, their morphology can be vastly different, making identification across sections a challenging task.

In this tutorial, we will demonstrate how to align the different muscle slices to each other using ImageJ BigWarp, then segment muscle cells with Cellpose and link them between multiple images using ImageJ Trackmate.

Here is an exaple of two resulting images, where all the cells are segmented and the same cells are marked with the same color:

Let's get started!

Pipeline overview:

  1. Data-specific preprocessing in Fiji

  2. Aligning images with ImageJ BigWarp

  3. Segmentation with Cellpose and cell linking with ImageJ Trackmate.

Installation

Install Python package manager

We recommend installing conda or mamba. Go to the website and follow the installation instructions for your operating system.
During installation, select the installation folder that you have permissions for, such as your home folder.

Install Cellpose

Follow Cellpose installation for official instructions.
If you are using GPU check out GPU version (CUDA) on Windows or Linux section.

Cellpose installation details
  1. Create a new python environment:
    conda create -n cellpose python=3.9
    conda activate cellpose
  2. If you have a GPU, install PyTorch by following the official instructions. Select a version that is compatible with your driver version. Follow this link for older versions.
    We will be installing PyTorch version 1.12 and cudatoolkit version 11.3 as an example:
    conda install pytorch==1.12.0 torchvision==0.13.0 cudatoolkit=11.3 -c pytorch
  3. If you have a GPU, check if the Pytorch installation is correct. If you are using GPU, this command should return a list of available devices:
    python -c "import torch; print([torch.cuda.get_device_properties(i) for i in range(torch.cuda.device_count())])"`
  4. Install Cellpose:
    pip install pyqt5 "cellpose[gui]"
  5. Check the installation by running Cellpose. You should see the Cellpose window open:
    cellpose

Install TrackMate-Cellpose

Follow TrackMate-Cellpose for official instructions.

TrackMate-Cellpose installation details
  1. Open Fiji.
  2. Add The TrackMate-Cellpose update site and restart Fiji.
  3. In your cellpose conda environment, run this command to find where your python is installed:
    which python
  4. Open TrackMate and select Cellpose detector from the list of available detectors.
  5. Insert the path to your python in Path to Cellpose

Step #1: Data-specific preprocessing in Fiji

Download example images here: TBD

Crop the empty background:

  1. If necessary, add scale information to the image in Image > Properties... >.
    Set the pixel width and height to the estimated number of microns. For example:
    Now you should see the scale on top of the image:
  2. Press Edit › Selection › Select Bounding Box to select the non-empty region. If it did not work, try using Select Bounding Box (guess background color)
  3. Press Image › Crop to crop the region.
  4. You can scale the image to reduce its size for faster pipeline performance.
    Press Image > Scale... and enter the desired scale, like 0.5 or 0.25.

Step #2: Align the images with BigWarp

BigWarp is an ImageJ plugin that helps to align and register images using interest points as a reference. This plugin comes with Fiji, so no installation should be required.

  1. Open two cropped images, the target image one will be a reference, and the moving image will be the one scaled and rotated.

  2. Go to Plugins > BigDataViewer > Big Warp.

  3. Select your two images:

  4. Press Space to enter Landmark mode.

  5. Put reference points on both images alternately.
    In case of an error - delete the error point in the Landmarks window.
    You can press Space again to exit the Landmark mode to be able to zoom, move, and rotate the images.

  6. Place points on several same cells. Try to cover all sides of the sample, like so:

  7. We suggest using affine transform for aligning to avoid warping artifacts. Press F2 to select the “Affine” transformation type from the menu.

  8. Press T to see the result

  9. Press File > Export moving image > OK to export the rotated image. The new image will be opened in a new window.

Step #3: Link the cells with TrackMate

To link cells between images we will be using a plugin designed for tracking - Trackmate.

  1. Download and unzip the pretrained segmentation model: cellpose_model.zip

  2. Make a stack of images. Open all the images, Image > Stacks > Images to Stack.

  3. Open up TrackMate Plugins > Tracking > TrackMate

  4. In the first window, it's possible select out the region you want to process and click Refresh ROI

  5. In the next step, select the Cellpose Detector

  6. Check if Path to cellpose is correct. It should be the same location that you installed your cellpose into. It should look like: /Users/emilianagiacomello/miniforge3/envs/cellpose/bin/python

  7. Select Custom model from Pretrained model and add a path to the downloaded model.

  8. Check if the approximate diameter of your objects in Cell diameter is correct. Here is an example of final settings:

  9. Press preview to run prediction on one image and check the result. The cells found on the image should now be highlighted.

  10. Press Next until you see the Select Tracker window. Select Manual tracking.

  1. Press Next until you see this window, and push the TrackScheme button.
  1. Now you should select the Spot edit tool in the main window, on the right side.

  2. Click on one of the cells, go to the next image and Shift + Click on the same cell on the other staining, and then Press L. You should see a small line appear, meaning the cells were linked.

Export options

  1. You can export a table with links and spot features in the Tracks window.
    Label is the name of the cell’s ROI, and Track ID is the of the link you created.
    You can export the resulting CSV for the downstream analysis.
  2. You can also export the segmentation results as ROI, which will have the same IDs as in the table above. Click Next until you see “Select an action” window, choose “Export spots to IJ ROIs” and press “Execute”:

How to train your own Cellpose model

You can watch a video tutorial on how to use Cellpose here - https://www.cellpose.org/

  1. Activate the cellpose enviroment you installed before.
  2. Run cellpose application.
  3. Find the best working model from the model zoo section.
  4. Look through the errors in the predictions and correct a few of them. Click Help > Help with GUI for help with labeling controls.
  5. Train a new model on the corrected data. Click Models > Train new model.
  6. Choose the best model from step 3 as an initial model. You cannot select a custom model as an initial model.
  7. We suggest using the following settings:
  8. After training, you’ll see your new model in the custom models section. It will also be saved in the folder with your data. Cell diameter will also be updated with what the model learned from the data.
  9. You can continue iterating: predict with the model - fix a couple of mistakes - train a new model - fix mistakes - train a new model

Conclusion

In this tutorial, we showed how to align murine muscle images with ImageJ BigWarp, segment cells with Cellpose and link them between multiple images using ImageJ Trackmate.

AI4Life is a Horizon Europe-funded project that brings together the computational and life science communities.

AI4Life has received funding from the European Union’s Horizon Europe research and innovation programme under grant agreement number 101057970. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the European Research Council Executive Agency. Neither the European Union nor the granting authority can be held responsible for them.