Mehrdad-Noori / Brain-Tumor-Segmentation

Attention-Guided Version of 2D UNet for Automatic Brain Tumor Segmentation
207 stars 37 forks source link

how to train on my own dataset? #5

Open manvirvirk opened 4 years ago

Mehrdad-Noori commented 4 years ago

You can easily modify the prepare_data.py to make it fit to your own problem. If you have any problems please let me know.

qiuyuan666 commented 4 years ago

Hello! Mehrdad-Noori. Thanks for your code! I want to train my own data, how do I put my own dataset into the folder 'data'? What are the data format requirements? I'm looking forward to your reply.

Mehrdad-Noori commented 4 years ago

I used BraTS dataset that is in nii.gz format. It also contains 4 image types/channels (flair, t1, t1_ce, t2) + label. Something like:

MICCAI_BraTS_2019_Data_Training
├── HGG
│   ├── BraTS19_2013_10_1
│   │   ├── BraTS19_2013_10_1_flair.nii.gz
│   │   ├── BraTS19_2013_10_1_seg.nii.gz
│   │   ├── BraTS19_2013_10_1_t1ce.nii.gz
│   │   ├── BraTS19_2013_10_1_t1.nii.gz
│   │   └── BraTS19_2013_10_1_t2.nii.gz
│   ├── BraTS19_2013_11_1
│   │   ├── BraTS19_2013_11_1_flair.nii.gz
│   │   ├── BraTS19_2013_11_1_seg.nii.gz
│   │   ├── BraTS19_2013_11_1_t1ce.nii.gz
│   │   ├── BraTS19_2013_11_1_t1.nii.gz
│   │   └── BraTS19_2013_11_1_t2.nii.gz
:   :   
:   :
│   │
└── LGG
    ├── BraTS19_2013_0_1
    │   ├── BraTS19_2013_0_1_flair.nii.gz
    │   ├── BraTS19_2013_0_1_seg.nii.gz
    │   ├── BraTS19_2013_0_1_t1ce.nii.gz
    │   ├── BraTS19_2013_0_1_t1.nii.gz
    │   └── BraTS19_2013_0_1_t2.nii.gz
    ├── BraTS19_2013_1_1
    │   ├── BraTS19_2013_1_1_flair.nii.gz
    │   ├── BraTS19_2013_1_1_seg.nii.gz
    │   ├── BraTS19_2013_1_1_t1ce.nii.gz
    │   ├── BraTS19_2013_1_1_t1.nii.gz
    │   └── BraTS19_2013_1_1_t2.nii.gz
    :
    :

You can modify the prepare_data.py with respect to your data structure. I have also done some cropping on images with x0, x1, y0, y1, z0, z1 parameters. You can comment them out or find the cropping values of your dataset.

Xiuxiu21 commented 2 years ago

我按您的格式进行放置他报错了 C:\ProgramData\Anaconda3\envs\tensorflow\python.exe E:/Brats/prepare_data.py 0%| | 0/1 [00:00<?, ?it/s] Traceback (most recent call last): File "E:/Brats/prepare_data.py", line 168, in cfg['crop_coord'], cfg['data_channels'], cfg['k_fold']) File "E:/Brats/prepare_data.py", line 123, in create_table all_modalities, brain_affine, brain_name = read_brain(brain_dir, mode='train', **crop_coordinates) File "E:/Brats/prepare_data.py", line 50, in read_brain modalities_dir = [flair[0], t1[0], t1ce[0], t2[0], gt[0]] IndexError: list index out of range Closing remaining open files:E:\data/data.hdf5...done