Extract data from struct using condition across fields

2 vues (au cours des 30 derniers jours)
DavidL88
DavidL88 le 16 Oct 2020
Commenté : DavidL88 le 27 Oct 2020
Hi
I have a struct file sFiles (a 1x144 struct file). This contains the results of t-tests perfomed on neuro-imaging data (I conducted 144 analyses and around 35 were p < 0.05. I opened a substruct/field in sFiles and called it DataMat (a struct with 37 fields). I wanted to extract data from 4 fields in DataMat based on a certain criteria. Three fields have corresponding forms (1x103 double) with the t values, p values and the time in the experiment for each value. I have managed to extract all the t values with a p value < 0.05 and the time at which it occured and place them in a table (using col variable). I can't figure out how to get the name of each analysis (in DataMat.Comment) with a p value < 0.05. Can anyone advise how I do this?
David
% Input files
sFiles = [];
% Start a new report
bst_report('Start', sFiles);
% Process: Select files using search query
sFiles = bst_process('CallProcess', 'process_select_search', [], [], ...
'search', '(([path CONTAINS "ERP_perm_ROI"] AND [name CONTAINS "Perm t-test equal"]))');
T1 = [];
T2 = [];
T3 = [];
T4 = [];
for iFile = 1:length(sFiles)
DataMat = in_bst_data(sFiles(iFile).FileName);
analysis = {DataMat.Comment}
tvalue = DataMat.tmap
pvalue = DataMat.pmap
time = DataMat.Time
col = min(find(DataMat.pmap(1,:)<=0.05));
A1 = pvalue(:,col);
A2 = tvalue(:,col);
A3 = time(:,col);
A4 = analysis;
T1 = [T1; A1];
T2 = [T2; A2];
T3 = [T3; A3];
T4 = [T4; A4];
end
  2 commentaires
Chidvi Modala
Chidvi Modala le 27 Oct 2020
Hi David,
From my understanding, you are trying to extract data from 4 fields(pmap,tmap,Time,Comment) based on the condition pvalue<0.05. I am assuming that DataMat.Comment contains the information about the name of each analysis. Can you help me clarify the following?
  • As mentioned, if each field pmap, tmap and Time is 1x103 double row vector, then why are you trying to use double indexing as shown below
A1 = pvalue(:,col);
A2 = tvalue(:,col);
A3 = time(:,col);
  • What is the datatype and size of Data.Comment ? And what exactly do you mean by "can't figure out how to get the name of each analysis"? Is it throwing any error or are you having trouble in understanding how to extract the value?
DavidL88
DavidL88 le 27 Oct 2020
Dear Chidvi,
Thank you for your reply. I have figured this out. The answer was to place the data from all 4 fields (A1-4) I was seeking within {} in order to concatenate them so they would fit into a table together.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by