Skip to content

BDehapiot/ETH-ScopeM_CapsSeg

Repository files navigation

Python Badge TensorFlow Badge CUDA Badge cuDNN Badge
Author Badge Date Badge License Badge

ETH-ScopeM_CapsSeg

Microcapsule segmentation tool

Index

Installation

Pease select your operating system

Windows

Step 1: Download this GitHub Repository

  • Click on the green <> Code button and download ZIP
  • Unzip the downloaded file to a desired location

Step 2: Install Miniforge (Minimal Conda installer)

  • Download and install Miniforge for your operating system
  • Run the downloaded .exe file
    • Select "Add Miniforge3 to PATH environment variable"

Step 3: Setup Conda

  • Open the newly installed Miniforge Prompt
  • Move to the downloaded GitHub repository
  • Run one of the following command:
# TensorFlow with GPU support
mamba env create -f environment_tf_gpu.yml
# TensorFlow with no GPU support 
mamba env create -f environment_tf_nogpu.yml
  • Activate Conda environment:
conda activate CapsSeg

Your prompt should now start with (CapsSeg) instead of (base)

MacOS

Step 1: Download this GitHub Repository

  • Click on the green <> Code button and download ZIP
  • Unzip the downloaded file to a desired location

Step 2: Install Miniforge (Minimal Conda installer)

  • Download and install Miniforge for your operating system
  • Open your terminal
  • Move to the directory containing the Miniforge installer
  • Run one of the following command:
# Intel-Series
bash Miniforge3-MacOSX-x86_64.sh
# M-Series
bash Miniforge3-MacOSX-arm64.sh

Step 3: Setup Conda

  • Re-open your terminal
  • Move to the downloaded GitHub repository
  • Run one of the following command:
# TensorFlow with GPU support
mamba env create -f environment_tf_gpu.yml
# TensorFlow with no GPU support 
mamba env create -f environment_tf_nogpu.yml
  • Activate Conda environment:
conda activate CapsSeg

Your prompt should now start with (CapsSeg) instead of (base)

Content

main.py

Processes either a selected image or all jpg, png, or tif images within the data_path folder and its subfolders. The rescaling factor rf can be adjusted to accelerate the post-prediction process. For each iteration, the procedure generates two CSV files (cData.csv and sData.csv) along with a display image (display.png), which are saved in the same location as the processed image. Refer to the Outputs section for further details.

# Paths
- data_path        # str, path to folder containing image(s) to process
- img_name         # str, image name or "all" for batch processing
# Parameters
- rf               # float, post-prediction rescaling factor (0 to 1)
- overlap          # int, prediction patches overlap (default 256)
- save             # bool, save or not outputs files 
# Outputs
- ..._cData.csv    # core data saved as csv
- ..._sData.csv    # shell data saved as csv
- ..._display.png  # display image 

analyse.py

Compile data from different CSV files, including tags_in and excluding tags_out containing file name.

Others

  • functions.py - contains all required functions
  • environment-gpu.yml - dependencies with GPU support (NVIDIA GPU required)
  • environment-nogpu.yml - dependencies with no GPU support
  • model_cores_edt_512_gamma - model files for core segmentation
  • model_shell_edt_512_gamma - model files for shell segmentation

Outputs

display.png

Image showing results of segmentation with detected shells in yellow and cores in cyan.

example_display

cData.csv - inner cores data

# Core data
    - cLabel # core ID
    - cArea # area
    - cVolum # volume (assuming spherical shape)  
    - cPerim # perimeter
    - cFeret # max feret diameter
    - cMajor # fitted ellipse major axis length 
    - cMinor # fitted ellipse minor axis length
    - cSolid # solidity (object area / convex hull area)
    - cRound # roundness  
    - cCircl # circularity  
    - cY # centroid y position
    - cX # centroid x position
    - csRatio # core area / shell area
    - csDist # core to shell centroid distance

# Associated shell data
    - c_sLabel # associated shell ID

sData.csv - outer shell data

# Shell data
    - sLabel # shell ID
    - sArea # area
    - sVolum # volume (assuming spherical shape)
    - sPerim # perimeter
    - sFeret # max feret diameter
    - sMajor # fitted ellipse major axis length 
    - sMinor # fitted ellipse minor axis length
    - sSolid # solidity (object area / convex hull area)
    - sRound # roundness
    - sCircl # circularity
    - sY # centroid y position
    - sX # centroid x position

# Associated core(s) data
    - sCore # number of associated core(s)
    - s_cLabel # core(s) ID
    - s_cArea # core(s) avg. area
    - s_cVolum # core(s) avg. volume
    - s_cPerim # core(s) avg. perimeter
    - s_cFeret # core(s) avg. max feret diameter
    - s_cMajor # core(s) avg. fitted ellipse major axis length 
    - s_cMinor # core(s) avg. fitted ellipse minor axis length
    - s_cSolid # core(s) avg. solidity
    - s_cRound # core(s) avg. roundness
    - s_cCircl # core(s) avg. circularity
    - s_csRatio # core(s) avg. core area / shell area
    - s_csDist # core(s) avg. core to shell centroid distance
# Volume = (4 / 3) * np.pi * np.sqrt(cArea / np.pi) ** 3
# Roundness = 4 * cArea / (np.pi * cMajor ** 2)
# Circularity = 4 * np.pi * cArea / cPerim ** 2

Comments

# Error message
lxml.html.clean module is now a separate project lxml_html_clean. 
Install lxml[html_clean] or lxml_html_clean directly. 
# Fix
pip install --upgrade lxml_html_clean

About

Microcapsule segmentation tool

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages