AD_Prediction icon indicating copy to clipboard operation
AD_Prediction copied to clipboard

axis 2 is out of bounds for array of dimension 1

Open Aliktk opened this issue 4 years ago • 7 comments

I am using your code I don't know why its not running smooth many errors removed but still getting this error please specify the reason why its is happening??

My preferences python 3.7 anaconda installed all libraries which are required .

Here I am getting the error runfile('C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master/main_alexnet.py', wdir='C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master') Reloaded modules: custom_transform2D, AD_Dataset, AD_Standard_2DSlicesData, AD_Standard_2DRandomSlicesData 2020-02-04 10:22:24 INFO: At 0-th epoch. Traceback (most recent call last):

File "", line 1, in runfile('C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master/main_alexnet.py', wdir='C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master')

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master/main_alexnet.py", line 238, in main(options)

File "C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master/main_alexnet.py", line 134, in main train_loss, correct_cnt = train(model, train_loader, use_cuda, criterion, optimizer, train_loss_f)

File "C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master/main_alexnet.py", line 162, in train for it, train_data in enumerate(train_loader):

File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 345, in next data = self._next_data()

File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 385, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration

File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index]

File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index]

File "C:\Users\Ali ktk.spyder-py3\AD_Prediction-master new\AD_Prediction-master\AD_Standard_2DRandomSlicesData.py", line 60, in getitem image2D = self.transform(image2D)

File "C:\ProgramData\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py", line 70, in call img = t(img)

File "C:\Users\Ali ktk.spyder-py3\AD_Prediction-master new\AD_Prediction-master\custom_transform2D.py", line 39, in call img = torch.from_numpy(pic.transpose((2, 0, 1)))

ValueError: axes don't match array

runfile('C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master/main_alexnet.py', wdir='C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master') Reloaded modules: custom_transform2D, AD_Dataset, AD_Standard_2DSlicesData, AD_Standard_2DRandomSlicesData, AD_Standard_2DTestingSlices, AlexNet2D 2020-02-04 10:23:12 INFO: At 0-th epoch. Traceback (most recent call last):

File "", line 1, in runfile('C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master/main_alexnet.py', wdir='C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master')

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master/main_alexnet.py", line 238, in main(options)

File "C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master/main_alexnet.py", line 134, in main train_loss, correct_cnt = train(model, train_loader, use_cuda, criterion, optimizer, train_loss_f)

File "C:/Users/Ali ktk/.spyder-py3/AD_Prediction-master new/AD_Prediction-master/main_alexnet.py", line 162, in train for it, train_data in enumerate(train_loader):

File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 345, in next data = self._next_data()

File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 385, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration

File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index]

File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index]

File "C:\Users\Ali ktk.spyder-py3\AD_Prediction-master new\AD_Prediction-master\AD_Standard_2DRandomSlicesData.py", line 53, in getitem AXimageList = axRandomSlice(image)

File "C:\Users\Ali ktk.spyder-py3\AD_Prediction-master new\AD_Prediction-master\AD_Standard_2DRandomSlicesData.py", line 87, in axRandomSlice return getRandomSlice(image_array, AX_INDEX, AX_SCETION)

File "C:\Users\Ali ktk.spyder-py3\AD_Prediction-master new\AD_Prediction-master\AD_Standard_2DRandomSlicesData.py", line 81, in getRandomSlice slice_2Dimg = np.stack((slice_select_0, slice_select_1, slice_select_2), axis = 2)

File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\shape_base.py", line 419, in stack axis = normalize_axis_index(axis, result_ndim)

AxisError: axis 2 is out of bounds for array of dimension 1

Aliktk avatar Feb 04 '20 05:02 Aliktk

I have the same problem as you!

Yanrui-Qiang avatar Jul 31 '20 04:07 Yanrui-Qiang

I have the same problem as you!

Did you manage to run the code yet?

FaRe3 avatar Sep 18 '20 13:09 FaRe3

What you want I will tell u short method. This is very heavy project and some of code has been deleted. So try something else method. Or give me overview I will guid u

Aliktk avatar Sep 19 '20 02:09 Aliktk

What you want I will tell u short method. This is very heavy project and some of code has been deleted. So try something else method. Or give me overview I will guid u

Aliktk avatar Sep 19 '20 02:09 Aliktk

What you want I will tell u short method. This is very heavy project and some of code has been deleted. So try something else method. Or give me overview I will guid u

First of all thabks for showing the interest in this. Actually I mentioned this topic to my mentor for my college project just by seeing the code. I thought it will work but when i saw you issue i think i made a mistake. Can you please help me finding the way to run this code or any other code related to Alzheimer prediction.

FaRe3 avatar Sep 19 '20 06:09 FaRe3

Yes, I tried the code much time and debug and try to remove that shity bug but unfortunately, it missing some file and a portion of the code. I will recommend some method that you follow for your project. second thing If you want to work on Alzheimer than you should first gather data and then you have to preprocess. First download dataset. prepare it and clean it (see how to clean a dataset) then if you want to start the coding part than make sure you have all lib and tools of DL. Furthermore, you have two options for data analysis.

  1. If you want to analyze your data in 3D format then you definitely need more computational power if you want to analyze your data and perform some experiments than convert your 3D data into 2D formate. Search for how to convert 3D image nii file to 2D jpg file formate.

than write coding for your project data preparing and preprocessing and then finally make a robust DL modal for your data which classifies into 3 or 4 classes. Thanks for your contact do some research and literature

Aliktk avatar Sep 19 '20 16:09 Aliktk

Yes, I tried the code much time and debug and try to remove that shity bug but unfortunately, it missing some file and a portion of the code. I will recommend some method that you follow for your project. second thing If you want to work on Alzheimer than you should first gather data and then you have to preprocess. First download dataset. prepare it and clean it (see how to clean a dataset) then if you want to start the coding part than make sure you have all lib and tools of DL. Furthermore, you have two options for data analysis.

  1. If you want to analyze your data in 3D format then you definitely need more computational power if you want to analyze your data and perform some experiments than convert your 3D data into 2D formate. Search for how to convert 3D image nii file to 2D jpg file formate.

than write coding for your project data preparing and preprocessing and then finally make a robust DL modal for your data which classifies into 3 or 4 classes. Thanks for your contact do some research and literature

Thanks for the explanation man. Just wanted to know that if this code has everything thing you said like converting 3d to 2d and the modal code thrn what part is missing.I mean i dont have that much time that i can do the whole code from scratch. If you have done any work regarding this then please help me with the code. Thank you

FaRe3 avatar Sep 20 '20 10:09 FaRe3