Hi Michel

I have this piece of matlab code (pasted below) that does this. It won’t divide into regions of “exactly” the same size, but almost.

Example use:

addpath /usr/local/fsl/etc/matlab
mask=read_avw('/usr/local/fsl/data/standard/MNI152_T1_2mm_brain’);
vmask=volvoronoi(mask,30);
figure,hist(vmask(~~mask))  % should be  approx uniform
save_avw(vmask,'~/Desktop/vmask','i',[2 2 2]);
!fslview /usr/local/fsl/data/standard/MNI152_T1_2mm_brain ~/Desktop/vmask

Cheers
Saad

function vmask = volvoronoi(mask,nclust)
% vmask = surfvoronoi(mask,nclust)
%
% subdivide mask into nclust
% clusters in a voronoi-like fashion
% starting with random equally spread seeds
%
rng('shuffle');

[x,y,z] = ind2sub(size(mask),find(mask));
v = [x y z];
N = size(v,1);

% random first point

s    = [randi(N);zeros(nclust-1,1)];
list = cell(nclust,1);
list{1} = s(1);
sv2=sum(v.^2,2);
d=zeros(N,nclust);D=d;
d(:,1) = sv2 + sv2(s(1)) - 2*v*v(s(1),:)';
D(:,1) = d(:,1);
% spread ‘nclust-1' points
for i=2:nclust
d(:,i-1) = sv2 + sv2(s(i-1)) - 2 * v*v(s(i-1),:)';
[~,j] = max(min(d(:,1:i-1),[],2));
s(i)  = j;
list{i} = j;
D(:,i) = sv2 + sv2(j) - 2 * v*v(j,:)';
end
% winner take all on distances
[~,idx]    = min(D,[],2);
vmask = 0*mask;
vmask(~~mask)=idx;

On 16 Aug 2017, at 09:19, Michel Thiebaut <[log in to unmask]> wrote:

Dear experts,

I am looking for a solution to divide a mask into 10 regions of interest of the same size.
Does anyone have a solution for this?

thank you much for your help,
kind regards

michel

Michel Thiebaut de Schotten
Associate Professor, PhD, HDR, CNRS
Sorbonne Universities, UPMC Univ Paris 06
Brain Connectivity and Behaviour Group
Frontlab, Institut du cerveau et la moelle épinière
Hôpital de la Salpêtrière - ICM
47 Bvd de l'Hôpital CS21414
75646 PARIS CEDEX 13

Skype: michel_thiebaut_de_schotten