How to read multiple files in a folder and extract information for each one

7 views (last 30 days)
I have a code that extracts multiple features on one Dicom slice, from a folder that has 350 slices
I now need to make a for loop that will allow me to extract the same features for the remaining Dicom slices in the folder, and then later take the average of each feature
Can anyone suggest how i can do this?
Here is the code I have for doing it for just one of the slices
%%
im=double(dicomread('slice1.dcm'));
[LL1,LH1,HL1,HH1] = dwt2(im,'sym4','mode','per');
[LL2,LH2,HL2,HH2] = dwt2(LL1,'sym4','mode','per');
[LL3,LH3,HL3,HH3] = dwt2(LL2,'sym4','mode','per');
%%
GLSZM_Original = getGLSZMtextures(im)
GLSZM_First_Depthlevel = getGLSZMtextures(LL1)
GLSZM_Second_Depthlevel = getGLSZMtextures(LL2)
GLSZM_Third_Depthlevel = getGLSZMtextures(LL3)
%%
GLCM_Original = getGLCMtextures(abs(im))
GLCM_First_Depthlevel = getGLCMtextures(abs(LL1))
GLCM_Second_Depthlevel = getGLCMtextures(abs(LL2))
GLCM_Third_Depthlevel = getGLCMtextures(abs(LL3))
%%
GLRLM_Original = getGLRLMtextures(im)
GLRLM_First_Depthlevel = getGLRLMtextures(LL1)
GLRLM_Second_Depthlevel = getGLRLMtextures(LL2)
GLRLM_Third_Depthlevel = getGLRLMtextures(LL3)

Answers (1)

Mahesh Taparia
Mahesh Taparia on 15 Dec 2020
Hi
You can use dir function to list out the content of a folder. After this use a for loop, in that you can keep the file reading and further processing part. You can use fullfile function if data is present in subfolder. You can refer this documentation for more help. The similar question has been already answered here. Hope it will help!

Categories

Find more on DICOM Format in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!