thuhoainguyen / kits23

The official repository of the 2023 Kidney Tumor Segmentation Challenge (KiTS23)
MIT License
0 stars 0 forks source link

Understanding preprocessing script #1

Open thuhoainguyen opened 1 month ago

thuhoainguyen commented 1 month ago

First we need to understand what the script does. I suggest you read and comment (line by line) the code flow. If you have any trouble please comment here and we can discuss.

thuhoainguyen commented 1 month ago

I don't understand the second argument this function:

def resample_image(image, new_spacing=[1.0, 1.0, 1.0]):
    original_spacing = image.GetSpacing()
    original_size = image.GetSize()
thuhoainguyen commented 1 month ago

Basically, the segmentation_preProc.py file crop the large axial abominal CT image to get the small specific kidney bound image for further processor techniques.

anhtuduong commented 1 month ago

@thuhoainguyen I think your description is ok but I may need more info:

Next time when you comment pleases tag me (@anhtuduong)

anhtuduong commented 1 month ago

@thuhoainguyen I made a diagram for the classes and the workflow of the code to help you: https://drive.google.com/file/d/1amNT1wPpbPOwA9weN3dbkXe1QY7vUEhF/view?usp=sharing

Image

Image

thuhoainguyen commented 1 month ago

Thank you very much! I will check tomorrow and let you know.

Buonanotte! hoaithu

On Fri, 24 May 2024 at 00:25 Anh Tu Duong @.***> wrote:

@thuhoainguyen https://github.com/thuhoainguyen I made a diagram for the classes and the workflow of the code to help you:

https://drive.google.com/file/d/1amNT1wPpbPOwA9weN3dbkXe1QY7vUEhF/view?usp=sharing

kits23-preprocessing-class.png (view on web) https://github.com/thuhoainguyen/kits23/assets/76017474/b3648d7d-bdad-49c0-94d4-d5475be01c2e

kits23-preprocessing-workflow.png (view on web) https://github.com/thuhoainguyen/kits23/assets/76017474/5912b7ae-fa27-4095-ad55-71445c6ad39d

— Reply to this email directly, view it on GitHub https://github.com/thuhoainguyen/kits23/issues/1#issuecomment-2128137826, or unsubscribe https://github.com/notifications/unsubscribe-auth/BHR373VFUT5IYBDNC3SNL4DZDZUGDAVCNFSM6AAAAABH3BWR4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRYGEZTOOBSGY . You are receiving this because you were mentioned.Message ID: @.***>

anhtuduong commented 3 weeks ago

The output of the preprocessing pipeline will differ significantly from the original NIfTI (.nii) images in several ways due to the various preprocessing steps. Here's a detailed explanation of the differences:

1. Resampling

Original Image:

Resampled Image:

2. Normalization

Original Image:

Normalized Image:

3. Cropping

Original Image:

Cropped Image:


Histogram in Preprocessing:

In your preprocessing code, the histogram plays a crucial role in normalizing the intensity values of the images. A histogram is a graphical representation of the distribution of intensity values in an image. It consists of bins, where each bin represents a range of intensity values, and the height of each bin represents the number of pixels (or voxels) that fall within that range.

The histograms for different labels are loaded from a precomputed file. This data likely represents the distribution of intensity values for different tissue types (e.g., kidney, tumor, cyst) across the training dataset.

Computing Gaussian Fits:

Range Normalization Using Histogram Data:

Benefits of Using Histogram in Preprocessing:

Standardization:

Contrast Enhancement:

Outlier Handling:

Summary: In summary, the histogram data in your preprocessing code is used to estimate the distribution of intensity values for different tissue types. These distributions are then used to normalize the intensity values of the images, ensuring that they fall within a standardized range. This process enhances the contrast and consistency of the images, making them more suitable for subsequent analysis and machine learning tasks.