Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data preprocess #28

Closed
b3r-prog opened this issue Aug 16, 2022 · 7 comments
Closed

Data preprocess #28

b3r-prog opened this issue Aug 16, 2022 · 7 comments

Comments

@b3r-prog
Copy link

Hi @himashi92

Thanks for this awesome work and repo. I am trying to replicate this on the Liver data in the decathlon. When I run the the train command for the base training CUDA_VISIBLE_DEVICES=0 nohup vtunet_train 3d_fullres vtunetTrainerV2_vtunet_tumor_base 3 0 &> base.out &

I get the following error below KeyError: 'BRATS_001'():
`stage: 0
{'batch_size': 2, 'num_pool_per_axis': [5, 5, 5], 'patch_size': array([128, 128, 128]), 'median_patient_size_in_voxels': array([195, 207, 207]), 'current_spacing': array([2.473119 , 1.89831205, 1.89831205]), 'original_spacing': array([1. , 0.76757812, 0.76757812]), 'do_dummy_2D_data_aug': False, 'pool_op_kernel_sizes': [[2, 2, 2], [2, 2, 2], [2, 2, 2], [2, 2, 2], [2, 2, 2]], 'conv_kernel_sizes': [[3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3]]}

stage: 1
{'batch_size': 2, 'num_pool_per_axis': [5, 5, 5], 'patch_size': array([128, 128, 128]), 'median_patient_size_in_voxels': array([482, 512, 512]), 'current_spacing': array([1. , 0.76757812, 0.76757812]), 'original_spacing': array([1. , 0.76757812, 0.76757812]), 'do_dummy_2D_data_aug': False, 'pool_op_kernel_sizes': [[2, 2, 2], [2, 2, 2], [2, 2, 2], [2, 2, 2], [2, 2, 2]], 'conv_kernel_sizes': [[3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3]]}

I am using stage 1 from these plans
I am using batch dice + CE loss

I am using data from this folder: /home/VT-UNet/VTUNet/DATASET/vtunet_preprocessed/Task003_Liver/vtunetData_plans_v2.1
###############################################
loading dataset
loading all case properties
2022-08-16 04:36:37.549490: Creating new 5-fold cross-validation split...
2022-08-16 04:36:37.550782: Desired fold for training: 0
2022-08-16 04:36:37.550879: This split has 387 training and 73 validation cases.
Traceback (most recent call last):
File "/home/VT-UNet/transegvenv/bin/vtunet_train", line 33, in
sys.exit(load_entry_point('vtunet', 'console_scripts', 'vtunet_train')())
File "/home/VT-UNet/VTUNet/vtunet/run/run_training.py", line 134, in main
trainer.initialize(not validation_only)
File "/home/VT-UNet/VTUNet/vtunet/training/network_training/vtunetTrainerV2_vtunet_liver_base.py", line 90, in initialize
self.dl_tr, self.dl_val = self.get_basic_generators()
File "/home/VT-UNet/VTUNet/vtunet/training/network_training/vtunetTrainer.py", line 401, in get_basic_generators
self.do_split()
File "/home/VT-UNet/VTUNet/vtunet/training/network_training/vtunetTrainerV2_vtunet_liver_base.py", line 410, in do_split
self.dataset_tr[i] = self.dataset[i]
KeyError: 'BRATS_001'`

Any idea how to fix this, also but separately I get an error when I try to do the vtunet_train_3d?

@himashi92
Copy link
Owner

Thank you. Inside your vtunetTrainerV2_vtunet_liver_base.py script, modify the file name prefix in the code line:

splits[self.fold]['train'] = np.array(['LiverXX', ... ])

@b3r-prog
Copy link
Author

Thanks for the reply. Just to clarify I should change all the prefix for the data splits?

i.e. change from this splits[self.fold]['train'] = np.array(['BRATS_001', 'BRATS_002', 'BRATS_003', 'BRATS_004' ...

to this

splits[self.fold]['train'] = np.array(['liver_001', 'liver_002', 'liver_003', 'liver_004' .... same convention in the preprocessed files.

@b3r-prog
Copy link
Author

fyi @himashi92, I made the change but I'm still getting this error

RuntimeError: Could not find trainer class in vtunet.training.network_training. I'm updating the class function in the vtunetTrainerV2_vtunet_liver_base.py file to vtunetTrainerV2_vtunet_liver_base from vtunetTrainerV2_vtunet_tumor_base. I guess I have to change the classes as well

@b3r-prog
Copy link
Author

b3r-prog commented Aug 16, 2022

I was able to resolve the above errors but now getting this KeyError: 'liver_131'. When I check the preprocessed files, it seems to stop at liver_130. Is there a way to change this to ensure that all the data is preprocessed? Right now, the file vtunetTrainerV2_vtunet_liver_base.py shows that the data should go all the way to liver_484 but the preprocessed files stop at liver_130.

I understand a little now. The vtunetTrainerV2_vtunet_liver_base.py file generates based on both train and test while the output data splits is correctly only on the train segment. I'll remove the unneeded entries from the vtunetTrainerV2_vtunet_liver_base.py and see if it works.

@b3r-prog
Copy link
Author

b3r-prog commented Aug 16, 2022

Hi @himashi92, resolved above but getting this error RuntimeError: Given groups=1, weight of size [72, 4, 4, 4, 4], expected input[2, 1, 128, 128, 128] to have 4 channels, but got 1 channels instead now. I guess this is related to the number of channels difference between the liver and tumor images. Is there a specific place to change this? Your previous comment suggested changing here VT-UNet/vtunet/vision_transformer.py but the file is no longer available. I can also help with a write up on the readme on adapting to a different dataset

@himashi92
Copy link
Owner

create a script like vtunet_tumor.py for liver dataset and change in_channels=1 https://github.com/himashi92/VT-UNet/blob/main/VTUNet/vtunet/network_architecture/vtunet_tumor.py#L780

@b3r-prog
Copy link
Author

Thanks, works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants