Borrar filtros
Borrar filtros

how load a different sessions files from the same subject

1 visualización (últimos 30 días)
Nenad Polomac
Nenad Polomac el 16 de Nov. de 2012
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

Respuestas (1)

John Petersen
John Petersen el 21 de Nov. de 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.

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by