Git Product home page Git Product logo

ad_prediction's People

Contributors

aozhou avatar este1le avatar wangyirui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ad_prediction's Issues

Why use CustomResize and CustomToTensor???

Hi,

This is not a bug, but I just wanna know why you chose to use your customized Class to resized and convert the image. We know that torchvision.transforms has offered all the functionalities.

One guess is that the function from torchvision has problem for GPU memory leakage???

I have the out of memory problem when I am using these functionalities from torchvision.transforms.

Another question is about the DataLoader that you used for the slice-level or path-level experiments, it seems that with the option: shuffle=True for training, the shuffle will be done on the subject-level, not from all available slices, then all slices of these subjects will be sequentially extracted to train, thus the training process is not really shuffled... Let's say, we extract 100 slices from each MRI, then the batch size is 16. The shuffle will randomly gives us 16 subjects, then the first slice of the 16 subjects were trained, then the second.....last. These results in the same orders of labels for the 100 iterations...

Can you help me clarify these two questions?

Thanks in advance

Problem / doubt in AD_Standard_3DRandomPatch

Hey @wangyirui, the problem of dimension that i am encountering is after this line

        while np.ndarray.sum(patch) == 0:
<-----------------till here the shape of patch is (7,7,7)--------------------->
            ax_ni = random.randint(first_ax - 3, last_ax - 4)
            cor_ni = random.randint(first_cor - 3, last_cor - 4)
            sag_ni = random.randint(first_sag - 3, last_sag - 4)
            patch = image_array[ax_ni - 3:ax_ni + 4, cor_ni - 3:cor_ni + 4, sag_ni - 3:sag_ni + 4]


<-----------------after this the patch.shape changes to (0,7,7) or (3,7,7) or (5,7,7)----------------->

Can you kindly tell me how you are taking the value of ax_ni ,cor_ni, sag_ni?
is there something i missed?
Thank you for having such great patience.

Too many dimension issue

Hey i am running your code and getting this error

2018-04-19 14:45:49 INFO: At 0-th epoch. Traceback (most recent call last): File "main_alextnet.py", line 234, in <module> main(options) File "main_alextnet.py", line 133, in main train_loss, correct_cnt = train(model, train_loader, use_cuda, criterion, optimizer, train_loss_f) File "main_alextnet.py", line 158, in train for it, train_data in enumerate(train_loader): File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 281, in __next__ return self._process_next_batch(batch) File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 301, in _process_next_batch raise batch.exc_type(batch.exc_msg) ValueError: Traceback (most recent call last): File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 55, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "/Users/science/Desktop/Alziehmer/AD_Prediction/AD_2DRandomSlicesData.py", line 60, in __getitem__ image2D = Image.fromarray(image2D.astype(np.uint8), 'RGB') File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/PIL/Image.py", line 2441, in fromarray raise ValueError("Too many dimensions: %d > %d." % (ndim, ndmax)) ValueError: Too many dimensions: 4 > 3.

Can you help me in solving this problem?

Conversion from array to tensor error

I am getting this error when i am running main_autoencoder.py.

Traceback (most recent call last): File "main_autoencoder.py", line 101, in <module> main(options) File "main_autoencoder.py", line 74, in main for i, patches in enumerate(train_loader): File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 281, in __next__ return self._process_next_batch(batch) File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 301, in _process_next_batch raise batch.exc_type(batch.exc_msg) RuntimeError: Traceback (most recent call last): File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 55, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "/Users/science/Desktop/Alziehmer/AD_Prediction/AD_Standard_3DRandomPatch.py", line 42, in __getitem__ patch_samples = getRandomPatches(image_array) File "/Users/science/Desktop/Alziehmer/AD_Prediction/AD_Standard_3DRandomPatch.py", line 80, in getRandomPatches img = torch.from_numpy(img)

RuntimeError: can't convert a given np.ndarray to a tensor - it has an invalid type. The only supported types are: double, float, int64, int32, and uint8.

Kindly help me solve this?

How to classify Images

Hey @wangyirui ,can you tell me how i can classify a test image? i have trained the model but can't figure out how to classify the images with accurate answers

CNN accuracy is Zero

I checked the pretrained weights and bias of autoencoder and tried to run main_cnn_autoencoder. But it gives 0.00 accuracy and loss. I dont know what is going wrong. I tried a method in some other tutorial that too gives the same result.

Classification Error

Hi,
I've been training my model using ADNI dataset, when i'm training I'm getting a loss of 0.05 but during validation It's just predicting one class out of the two for all set of images.
I'm really confused ,i dont know what am I doing wrong.
Please help.

Installation

Hi,

I'm Esha, a highschooler using this for Alzheimer's and neural networks research work. I just downloaded the zip file: AD_Prediction-master.zip. After I extracted the zip I am unable to find the installation script. Could you please point me where to look or am I missing any other file to download? I am on a time crunch so I greatly appreciate your help.

Thanks,
Esha

Dataset related queries

We are currently working on the same project and we are facing same issues related to image processing as in how to input the images to the SPM software.

Subscriptable Error

F:\VAIO\Latest\AD_Prediction-master\AD_Prediction-master\2D>python main_alextnet.py
2018-05-05 16:00:35 INFO: At 0-th epoch.
Traceback (most recent call last):
File "main_alextnet.py", line 236, in
main(options)
File "main_alextnet.py", line 135, in main
train_loss, correct_cnt = train(model, train_loader, use_cuda, criterion, optimizer, train_loss_f)
File "main_alextnet.py", line 160, in train
for it, train_data in enumerate(train_loader):
File "C:\Users\Hashim\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 281, in next
return self._process_next_batch(batch)
File "C:\Users\Hashim\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 301, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
TypeError: Traceback (most recent call last):
File "C:\Users\Hashim\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 55, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "C:\Users\Hashim\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 55, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "F:\VAIO\Latest\AD_Prediction-master\AD_Prediction-master\2D\AD_2DRandomSlicesData.py", line 56, in getitem
AXimageList = axRandomSlice(image)
File "F:\VAIO\Latest\AD_Prediction-master\AD_Prediction-master\2D\AD_2DRandomSlicesData.py", line 94, in axRandomSlice
return getRandomSlice(image_array, NON_AX, AX_F, AX_SCETION)
File "F:\VAIO\Latest\AD_Prediction-master\AD_Prediction-master\2D\AD_2DRandomSlicesData.py", line 73, in getRandomSlice
first_p = list(mean_array).index(filter(lambda x: x>0, mean_array)[0])
TypeError: 'filter' object is not subscriptable
I just ran your code with your dataset but I get this type error and unable to figure it out. Kindly help me resolving this error

50% accuracy with alexnet after 300 epochs

Hi @wangyirui ,
I downloaded the data from ADNI site and also skull stipped it. Now when I run the code with main_alexnet.py I am getting very low accuracy. The accuracy is only around 51% which is far away from what I can see in the results. I am not sure why this is happening. Previously when the data wasn't skull stripped I thought that was the reason. But even after skull stripping I am getting low accuracy. I can see in other comments where someone else achieved 80% accuracy too. Can you please guide me on this.
Thanks for your help. :)

咨询阿尔兹海默症SMRI预处理

老师 您好 我想用CNN对MRI图像进行分类 ,您给指点一下,我要做几步预处理,需要用到哪些软件,希望您可以回复一下,万分感谢

Convert three 2D MRI slices into a RGB image for transfer learning

Hi,

Thanks very much for your work.

I have a question about how you convert slices into a RGB image.

To constructed a RGB color image, we concatenate the key position slice, one slice one index before the key position, and one slice one index after the key position, into R, G, and B channels respectively(Figure 3b).

I understand that the pertrained models like AlexNet was trained based on ImageNet RGB images. That's reasonable to transfer the MRI slices into a RGB to facilitate the training. One question is that did you normalize the image intensity to 0-255? We know that the intensity of MRI image ranges from a much border ranges than the RGB image. If you simply put the 3 slices into the R, G, B channels; the resulting images mean nothing to be a MRI brain image (For some slices, it works like you showed in your repo, but for other slices, it is no longer a brain)… So I wander how you get the synthesized 2D RGB image, did you always get the good images??

Thanks very much in advance

Hao

why 2D slices

Hello @wangyirui , i wanted to as why did you select 2D slice since the volume is taken as key feature in case of Alzheimer disease.. so could have looked for deformations of structures ..so isnt 3D more appropriate? is there any reference material that suggests this idea?

Invalid Argument 0 error

Hey,

When i run
python main_autoencoder.py --batch_size 32 --num_classes 2 --epochs 200 --gpuid -1
I get this error:

At 0-th epoch.
Traceback (most recent call last):
  File "main_autoencoder.py", line 101, in <module>
    main(options)
  File "main_autoencoder.py", line 74, in main
    for i, patches in enumerate(train_loader):
  File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 281, in __next__
    return self._process_next_batch(batch)
  File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 301, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
RuntimeError: Traceback (most recent call last):
  File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 55, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 132, in default_collate
    return {key: default_collate([d[key] for d in batch]) for key in batch[0]}
  File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 132, in <dictcomp>
    return {key: default_collate([d[key] for d in batch]) for key in batch[0]}
  File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 135, in default_collate
    return [default_collate(samples) for samples in transposed]
  File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 112, in default_collate
    return torch.stack(batch, 0, out=out)
  File "/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/functional.py", line 66, in stack
    return torch.cat(inputs, dim, out=out)

RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 7 and 3 in dimension 2 at /Users/soumith/code/builder/wheel/pytorch-src/torch/lib/TH/generic/THTensorMath.c:2897

Is there anyway you can help me with this?

SPM preprocessing

Hi, first of all many thanks for sharing this- this is extremely helpful for a project I am currently undertaking. I would like to ask, I have noticed that the SPM software suggests this is only for fMRI images. However, I believe that you are using sMRI and was therefore wondering if the preprocessing steps would be the same?
Many thanks in advance for your help!

Autoencoder model file

Hi I am trying to execute your project but it the folder didn't had autoencoder_pretrained_model39. So can you please share it too.

axis 2 is out of bounds for array of dimension 1

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.