HemaxiN / 3DVascNet

Official implementation of the paper: Narotamo, H., Silveira, M., & Franco, C. A. (2024). 3DVascNet: An Automated Software for Segmentation and Quantification of Mouse Vascular Networks in 3D. Arteriosclerosis, Thrombosis, and Vascular Biology.

Home Page:https://www.ahajournals.org/doi/10.1161/ATVBAHA.124.320672

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

3DVascNet: An Automated Software for 3D Retinal Vascular Networks Segmentation and Quantification

This repository contains the Python implementation of a 3D CycleGAN model to segment blood vessels in 3D microscopy images of mouse retinas. It also contains the code of the automatic pipeline developed for the quantification of the vascular network based on the segmentation masks. Moreover, the instructions for downloading and using our interface can be found in this repository.

This is the official implementation of the paper: 3DVascNet.

How to cite

@article{narotamo20243dvascnet,
  title={3DVascNet: An Automated Software for Segmentation and Quantification of Mouse Vascular Networks in 3D},
  author={Narotamo, Hemaxi and Silveira, Margarida and Franco, Cl{\'a}udio A},
  journal={Arteriosclerosis, Thrombosis, and Vascular Biology},
  year={2024},
  publisher={Am Heart Assoc}
}

Segmentation

Architecture

Dataset

Our dataset contains 3D microscopy images of mouse retinas and the corresponding 2D segmentation masks (annotated manually based on the maximum intensity projection (MIP) images of the 3D microscopy images). Moreover, we have the 3D segmentation masks obtained based on the 2D segmentation masks using PolNet. The dataset will be soon made publicly available here.

Requirements

The code was initially developed in Python 3.5.2, using Keras 2.2.4.

Now it has been updated to work in Python 3.10, the required packages are listed in requirements.txt.

Pre-Processing

To apply the pre-processing vessel enhancement method run the file percentile.py. Moreover, the code to convert the .stl objects (3D segmentation masks obtained with PolNet) into 3D .tif files is provided in the jupyter notebook STL2Voxel.ipynb. Note that while percentile normalization with values of 1 and 99 is effective for single-layer vasculature (P6 retinas), it may not be optimal for complex vasculatures with substantial intensity variations between different vessel layers as observed in adult retinas. In such cases, we have found that using percentiles of 0.5 and 99.5 yields better results. Thus, percentile normalization parameters may need to be adjusted according to the user's specific dataset requirements.

Testing the Pre-trained Model on Your Own Dataset

Firstly, download the weights of the pre-trained model.

This implementation supports the segmentation of images with any dimensions along x and y, and z. The images should be .tif files, the images' names should have a prefix denoting its group (for instance 'GroupName_Image1.tif). If the pre-trained model does not work well on your images you can train the cycleGAN model using the images of your dataset, and masks of our dataset.

Training on Your Own Dataset

To create the training patches (images and masks) use the files create_patches_images.py and create_patches_masks.py, respectively. Furthermore, patches representing the background can be created running the file create_background_patches.py.

Run the file train_main.py after changing the parameters defined in this file. The train_dir contains the following tree structure:

train_dir
   ├── images  0.tif, 1.tif, ..., N.tif (patches of microscopy images of vessels  (Z_slices, X_dim, Y_dim))
   └── masks   0.tif, 1.tif, ..., N.tif (patches of segmentation masks of vessels  (Z_slices, X_dim, Y_dim))

Prediction

To test the trained model on new images specify the directories in file predict_main.py and run it.

Post-Processing and Evaluation

Post-Processing methods can be applied to the predicted segmentation masks using the file post_proc_main.py; and the performance of the model can be evaluated using eval_main.py, which writes a results.csvfile:

| Image         | NMI3D | MI2D | NMI2D | DC | TP | FP | FN | TN | SP | SN |
|---------------|-------|------|-------|----|----|----|----|----|----|----|
| GroupA_Image1 |       |      |       |    |    |    |    |    |    |    |
| GroupB_Image2 |       |      |       |    |    |    |    |    |    |    |
| GroupA_Image3 |       |      |       |    |    |    |    |    |    |    |
  • NMI3D: normalized mutual information in 3D
  • MI2D: mutual information in 2D
  • NMI2D: normalized mutual information in 2D
  • DC: dice coefficient
  • TP: true positive pixels
  • FP: false positive pixels
  • FN: false negative pixels
  • TN: true negative pixels
  • SP: specificity
  • SN: sensitivity

Model

The model that achieved the best performance is made publicly available here.

Vasculature Quantification

The code for feature extraction from the segmentation masks of vessels is provided in this script. First, you should change the masks_dirand resolution_filevariables, which correspond respectively to the directory where the 3D post-processed masks are saved and the path to a resolution.xlsx file containing details about the voxel's physical sizes for each image. The resolution.xlsx file should have the following structure:

As stated above, the images' names should have a prefix denoting its group (for instance 'GroupName_Image1.tif). This is important to later visualize the distributions of the vascular features by grouping images belonging to the same group. After running quantification.py, a features3d.csv file will be generated containing the computed 3D features for each mask, it will have the following structure:

| Image        | Group | Branching Points Density | Vessel Density % | Avascular Area % | Mean Branch Length | Mean Vessel Radius |
|--------------|-------|--------------------------|------------------|------------------|--------------------|--------------------|
| Image_Name_1 |       |                          |                  |                  |                    |                    |  
| Image_Name_2 |       |                          |                  |                  |                    |                    |    
| Image_Name_3 |       |                          |                  |                  |                    |                    |    

To define the region of interest we computed the concave hull for each segmentation mask using this implementation. More details are presented here ConcaveHull.

Graphical User Interface - 3DVascNet

3DVascNet is available as a GUI that allows to automatically analyse 3D microscopy images of retinal blood vessels. Instructions for downloading and using our 3DVascNet software can be found here.

Acknowledgements

About

Official implementation of the paper: Narotamo, H., Silveira, M., & Franco, C. A. (2024). 3DVascNet: An Automated Software for Segmentation and Quantification of Mouse Vascular Networks in 3D. Arteriosclerosis, Thrombosis, and Vascular Biology.

https://www.ahajournals.org/doi/10.1161/ATVBAHA.124.320672

License:GNU General Public License v3.0


Languages

Language:Jupyter Notebook 86.8%Language:Python 13.2%