Radi_tech’s blog

Radiological technologist in Japan / MRI / AI / Deep learning / MATLAB / R / Python

【MATLAB】How to remove hidden files from list

This article introduce how to remove hidden files from list.

For example, it is important to remove hidden files to perform batch processing with "for method" in the medical imaging analysis.

Hidden files would abort processing due to incorrect file path.



MATLAB code is the below.

%  Selecting image fold using uigetdir().
MR_fd= uigetdir();

% Getting files using dir()
MR_fl=dir(MR_fd);

% Removing hidden files using the following code
MR_fl=MR_fl(~ismember({MR_fl.name}, {'.','..','.DS_Store','._.DS_Store','._*'}));

%Convert to cell types
MR_fl={MR_fl.name}

This code provides file list without hidden file.