function run_hierarchical_org(hemi)

back = pwd;
%======================
% DEFAULT
%======================
num_branches = 2:9;

% move to results directory
cd(['results/hierarchical_organization/' hemi '_hemisphere/']);

% get seed and target exemplars from parcellation results
seed_exemplars      = get_exemplar_ind(['../../parcellation/' hemi '_frontal/ap_cluster_all_var.mat']);
target_exemplars    = get_exemplar_ind(['../../parcellation/' hemi '_parietal/ap_cluster_all_var.mat']);

% select appropriate connectivity values from the main dconn.nii file
make_hierarchy_matrix(['../../../data/dconn/' hemi '_hemisphere_' hemi '_hemisphere.dconn.nii'], seed_exemplars, target_exemplars,[hemi '_frontal_' hemi '_parietal.mat']);

clc;

% load for a visualization
load([hemi '_frontal_' hemi '_parietal.mat']);
clustergram(data_hierarchy.correlation,'Colormap',redbluecmap,'RowPDist','cityblock','ColumnPDist','cityblock','Linkage','ward');

if upper(hemi)=='R'
    
    mkdir individual_branches_R_frontal
    parcellation_mask = ['../../parcellation/' hemi '_frontal/ap_solution_26.func.gii'];
    for i_branch = 1:length(num_branches)
        make_individual_hierarchical_branches(data_hierarchy.correlation, num_branches(i_branch), parcellation_mask, hemi);
    end
    movefile R_frontal* individual_branches_R_frontal
    
    % this also moves the exemplar data matrix, so, put it back
    cd individual_branches_R_frontal
    movefile R_frontal_R_parietal.mat ../
    cd ../
        
    mkdir individual_branches_R_parietal
    parcellation_mask = ['../../parcellation/' hemi '_parietal/ap_solution_15.func.gii'];
    for i_branch = 1:length(num_branches)
        make_individual_hierarchical_branches(data_hierarchy.correlation, num_branches(i_branch), parcellation_mask, hemi);
    end    
    movefile R_parietal* individual_branches_R_parietal
    
elseif upper(hemi)=='L'
    
    mkdir individual_branches_L_frontal
    parcellation_mask = ['../../parcellation/' hemi '_frontal/ap_solution_23.func.gii'];
    for i_branch = 1:length(num_branches)
        make_individual_hierarchical_branches(data_hierarchy.correlation, num_branches(i_branch), parcellation_mask, hemi);
    end
    movefile L_frontal* individual_branches_L_frontal
    % this also moves the exemplar data matrix, so, put it back
    cd individual_branches_L_frontal
    movefile L_frontal_L_parietal.mat ../
    cd ../
    
    mkdir individual_branches_L_parietal
    parcellation_mask = ['../../parcellation/' hemi '_parietal/ap_solution_14.func.gii'];
    for i_branch = 1:length(num_branches)
        make_individual_hierarchical_branches(data_hierarchy.correlation, num_branches(i_branch), parcellation_mask, hemi);
    end
    movefile L_parietal* individual_branches_L_parietal
    
end

close all; cd(back);

end