Input folders or files do not contain specified file extensions:

30 views (last 30 days)
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 Comments
Walter Roberson
Walter Roberson on 2 Nov 2019
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 .

Sign in to comment.

Accepted Answer

Ajay Pattassery
Ajay Pattassery on 4 Nov 2019
Edited: Ajay Pattassery on 4 Nov 2019
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 Comments
Walter Roberson
Walter Roberson on 18 May 2020
pxds = pixelLabelDatastore(labelDir, classNames, labelIds, 'FileExtensions', '.nii', 'ReadFcn', @sampleReadFcn);
imds = imageDatastore(imageDir, 'FileExtensions', '.nii', 'ReadFcn', @sampleReadFcn);

Sign in to comment.

More Answers (1)

Gökay Karayegen
Gökay Karayegen on 18 May 2020
Edited: Gökay Karayegen on 18 May 2020
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 Comments
hla hla myint
hla hla myint on 20 Oct 2020
Dear
Gökay Karayegen'
My research is same to you. I do not solve error_message PNG. Please help me.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!