rezazad68 / BCDU-Net

BCDU-Net : Medical Image Segmentation
712 stars 264 forks source link

Issue in Prepare_Data.py #29

Closed ruchaa01 closed 3 years ago

ruchaa01 commented 3 years ago

Hi,

I was trying to implement lung segmentation from the repo. As mentioned, I downloaded the dataset from Kaggle. I processed the data and the npy files are now being saved inside the processed_data folder under Lung Segmentation. In order to train the network, I was trying to use train.py file, but ran into an error that states:

File "train_lung.py", line 20, in tr_data = np.expand_dims(tr_data, axis=3) File "<__array_function__ internals>", line 6, in expand_dims File "/home/achoudhury/biomedseg/lib/python3.6/site-packages/numpy/lib/shape_base.py", line 597, in expand_dims axis = normalize_axis_tuple(axis, out_ndim) File "/home/achoudhury/biomedseg/lib/python3.6/site-packages/numpy/core/numeric.py", line 1358, in normalize_axis_tuple axis = tuple([normalize_axis_index(ax, ndim, argname) for ax in axis]) File "/home/achoudhury/biomedseg/lib/python3.6/site-packages/numpy/core/numeric.py", line 1358, in axis = tuple([normalize_axis_index(ax, ndim, argname) for ax in axis]) numpy.AxisError: axis 3 is out of bounds for array of dimension 2

Can you please help me with it?

Thank you so much!

rezazad68 commented 3 years ago

Hi,

Thanks for your interest. Please let me know the shape of tr_data.

ruchaa01 commented 3 years ago

Thank you so much for your reply. Initially, when I unzip the data in the Lung Segmentation folder and run the Prepare_data.py script, it starts implementing and prints upto 4 idx and then prints Killed and the implementation stops. So, processed data folder couldn't be created. Late I tried to unzip the dataset folder under BCDU-Net and not inside Lung Segmentation folder, and tried to run the Prepare_data script. I got the following error: Traceback (most recent call last): File "Prepare_data.py", line 50, in Train_img = Data_train[0:alpha,:,:] IndexError: too many indices for array: array is 1-dimensional, but 3 were indexed

After looking at one of the pull requests, I modified the prepare_data script as follows - Train_img = Data_train[0:alpha] Test_img = Data_train[alpha:en_d]

Train_mask = Mask_train[0:alpha] Test_mask = Mask_train[alpha:en_d]

Train_maska = Maska_train[0:alpha] Test_maska = Maska_train[alpha:en_d]

FOV_tr = FOV_train[0:alpha] FOV_te = FOV_train[alpha:en_d]

After making these changes, the processed_data folder is being created, but the shape of tr_data is (0,).

Can you please guide me more on what I might be missing in creating a processed data folder?

Thank you so much. I appreciate your help.

rezazad68 commented 3 years ago

Sorry for the delay, if the shape of your data is zero then you should check your data address carefully.

Tr_add = '3d_images' Tr_list = glob.glob(Tr_add+'/*.gz')

if you put your original data in any other address just change the Tr_add, for example, if you put it on the BCDUnet folder then Tr_add= "../3d_images/" also when you download the dataset it has other files also, just use the 3d_images and fix your address.

Best