LuxImagingAI / DBSegment

This is a deep learning-based method to segment deep brain structures and a brain mask from T1 weighted MRI.
GNU General Public License v3.0
11 stars 6 forks source link

How to specify the area to segment? #21

Closed Kimmm-pzl closed 1 year ago

Kimmm-pzl commented 1 year ago

Hi

How do I specify the area I want to split, instead of splitting all 30 areas at once. For example, only split on 'GPI_L' and 'GPI_R' Thank you for your reply!

Best Kim

Kimmm-pzl commented 1 year ago

Hi,

In addition, I want to ask whether the pixel value matches the labels in the "label.txt" after getting the divided ".nii file", so that the structure name can be determined according to the pixel value of the ".nii file"? In other words, how to match RGB values in "label.txt" to pixels in ".nii file". Thanks again and look forward to your reply!

Best Kim

adhusch commented 1 year ago

Hi @Kimmm-pzl, by construction, the network will always return all labels. When you are only interested in one label, you can look up the integer index from the label.txt file, e.g. 5 for GPI_R and only look at these values in the result nifti (effictivly generating a binary mask for the GPI_R from it).

Python Pseudocode:

# Load the NIfTI file
nifti_file = nib.load('dbsegment_output.nii')

# Access the data array and header information
nifti_data = nifti_file.get_fdata()

# get a binary GPI_R only mask from the integer segmentation partition
mask_GPI_R = nifti_data == 5
Kimmm-pzl commented 1 year ago

Thanks for your reply, it helped me a lot!

Best Kim