Skip to content

Instantly share code, notes, and snippets.

@tferr
Last active October 19, 2019 18:33
Show Gist options
  • Save tferr/60c4584c08c5f61d7f3954a363113ad0 to your computer and use it in GitHub Desktop.
Save tferr/60c4584c08c5f61d7f3954a363113ad0 to your computer and use it in GitHub Desktop.
Extract soma positions from ML database
import sc.fiji.snt.io.MouseLightLoader
import sc.fiji.snt.annotation.AllenCompartment
import sc.fiji.snt.annotation.AllenUtils
import java.text.DecimalFormat
// The name of the compartment to extract somas from
compartmentOfInterest = AllenUtils.getCompartment("Cerebral cortex")
/*
If MouseLightQuerier is available one could simply do:
cellIds = MouseLightQuerier.getIDs(compartmentOfInterest)
for (neuron in cellIds) {
(...)
}
*/
println("ID,Soma X,Soma Y,Soma Z,Label ID")
for (neuron in 1..MouseLightLoader.getNeuronCount()) {
// Define a valid cell ID
id = "AA" + new DecimalFormat("0000").format(neuron)
loader = loader = new MouseLightLoader(id)
if (!loader.idExists()) continue
// Currently all somas are represented by a single point
soma = loader.getNodes("soma")[0]
somaCompartment = (AllenCompartment) soma.getAnnotation()
if (compartmentOfInterest.contains(somaCompartment)) {
somaDetails = [id, soma.getX(), soma.getY(), soma.getZ()]
if (somaCompartment) somaDetails << somaCompartment.id()
println(somaDetails.join(","))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment