简体   繁体   中英

Coloring area between pixels based on thickness

I'm trying to isolate the gray matter in a brain image and color it based on the cortical thickness at each point giving a result similar to this: Cortical thickness map based on this original: Original brain scan
So far I have segmented the white matter boundary and the gray matter boundary giving me this:
White + Gray matter segmentation
The next step is where I'm stuck.
I need to find the distance between the 2 boundaries by finding the closest white boundary pixel for each gray boundary pixel and record the distance between them as shown here: Distance
This can be done simply with some for loops and Euclidian distance.
My problem is how to then color the pixels in between them/assign the distance value to the pixels between them.

import numpy as np
import matplotlib.pyplot as plt
import nibabel as nib
from skimage import filters
from skimage import morphology


t1 = nib.load('raw_map1.nii').get_fdata()
t1map = nib.load('thickness_map1.nii').get_fdata()

filt_t1 = filters.gaussian(t1,sigma=1)
plt.imshow(filt_t1[:,128,:])

#Segment the white matter surface
wm = filt_t1 > 75
plt.imshow(wm[:,128,:])

med_wm = filters.median(wm)
plt.imshow(med_wm[:,128,:])

dilw = morphology.binary_dilation(med_wm)
edge_wm = dilw.astype(float) - med_wm
plt.imshow(edge_wm[:,128,:])

#Segment the gray matter surface
gm = (filt_t1 < 75) & (filt_t1 > 45)
plt.imshow(gm[:,128,:])

med_gm = filters.median(gm)
plt.imshow(med_gm[:,128,:])

dilg = morphology.binary_dilation(med_gm)
edge_gm = dilg.astype(float) - med_gm
plt.imshow(edge_gm[:,128,:])

dilw2 = morphology.binary_dilation(edge_wm)
plt.imshow(dilw2[:,128,:])

fedge_gm = edge_gm.astype(float) - dilw2
plt.imshow(fedge_gm[:,128,:])

fedge_gm2 = fedge_gm > 0
plt.imshow(fedge_gm2[:,128,:])

#Combine both surfaces
final = fedge_gm2 + edge_wm
plt.imshow(final[:,128,:])

You may use DL+DiReCT : https://github.com/SCAN-NRAD/DL-DiReCT

Starting from a brain scan (T1-weighted MRI) as input, DL+DiReCT labels anatomical regions including the cortex and calculates a voxel-wise cortical thickness map ( T1w_norm_thickmap.nii.gz ). For every voxel inside the cortex, the intensity indicates the thickness of the cortex in mm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM