Synthesize neuron with a simple diameter modelΒΆ

This example shows how to synthesize a cell with one of the simple provided diameter models.

25 import json
26 from pathlib import Path
27
28 import neurots
29 from neurots import extract_input
30
31
32 def run(output_dir, data_dir):
33     """Run the example for generating a cell with a simple diameter model."""
34     # Extract distributions with diameters
35     distr = extract_input.distributions(
36         data_dir / "neurons", feature="path_distances", diameter_model="M5"
37     )
38
39     # Load default parameters dictionary
40     with open(data_dir / "bio_params.json", "r", encoding="utf-8") as F:
41         params = json.load(F)
42
43     # Set the diameter method
44     params["diameter_params"]["method"] = "M5"
45
46     # Initialize a neuron
47     N = neurots.NeuronGrower(input_distributions=distr, input_parameters=params)
48
49     # Grow the neuron
50     neuron = N.grow()
51
52     # Export the synthesized cell
53     neuron.write(output_dir / "generated_cell.asc")
54     neuron.write(output_dir / "generated_cell.swc")
55     neuron.write(output_dir / "generated_cell.h5")
56
57
58 if __name__ == "__main__":
59     result_dir = Path("results_neuron_with_diameters")
60     result_dir.mkdir(parents=True, exist_ok=True)
61
62     run(result_dir, Path("data"))

Gallery generated by Sphinx-Gallery