Skip to content



This software has been developed as an R package so is needed an R environment. R can be downloaded from It must be installed for 64-bit OS.

To process the meshes our package uses MeshLab. The latest version of MeshLab is only available for Microsoft Window 64-bits, therefore this package only runs in this OS. Latest version of MeshLab software can be downloaded from

After R and MeshLab installation, MeshLab path must be included in the PATH enviroment of the OS. A graphical explanation about how to do that is included in the user’s guide placed at the end of this page.  

To install 3DSomaMS package you must run the next lines in the R console:

setRepositories(addURLs = c(cigrepo = “”)); install.packages(“SomaMS”)

Confirm all the alert messages and wait it installs dependencies.

Running the algorithm

First, you should load the library running the next line in the R console:


After that, to reproduce the experiments in the article you must run the next lines:

convert_somas_to_PLY(read_directory = system.file(“test/VRMLs”, package = “SomaMS”), write_directory = file.path(tempdir(), “PLYs”), parallel = TRUE)

repair_somas(file.path(tempdir(), “PLYs”), file.path(tempdir(), “ambient_occlusion”), file.path(tempdir(), “broken_mesh_ao”), file.path(tempdir(), “poisson_reconstruction_ao”))

segment_somas(file.path(tempdir(), “poisson_reconstruction_ao”), file.path(tempdir(), “sdf”), file.path(tempdir(), “broken_mesh_sdf”), file.path(tempdir(), “poisson_reconstruction_sdf”), file.path(tempdir(), “final_result”))

Results are saved in a temporal directory. To save it in other folder you only have to change file.path(tempdir(), “final_result”) in segment_somas specifying other path. If you do that, you can open the segmented somas with MeshLab. An example of opening a mesh in MeshLab is provided in the user’s guide.


In the paper we applied two measures to validate the somas. Both are integrated in the package. Compute the measures after running the algorithm as it was explained previously.


If you want to compute the interexpert RMSE, run:

path_somas_algorithm <- file.path(tempdir(), “final_result”)

path_somas_experts <- system.file(“test/pre_repaired”, package = “SomaMS”)

experts_paths <- list.dirs(path_somas_experts, recursive = F)

pre_repaired_RMSE <- RMSE_mesh_distance(path_somas_algorithm, experts_paths[1], experts_paths[2], TRUE)

values_barplot<- t(pre_repaired_RMSE)

colors <- c(rainbow(3))

X11(width = 18, height = 10.37)

mp <- barplot2(values_barplot, main = “RMSE before repairing neuroanatomists’ somas”, ylab = “RMSE”, beside = TRUE, col = colors, ylim = c(0, 1.7), cex.names = 1.5, cex.lab = 1.5, cex.axis = 1.5)

legend(“top”, legend = c(“Procedure Vs Neuroanatomist 1”, “Procedure Vs Neuroanatomist 2”, “Neuroanatomist 1 Vs Neuroanatomist 2”), fill = colors, box.col = “transparent”, x.intersp = 0.8, cex = 1.3)

mtext(1, at = mp[2,], text = c(“Neuron 1”, “Neuron 2”, “Neuron 3”, “Neuron 4”, “Neuron 5”, “Neuron 6”, “Neuron 7”, “Neuron 8”, “Neuron 9”), line = 0.5, cex = 1)


Execute the next lines to obtain the MAQ_S:

path_somas_algorithm <- file.path(tempdir(), “final_result”)

path_somas_experts <- system.file(“test/post_repaired”, package = “SomaMS”)

experts_paths <- list.dirs(path_somas_experts, recursive = F)

path_somas_expert_1 <- experts_paths[1]

path_somas_expert_2 <- experts_paths[2]

MAQ_S_result <- MAQ_S(path_somas_algorithm,path_somas_expert_1, path_somas_expert_2)

print(paste(“Mean MAQ_S between algorithm and experts is:”, mean(c(MAQ_S_result[1], MAQ_S_result[2])) * 100, “%”))

print(paste(“Difference between experts MAQ_S and mean MAQ_S of algorithm is:”, abs(MAQ_S_result[3] – mean(c(MAQ_S_result[1], MAQ_S_result[2]))) * 100, “%”))

User’s Guide

Further information is provided in the User’s Guide and in the help page of the package. To open the help page of the package write ?SomaMS in R console.

NOTE: It should be noted that the original generated triangular meshes necessary for the development of the present method, were created to obtain a single coarse solid surface of a particular threshold, which included both the soma and proximal dendrites of labeled neurons. Thus, they are available only for reproducibility purposes of the present algorithm. NOTE: Uncompressed package size is more than 300MB due to the size of the meshes provided as examples.