0

I'm having some trouble loading up my files properly - so far all I get is a 0x1 struct - I'm sure there's an easy method for it, but it's eluding me.

I have a big folder with .bmp images; out of them, I only need to analyze certain particular ones.

My folder is divided up into 200 folders, named IMD002-IMD475, with some numbers missing. Each of them is divided up into three further folders, one of which is given the name of, i.e. IMD002_roi, depending on the main folder's name. That's the folder with the images I need. The images inside all have varying names, but the common point is they all contain the word 'label' in them.

How can I load up only the files I need? I tried dir(), but as it only accepts one wildcard space, that method is out of the question.

sal
  • 45
  • 1
  • 7
  • 1
    `dir` does not only accept one wildcard space. What version of MATLAB are you using? Please see [mcve]. – sco1 Sep 05 '17 at 18:25
  • 2
    Perhaps the answers here could help you?: [How to get all files under a specific directory in MATLAB?](https://stackoverflow.com/q/2652630/52738) – gnovice Sep 05 '17 at 18:25
  • In R2016b, this appears to work just fine: `dirData = dir('top_folder/IMD*/*_roi/*label*.bmp');` – gnovice Sep 05 '17 at 18:32
  • @gnovice , I reproduced your code, however the result is still a 0x1 struct. I'm using MATLAB R2016a. – sal Sep 05 '17 at 18:36
  • You can try `rdir.m` from File Exchange. I found it very useful for this purpose. – Adiel Sep 05 '17 at 18:44
  • Do you need a `**` for all subfolders? See documentation here. https://www.mathworks.com/help/matlab/ref/dir.html#bvd_n8a – Yvon Sep 05 '17 at 19:07
  • @sal: Ah, I see. The updates to `dir` that allow my above solution to work were made in R2016b, so your version doesn't have them. You may be able to use my [`dirPlus`](https://stackoverflow.com/a/2654459/52738) utility, like so: `dirData = dirPlus('test_folder', 'Struct', true, 'FileFilter', '.*label.*\.bmp$');` – gnovice Sep 05 '17 at 19:15

0 Answers0