Input folders or files do not contain specified file extensions:

hy,
I have a doubt regarding loading '.nii' (NIFTI) files in my CNN architecture for segmentation (I am using segnet architecture). I have attached the snapshot of the error and my code. I want to load my .nii file dataset inside imds . please suggest me any option.
Untitled.png

3 件のコメント

Walter Roberson
Walter Roberson 2019 年 11 月 1 日
The error is occuring for the pixelLabelDatastore() call, not for the imageDataStore that you are creating.
pxds = pixelLabelDatastore(location,classNames,pixelLabelIDs) creates a PixelLabelDatastore object from image files that store pixel label data, in the folder or files specified by location. The function creates the object using pixel IDs that map image pixel label values to class names.
However, it cannot find any image files in E:\PHD\LITS17\GroundTruth\
Emerson Nithiyaraj
Emerson Nithiyaraj 2019 年 11 月 2 日
yes my images are stored in 3D form with extension (.nii) i.e. medical file named NIFTI (Neuro imaging) file. So that i have coded with file extension in creating image datastore. Still, my input file format is not accepted by the network. please help me.
imds = imageDatastore(imageDir,'FileExtensions','.nii');
Walter Roberson
Walter Roberson 2019 年 11 月 2 日
You would need to provide the FileExtensions option for the pixelLabelDatastore call. You will need to provide a ReadFcn property. You will probably also need a ReadFcn property for the imageDataStore .

サインインしてコメントする。

 採用された回答

Ajay Pattassery
Ajay Pattassery 2019 年 11 月 4 日
編集済み: Ajay Pattassery 2019 年 11 月 4 日

1 投票

Here if you do not define the ReadFcn explicitly, the default function used is imread() which is not supported for .nii extension.
Hence add ReadFcn as suggested by Walter Roberson.
pxds = pixelLabelDatastore(labelDir,classNames,labelIds,'FileExtensions','.nii','ReadFcn',sampleReadFcn);
imds = imageDatastore(imageDir,'FileExtensions','.nii','ReadFcn',sampleReadFcn);
The custom ReadFcn looks something like the following
function data = sampleReadFcn(filename)
data = niftiread(filename);
end
Refer here for more information on custom ReadFcn.
Refer niftiread for more info.

3 件のコメント

Emerson Nithiyaraj
Emerson Nithiyaraj 2019 年 11 月 12 日
編集済み: Emerson Nithiyaraj 2019 年 11 月 12 日
Thankyou so much for your help and this sampleReadFcn has cleared my error.
Ajay Pattassery
Ajay Pattassery 2019 年 11 月 12 日
Please create as a new question.
Walter Roberson
Walter Roberson 2020 年 5 月 18 日
pxds = pixelLabelDatastore(labelDir, classNames, labelIds, 'FileExtensions', '.nii', 'ReadFcn', @sampleReadFcn);
imds = imageDatastore(imageDir, 'FileExtensions', '.nii', 'ReadFcn', @sampleReadFcn);

サインインしてコメントする。

その他の回答 (1 件)

Gökay Karayegen
Gökay Karayegen 2020 年 5 月 18 日
編集済み: Gökay Karayegen 2020 年 5 月 18 日

0 投票

Hello ! I have a problem regarding pixellabel data store too. The screenshot of the error and the part of the code are enclosed above. Do you have any suggentions? I would be really glad if anyone could help me? Regars,

7 件のコメント

Walter Roberson
Walter Roberson 2020 年 5 月 18 日
編集済み: Walter Roberson 2020 年 5 月 18 日
That option is new for pixelLabelDatastore as of R2019a.
Before that, the workaround would seem to be to pass in all of the file names. For example,
dinfo = dir(fullfile(labelDir, '**', '*.nii'));
filenames = fullfile({dinfo.folder}, {dinfo.name});
pxds = pixelLabelDatastore(filenames, classnames, labelIDs, 'ReadFcn', matReader);
Gökay Karayegen
Gökay Karayegen 2020 年 5 月 19 日
Thank you so much for the update. First two lines worked very well. However, I got the same error for 'ReadFcn' this time. Do you have an idea to overcome this issue. Thank you in advance for your help.
Walter Roberson
Walter Roberson 2020 年 5 月 19 日
try
dinfo = dir(fullfile(labelDir, '**', '*.nii'));
filenames = fullfile({dinfo.folder}, {dinfo.name});
pxds = pixelLabelDatastore(filenames, classnames, labelIDs);
pxsd.ReadFcn = matReader;
Gökay Karayegen
Gökay Karayegen 2020 年 5 月 19 日
I am getting this error message.
Walter Roberson
Walter Roberson 2020 年 5 月 24 日
My recommendation would be to upgrade MATLAB versions.
Gökay Karayegen
Gökay Karayegen 2020 年 5 月 26 日
Hello again ! Finally I manage to solve the problem. However, this time I am getting an error regarding trainnetwork command. Do you have any suggestions? Thank you once again.
Error using trainNetwork (line 170)
The subscript vectors must all be of the same size.
Error in semantik_derinogrenme (line 145)
net = trainNetwork(trainingData,layers,opts);
Caused by:
Error using sub2ind (line 69)
The subscript vectors must all be of the same size.
hla hla myint
hla hla myint 2020 年 10 月 20 日
Dear
Gökay Karayegen'
My research is same to you. I do not solve error_message PNG. Please help me.

サインインしてコメントする。

製品

リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by