Home › Forums › General Help (Braph 2.0) › Export graph metric values
- This topic has 14 replies, 3 voices, and was last updated 1 year, 4 months ago by Yu-Wei Chang.
-
AuthorPosts
-
March 2, 2023 at 7:22 am #172555Sai PrasannaParticipant
Hi,
When I run the Functional analysis pipeline, is there anyway I can obtain the graph metrics values for individual subject and not just the group average. I need these values subject-wise and store them in a xls file.Thanks.
Sai PrasannaMarch 9, 2023 at 5:26 pm #173018Anna Canal-GarciaModeratorDear Sai Prasanna,
The export to XLS file in the GUI is made on the group average results. Nevertheless, we keep the results for each subject. To obtain those, you will need to create your own script. Use ‘example_FUN_WU’ as a base, which is located in the Functional folder inside pipelines, and after calculating the analysis use the following line of code:
ms1 = cellfun(@(x) x.getMeasure(measure_class).memorize('M'), analysis.memorize('G_DICT').getItems, 'UniformOutput', false);
measure_class is the type of measure you want, for example, ‘Degree’.
Best regards,
Emiliano and Anna- This reply was modified 1 year, 6 months ago by Anna Canal-Garcia.
- This reply was modified 1 year, 6 months ago by Anna Canal-Garcia.
March 10, 2023 at 6:35 am #173060Sai PrasannaParticipantThanks. I will try that.
Also, the GUI is giving me an option of exporting the results as a JSON file only. Could you please let me know how I can save the group average results into an XLS file ?
March 10, 2023 at 9:44 am #173076Sai PrasannaParticipantI’m trying to use the example_FUN_BUD as you mentioned. I need to calculate all the graph metrics. The example file mentions 2-3 metrics. Do I use similar methods for all other metrics ?
I would appreciate your guidance on saving the individual subject correlation matrices as well.
March 17, 2023 at 1:48 pm #173528Anna Canal-GarciaModerator- You can export the results to XLS if you right-click on the top of the table that is visualized by pressing Data Selected Measures or Data Selected Comparison:
Check Figure 11 and Figure 14 in this tutorial to see what I mean by going to Data Selected Measures or Data Selected Comparison: http://braph.org/tutorials/pipelines/pipeline-functional-comparison-bud/
- You can add as many metrics as you want, just change the name of the Measure in the measure_class field. The example file is to show how to calculate them using a script and not the GUI. So you can modify it as you need.
- To save the individual subject correlation matrices it is better to do it as well via script. Still, it is possible in the GUI if you press the IndexedDictionary button in the GRAPHS section in analysis.
- This reply was modified 1 year, 6 months ago by Anna Canal-Garcia.
- This reply was modified 1 year, 6 months ago by Anna Canal-Garcia.
- This reply was modified 1 year, 6 months ago by Anna Canal-Garcia.
March 21, 2023 at 7:15 am #173791Sai PrasannaParticipantThanks for your responses.
Sorry, if I’m asking too many questions.- I just tried as you mentioned. However, after running my script for calculating the analysis,
ms1 = cellfun(@(x) x.getMeasure(‘Degree’).memorize(‘M’), analysis.memorize(‘G_DICT’).getItems, ‘UniformOutput’, false)
gives me an error that says, “Unable to resolve the name analysis.memorize.”
I must be doing something wrong.- I have 200+ subjects. Saving individual correlation matrices through GUI would be a tedious process. How can I save them as separate .xls files for each subject through custom script?
March 21, 2023 at 10:28 am #173810Yu-Wei ChangModeratorHi Sai Prasanna,
Thanks for the follow-up feedback.
I would like to provide further information based on example_FUN_WU.m about the following:
(1) Get individual graph metrics/graph measures.
(2) Get individual correlation matrices/adjacency matrices.Please follow the steps below:
Step 1: Copy and paste the following codes at the end of example_FUN_WU.m
%% Get individual correlation matrices adjacency_matrices1 = cellfun(@(x) x.get('A'), a_WU1.memorize('G_DICT').getItems, 'UniformOutput', false); % all individuals from group 1 adjacency_matrices2 = cellfun(@(x) x.get('A'), a_WU2.memorize('G_DICT').getItems, 'UniformOutput', false); % all individuals from group 2 %% Get individual graph measure ms1 = cellfun(@(x) x.getMeasure('Strength').memorize('M'), a_WU1.memorize('G_DICT').getItems, 'UniformOutput', false); % all individuals from group 1 ms2 = cellfun(@(x) x.getMeasure('Strength').memorize('M'), a_WU2.memorize('G_DICT').getItems, 'UniformOutput', false); % all individuals from group 2
Step 2: Run the revised example_FUN_WU.m by clicking on the run button
Step 3: Check the variable adjacency_matrices1 for all individual correlation matrices (weighted-undirected in this example) from group 1, and adjacency_matrices2 for group 2
Step 4: Check the variable ms1 for all individual calculated metrics (strength in this example) from group 1, and ms2 for group 2
Thank you, and let me know if you have any questions.
Best regards,
Yu-Wei- This reply was modified 1 year, 5 months ago by Yu-Wei Chang.
- This reply was modified 1 year, 5 months ago by Yu-Wei Chang.
- This reply was modified 1 year, 5 months ago by Yu-Wei Chang.
- This reply was modified 1 year, 5 months ago by Yu-Wei Chang.
April 20, 2023 at 4:36 am #178264Sai PrasannaParticipantThanks. That works perfectly for me.
On an average configured system and for two groups with around 400 subjects each, completing the above task takes about 65 hours. Is that a usual case?April 20, 2023 at 8:21 am #178289Yu-Wei ChangModeratorHi,
Thanks for the feedback.
May you provide further information:
what is the size of the adjacency matrix in your case? Additionally, I wanted to ask two things: (1) how long does it take to run the modified example file, example_FUN_WU.m, on your computer? and (2) have you installed the parallel computing toolbox?For reference, on my computer with the parallel computing toolbox installed, each step in the modified example file example_FUN_WU.m took the following amount of time:
– Load BrainAtlas: 11 secs
– Load Groups of SubjectFUN: 36 secs
– Measures calculation (Strength, StrengthAv, and Distance): 460 secs
– Comparison (Strength and modularity): 272 secs
– Get individual correlation matrices and graph measures: 1 secTherefore, if the comparison is not of your interest, you may skip the comparison calculation and save some time, which are the following lines:
% comparison c_WU = CompareEnsemble( ... 'P', 10, ... 'A1', a_WU1, ... 'A2', a_WU2, ... 'WAITBAR', true, ... 'VERBOSE', false, ... 'MEMORIZE', true ... ); strength_WU_diff = c_WU.getComparison('Strength').get('DIFF'); strength_WU_p1 = c_WU.getComparison('Strength').get('P1'); strength_WU_p2 = c_WU.getComparison('Strength').get('P2'); strength_WU_cil = c_WU.getComparison('Strength').get('CIL'); strength_WU_ciu = c_WU.getComparison('Strength').get('CIU'); modularity_av_WU_diff = c_WU.getComparison('Modularity').get('DIFF'); modularity_av_WU_p1 = c_WU.getComparison('Modularity').get('P1'); modularity_av_WU_p2 = c_WU.getComparison('Modularity').get('P2'); modularity_av_WU_cil = c_WU.getComparison('Modularity').get('CIL'); modularity_av_WU_ciu = c_WU.getComparison('Modularity').get('CIU');
- This reply was modified 1 year, 4 months ago by Yu-Wei Chang.
April 20, 2023 at 9:28 am #178296Sai PrasannaParticipantI used AAL Atlas, and the size of adjacency matrices for each of the 800 subjects is 116 * 116.
Executing precisely the code you provided took approximately the same time, or maybe a little more. But not hours, for sure.
Yes, I have installed the parallel computing toolbox.
I did not execute the comparison part. I was interested in obtaining the correlation matrices of all the subjects and all the graph metric values for each subject (all those metrics listed on the GUI module for 800 odd subjects). This is what took approximately 65 hours. I just wanted to confirm with you if this is a reasonable time.I appreciate your quick responses. It makes the toolbox extremely user-friendly.
-
AuthorPosts
- You must be logged in to reply to this topic.