필터 지우기
필터 지우기

How to skip file in imageDatastore.ReadFcn?

조회 수: 3 (최근 30일)
tesarj13
tesarj13 2021년 1월 24일
편집: John 2022년 11월 18일
I have folder with dicom files (.dcm). Some of them are images (with size MxNx3), some of them are videos (MxNx3xnumOfFrames). I would like to use imageDatastore to read images only.
I tried this:
imds = imageDatastore('pathToDicoms','FileExtensions',{'.dcm'},'ReadFcn',@ImageLoader);
function imgOut = ImageLoader(path)
imgOut = dicomread(path);
if(length(size(imgOut))>3)
imgOut = [];
end
end
But it return empty matrix insead of ommiting the file.
How to skip file in read fuction?
  댓글 수: 1
John
John 2022년 11월 18일
편집: John 2022년 11월 18일
I used this and worked well:
exts = ".dcm";
readimgFcn = @(x)int16(dicomread(x));
imds = imageDatastore(datafiles,FileExtensions=exts,ReadFcn=readimgFcn);
Hope this helps.

댓글을 달려면 로그인하십시오.

채택된 답변

Jeremy Hughes
Jeremy Hughes 2021년 1월 25일
The only way to do this is to remove the files from the Files list on the ImageDatastore, or make a copy of this dataset which contains only the images, and not the videos.
If there's any way to tell what the contents are from the file name, or file metadata using dicominfo(filename), you might have an easier time splitting them out.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 DICOM Format에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by