why this error is heppening?

my CNN code to train brats images with nifti extension
brainDatasetPath=fullfile('D:','MSCS SUPERIOR','Image Processing','source_code');
imds = imageDatastore(brainDatasetPath, ...
'FileExtensions','.mat','ReadFcn',@(x) matRead(x));
b=load(imds.Files{1});
c=b.Images;
cellArray=cellmat(1,155,240,240,0);
for k=1:155
cellArray{k}=c(:,:,k); % storing each slice in cell array
end
%[trainDigitData,valDigitData] = splitEachLabel(cellArray,75,'randomize');
trainDigitData = cellArray(1:100);
valDigitData = cellArray(101:155);
%% Define Network Architecture
% Define the convolutional neural network architecture.
layers = [
imageInputLayer([240 240 1])
convolution2dLayer(3,16,'Padding',1)
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,32,'Padding',1)
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,64,'Padding',1)
batchNormalizationLayer
reluLayer
fullyConnectedLayer(10)
softmaxLayer
classificationLayer];
%% specify training options
options = trainingOptions('sgdm',...
'MaxEpochs',3, ...
'ValidationData',cellArray(101:155),...
'ValidationFrequency',30,...
'Verbose',false,...
'Plots','training-progress');
error
Error using trainingOptions (line 187)
The value of 'ValidationData' is invalid. Cell array with validation data must have two
elements: the input data X and a numeric array of responses Y.
Error in test (line 43)
options = trainingOptions('sgdm',...

8 Comments

Looks plausible to me. Validation data is not just arrays of input to test against: validation data must also include information about what class the input belongs to. Perhaps the information is in some other field of b or perhaps you want to exact the class information from the file names.
can you change b for me. so that it contains second field to contain class information.
Your variable names imply that you have images of digits (or perhaps of thinking about digits) and that somewhere there is information about which image corresponds to which digit. Which variable contains that information about which image corresponds to which digit?
Actually variable names not representing actual data. actual data is BRATS2017 brain MRI wih nifty extension. how can i read that data using imageDatastore object.
So is it correct that you have downloaded a dataset of brain MRI in which the authors of the dataset did not provide any information about which class each of the images falls into? If so then you cannot proceed, except perhaps by finding a brain MRI specialist who is willing to classify all of the images for you. But if the authors did provide information about which image belongs to which class, then you need to find or transcribe that information .
"All the imaging datasets have been segmented manually, by one to four raters, following the same annotation protocol, and their annotations were approved by experienced neuro-radiologists. Annotations comprise the GD-enhancing tumor (ET — label 4), the peritumoral edema (ED — label 2), and the necrotic and non-enhancing tumor (NCR/NET — label 1), as described in the BraTS reference paper, published in IEEE Transactions for Medical Imaging (also see Fig.1)."
It would be very weird if they went through all of that trouble but did not provide the label information with the datasets.
yes it is true they did not label the data but for each patient data they provided ground truth data. for example a patient's 155 slices of origional data and for those they provided 155 slices of ground truth values of MRI.
If all of this were working properly, then would would the desired outcome be? That you feed in images and it would tell you whether somewhere in the image there was a Grade II pteroblastoma ? Or that in each case you would get out a fully labeled image? If I understand your code correctly (and I probably do not), your code is set up to consider an entire image and classify the image as a whole into one of several different classes.

Sign in to comment.

Answers (0)

Categories

Tags

Asked:

on 1 Aug 2019

Commented:

on 6 Aug 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!