function calculate_chance_level_dice_coeff(func_file)
% To calculate what would be chance level dice coefficient of similarity
% for 10000 trails

% func_file   = 'R_frontal_hierarchy_F26_P15_8_branches.func.gii';

%=========================
% DEFAULT
%=========================
n_trials    = 10000;

data        = double(nonzeros(readimgfile(func_file)));
temp        = data;

for i = 1:n_trials
    
    if mod(i,25)==0
        fprintf('Running in the range: %d \n',i);
    end
    
    % Randomly shuffle data and calculate dice coefficients
    temp = double(temp(randperm(length(temp))));

    % Calculate dice 
    jac                 = jaccard(temp,data);    
    similarity(i,:)     = 2 * jac ./ (1 + jac);
    average_dice(i,1)   = mean(similarity(i,:));
    
end

save(['dice_chance_' num2str(n_trials)])
