Clear Filters
Clear Filters

how load a different sessions files from the same subject

2 views (last 30 days)
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

Answers (1)

John Petersen
John Petersen on 21 Nov 2012
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.

Categories

Find more on Graph and Network Algorithms 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!