how load a different sessions files from the same subject

1 次查看(过去 30 天)
Hi, I have one problem. I have a list of file which looks like this.
00060-DAY1-K-0-1041_Condi1.MRK
00060-DAY1-K-0-1041_Condi2.MRK
00060-DAY2-K-0-1042_Condi1.MRK
00060-DAY2-K-0-1043_Condi2.MRK
00062-DAY1-K-0-1055_Condi1.MRK
00062-DAY1-K-0-1056_Condi2.MRK
00062-DAY2-K-0-1057_Condi1.MRK
00062-DAY2-K-0-1058_Condi2.MRK......
Number (e.g 00060) is a subject number, "DAY1" means the first or the second(DAY2) session, and "Condi1" mens the first or the second condition of the experiment. The part of the file name between the "DAY" and "Condi" is irrelevant.
This files contain the data I need to extract and average. And I am able to do that with single files. But the problem begins when I need to combine different session files from the same subject in order to get data in the same matrix.
For example, I want to load files of the first condition(Condi1) for one Subject(00060). This means that
00060-DAY1-K-0-1041_Condi1.MRK
00060-DAY2-K-0-1042_Condi1.MRK
should be loaded together for the extraction of data.
I suppose that some kind of regular expression could be employed but I have no idea how.
Please help!
Thank you in advance!
NP

回答(1 个)

John Petersen
John Petersen 2012-11-21
One way to do this is to filter the directory of files by some user input. A GUI would be a nice user friendly way, but if you don't know how to make a GUI, then you could just do it in an mfile. You might end up with something like
subjectnum = input('Input subject number: '); % enter it in single quotes
condition = input('Input condition: '); % also enter in single quotes.
files = dir;
match = strfind({files.name},subjectnum);
idx = find(not(cellfun('isempty',match)));
subfiles = {files(idx).name};
match = strfind(subfiles,condition);
idx = find(not(cellfun('isempty',match)));
filterfiles = subfiles(idx);
now filterfiles has only the files that you want to process.

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by