Skip to content

BDehapiot/ETH-ScopeM_Concrete

Repository files navigation

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

ETH-ScopeM_Concrete

Concrete rebar CT scan analysis 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 concrete

Your prompt should now start with (concrete) 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 concrete

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

Main procedure

process_main.py

Main processing tasks executed on original image stacks

  1. Downscale (reduce processing time)
# For downscale factor (df) = 4  
original stack (z, y, x)  = 1948 x 1788 x 1788 = 13 Gb  
downscaled stack (z, y, x)  = 487 x 447 x 447 = 186 Mb

  1. Preprocess
    • center images over Z axis
    • compute median projection (med_proj)
    • normalize images (divide by med_proj to get norm)
    • determine matrix and rod masks (mtx_mask, rod_mask)
    • compute distance maps
      mtx_EDM - distance from outer surface
      rod_EDM - distance from inner rod

masks&EDM

  1. Predict (U-Net - resnet34)
    • manually annotate data (Napari)
    • train semantic segmentation model (~ 25 image pairs)
    • save weights (model-weights_void.hdf5)
    • predict un-seen images (obj_probs)

predict

  1. Segment
    • segment voids from obj_probs
    • normalize void brightness (custom fitting procedure)
    • determine air and liquid masks (air_mask, liquid_mask)

segment

  1. Objects

Registration

register_main.py

Between different timepoints, the image stacks exhibit inconsistencies in terms
of translation, rotation, and scaling within the 3D space.

misalignment

  1. Match object pairs
    • compare segmented objects for:
      • distance to outer surface
      • distance to neighbors
      • shape descriptors (area, solidity)
    • identify valid pairs (min. difference between comparison criteria)

  1. Register 3D stacks
    • compute affine transformation matrix (based on valid pair centroids)
    • apply transformation and save registered data (see registered folder)

Display

display_probs.py

display_mask.py

Display prediction (display_probs.py) and segmentation (display_mask.py)
results in a customized Napari viewer.

Outputs

data folder

- Time0_crop_df4.tif # crop + downscale raw images  
- Time0_crop_df4_norm.tif # crop + downscale + norm. images  
- Time0_crop_df4_probs.tif # obj. predictions (model)  
- Time0_crop_df4_air_mask.tif # labelled mask of obj.  
- Time0_crop_df4_liquid_mask.tif # mask of air-filled regions  
- Time0_crop_df4_labels.tif # mask of liquid-filled regions  
- Time0_crop_df4_metadata.pkl # processing metadata  

registered folder

- crop_df4_reg.tif # registered crop + downscale raw images
- crop_df4_reg_norm.tif # registered crop + downscale + norm. images
- crop_df4_reg_probs.tif # registered obj. predictions
- crop_df4_reg_air_mask.tif # registered air masks
- crop_df4_reg_liquid_mask.tif # registered liquid masks
- crop_df4_transform_matrix.pkl # registration transformation matrices

outputs folder

  1. obj_data.csv
- label # obj. identification label (see `labels.tif`)
- ctrd_z # obj. z position 
- ctrd_y # obj. y position
- ctrd_x # obj. x position
- area # obj. number of voxel (3D volume)
- air_area # air number of voxel (3D volume)
- liquid_area # liquid number of voxel (3D volume)
- ratio # liquid / obj. volume
- solidity # obj. volume / obj. convex hull volume
- obj_dist # distance from neighbouring obj.
- mtx_dist # distance from external matrix surface
- category # 0 = inner obj., 1 = surface obj., 2 = rod obj
  1. plot.jpg

Comments

  • Fading images in reg_hmatch.tif
    • solved
  • Bin fluctuation from timepoint to timepoint
    • partially solved by excluding bins with not enough data-points
  • Consistent bin range (avoid disapiring bin range (e.g 0-10))
    • solved by showing excluding bins NaN text in plot

About

Concrete rebar CT scan analysis tool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages