You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: icassoIdx2Centrotype.m
    path of file: ./repos/fieldtrip/external/icasso
    
    the code of the file until where you have to start completion: function index2centrotype=icassoIdx2Centrotype(sR,mode,P)
%function index2centrotype=icassoIdx2Centrotype(sR,mode,P)
%
%PURPOSE
%
%To compute the index to centrotype of
%estimate-clusters. Centrotype is an estimate close to the centroid
%of the estimate-cluster. (see help in function centrotype for an

    
function index2centrotype=icassoIdx2Centrotype(sR,mode,P)
%function index2centrotype=icassoIdx2Centrotype(sR,mode,P)
%
%PURPOSE
%
%To compute the index to centrotype of
%estimate-clusters. Centrotype is an estimate close to the centroid
%of the estimate-cluster. (see help in function centrotype for an
%exact definition). This estimate represents better the "true"
%estimate than an arbitrary estimate from a single run.         
%
%EXAMPLE OF BASIC USAGE
%
%For this example variable sR must contain complete results of 
%Icasso randomization & clustering (see functions icassoEst and
%icassoExp):
%
%   U=sR.cluster.partition(10,:); 
%   i=icassoIdx2Centrotype(sR,'partition',U); 
%   signalplot(icassoGet(sR,i));
%
%plots 10 estimated sources (ICs) each corresponding to a
%centrotype of the 10 estimate-clusters at level 10 in the dend