Using regular expressions to filter files
Ältere Kommentare anzeigen
Hi everyone,
I need to use regular expressions to filter through a directory of nii files and create a cell array of files that match the requirements. However, I am new to matlab and there are just too many requirements for me to work out the regular expression needed.
The desired cell array looks like this (but note that the nii files have 20 frames so I want the script to loop through 20 times):
In the past, I have been able to create these arrays by just using dir and filtering using ‘*.nii, however, the directory I am working with has loads of different nii, files so using it here would not be specific enough.
As you can see from the picture above, the pattern I am looking for is ‘ica_sub’ + 3 digits + _component_ica_s + 1 digit + ‘_.nii, + a final digit.
As explained above, the nii files have 20 frames so the 'final digit' in the expression will need to be a variable containing the numbers 1 to 20 (which I will loop through).
I am just really confused about how to combine all of this together. If anyone can help me out I would appreciate it so much.
Gerard
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu File Operations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!