data(Simulation_data,package="fMMseg")
n <- nrow(Simulation_data)
#### fMM non spatial ####
res_EMbase <- launcher_fMM(G=3,data=Simulation_data,
                            var_reg="Y_artlinear",family=gaussian(link="identity"),
                            epsilon=5*10^{-3})
#### fMM local regularization ####
 res_EMICM <-  launcher_fMM(G=3,data=Simulation_data,coords=c("i","j"),distband.SR=sqrt(2),
                            var_reg="Y_artlinear",family=gaussian(link="identity"),
                            test.ICM=TRUE,rho_ICM=c(6,0),
                            epsilon=5*10^{-3})
  
#### fMM local and regional regularization ####
system.time(
  res_EMICMlocreg <-  launcher_fMM(G=3,data=Simulation_data,coords=c("i","j"),distband.SR=sqrt(2),distband.LR=10,
                               var_reg="Y_artlinear",family=gaussian(link="identity"),
                               test.ICM=TRUE,rho_ICM=c(6,6),
                               test.ICMregional=TRUE,
                               epsilon=5*10^{-3})
)
 if(try(require(fields))){
  par(mfrow=c(2,2),mar=rep(1.5,4))
 image.plot(x=1:sqrt(n),y=1:sqrt(n),xlab="",ylab="",axes=FALSE,
            z=matrix(Simulation_data[,"Y_artlinear"],sqrt(n),sqrt(n)),
            main="Dataset")
 image.plot(x=1:sqrt(n),y=1:sqrt(n),xlab="",ylab="",axes=FALSE,
            z=matrix(res_EMbase$posterior_proba[,3],sqrt(n),sqrt(n)),
            main=expression(fMM[ns]))
 image.plot(x=1:sqrt(n),y=1:sqrt(n),xlab="",ylab="",axes=FALSE,
            z=matrix(res_EMICM$posterior_proba[,3],sqrt(n),sqrt(n)),
            main=expression(paste(fMM[Loc],"- weak",sep="")))
 image.plot(x=1:sqrt(n),y=1:sqrt(n),xlab="",ylab="",axes=FALSE,
            z=matrix(res_EMICMlocreg$posterior_proba[,3],sqrt(n),sqrt(n)),
            main=expression(fMM[LocReg]))
 }
## for other examples see the demo files : 
??fMMEvaluation # line 65 to 102 (simulated data)   
??fMMLesionSegmentation # line 55-67, 86-100 and 121-135  (real example)Run the code above in your browser using DataLab