Extract data from struct using condition across fields

3 views (last 30 days)
DavidL88
DavidL88 on 16 Oct 2020
Commented: DavidL88 on 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 Comments
DavidL88
DavidL88 on 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.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!