Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

measurements and saving problems #1742

Open
karl-koschutnig opened this issue Oct 4, 2024 · 5 comments
Open

measurements and saving problems #1742

karl-koschutnig opened this issue Oct 4, 2024 · 5 comments
Assignees
Labels
bug Something isn't working and need to be fixed right away enhancement New feature or request

Comments

@karl-koschutnig
Copy link

Dear Braph-Experts,

we are struggling with two issues:

  1. In a WU connectivity analysis of DWI data, we are not able to get results from: clustering, average clustering, small wordless and transitivity. All other measures run smoothly. We don't get an error - it just doesn't stop calculating.

  2. Saving results unfortunately doesn't work at all for us. We were able to save a b2 file with an 1) atlas file and defining two groups with xlsx file, but all attempts to save our steps later on won't work. Again we don't get an error. It just takes for ever.
    Saving the info about the two groups (with the test data) takes about 1 minute (which feels very long).

We tried this on macOS and ubuntu with the latest development version (2.0.0.b2) build 6

@karl-koschutnig karl-koschutnig added bug Something isn't working and need to be fixed right away enhancement New feature or request labels Oct 4, 2024
@c-yuwei c-yuwei self-assigned this Oct 8, 2024
@c-yuwei
Copy link
Collaborator

c-yuwei commented Oct 8, 2024

Hi Karl,

Thanks for getting back to us.
Before I look into that, could you please let me know which version/branch (at what commit) of BRAPH-2 you used?
Is it from develop?
I would recommend, for the time being, try to use this release version. We are very close to have a new release, in a few or so, please stay tuned.

I will get you back soon about (1) clustering, average clustering, small wordless and transitivity and (2) saving

@karl-koschutnig
Copy link
Author

Hi, and thanks for the quick response.
Honestly, I lost track of which versions we used. We definitely used the developer and the recommended stable version (on Windows, Mac, and Ubuntu, with different Matlab versions).
Maybe you could provide a version (+ Matlab + Operating system) that works for you, so that I can use this combination?

@c-yuwei
Copy link
Collaborator

c-yuwei commented Nov 5, 2024

Hi Karl,

Apologies for the delayed response, and thank you for the information.

I’ve created an example script (attached in the comments below) that demonstrates how to (1) calculate clustering, average clustering, small-worldness, and transitivity, (2) plot these metrics on a brain, and (3) save the results as a b2 file or export them to XLSX files.

Could you please run this script directly using the develop branch? There’s no need to run braph2genesis; simply download the code and run it on your computer.

If the script executes successfully, it should also work with your data. I’m happy to answer any further questions or schedule a short meeting to assist with the process.

@c-yuwei
Copy link
Collaborator

c-yuwei commented Nov 5, 2024

Load the example data

clear variables %#ok<*NASGU>

%% Load BrainAtlas
im_ba = ImporterBrainAtlasXLS( ...
    'FILE', [fileparts(which('SubjectCON')) filesep 'Example data CON XLS' filesep 'atlas.xlsx'], ...
    'WAITBAR', true ...
    );

ba = im_ba.get('BA');

%% Load Groups of SubjectCON
im_gr1 = ImporterGroupSubjectCON_XLS( ...
    'DIRECTORY', [fileparts(which('SubjectCON')) filesep 'Example data CON XLS' filesep 'CON_Group_1_XLS'], ...
    'BA', ba, ...
    'WAITBAR', true ...
    );

gr1 = im_gr1.get('GR');

im_gr2 = ImporterGroupSubjectCON_XLS( ...
    'DIRECTORY', [fileparts(which('SubjectCON')) filesep 'Example data CON XLS' filesep 'CON_Group_2_XLS'], ...
    'BA', ba, ...
    'WAITBAR', true ...
    );

gr2 = im_gr2.get('GR');

Calculate the measures

%% Analysis CON WU
a_WU1 = AnalyzeEnsemble_CON_WU( ...
    'GR', gr1 ...
    );

a_WU2 = AnalyzeEnsemble_CON_WU( ...
    'TEMPLATE', a_WU1, ...
    'GR', gr2 ...
    );

% measure calculation
measures_of_interest = {'Clustering', 'ClusteringAv', 'SmallWorldness', 'Transitivity'};

for i = 1:length(measures_of_interest)
    measure = measures_of_interest{i}
    av_values_gr1 = a_WU1.get('MEASUREENSEMBLE', measure).memorize('M');
    av_values_gr2 = a_WU2.get('MEASUREENSEMBLE', measure).memorize('M');
end

Show GUI for the calculated measure on a brain surface

% clustering for example
pf = MeasureEnsembleBrainPF_NU('ME', a_WU1.get('ME_DICT').get('IT', 'Clustering'), 'BA', ba);
gui = GUIFig('PF', pf, 'CLOSEREQ', false);
gui.get('DRAW');
gui.get('SHOW')
pf.get('ST_SURFACE').set('FACEALPHA', 0.05);
image

Show GUI for possibly calculating other measures

gui = GUIElement('PE', a_WU1);
gui.get('DRAW');
gui.get('SHOW')
image

Save those calculated measures as subject-wise xlsx files

% export calculated clustering value for all subjects in group 1 and export
% as xlsx files
num_subject_gr1 = a_WU1.get('G_DICT').get('LENGTH');
measure = 'Clustering';

for i = 1:num_subject_gr1
    m_value_sub = a_WU1.get('G_DICT').get('IT', i).get('M_DICT').get('IT', measure).get('M');
    writematrix(cell2mat(m_value_sub), [measure '_Subject' num2str(i) '.xlsx']);
end
image

Save as b2 and reopen


fprintf('group 1 saving...\n')
tic
Element.save(a_WU1, 'analyzeGroup1.b2')
toc
fprintf('group 1 saved\n')

fprintf('group 2 saving...\n')
tic
Element.save(a_WU2, 'analyzeGroup2.b2')
toc
fprintf('group 2 saved\n')

% reopen from the saved b2 file
a_WU1_saved = Element.load('analyzeGroup1');
gui = GUIElement('PE', pip_saved);
gui.get('DRAW');
gui.get('SHOW')

@c-yuwei
Copy link
Collaborator

c-yuwei commented Nov 5, 2024

Note that, since smallworldness involves randomizing the connectivity matrix, it is indeed taking longer time to calculate it. Would you please let me know how many nodes for your data? And how many entries (subjects/datapoints) are there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working and need to be fixed right away enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants