Note
Go to the end to download the full example code.
Synthesize neuron with a simple diameter modelΒΆ
This example shows how to synthesize a cell with one of the simple provided diameter models.
14 import json
15 from pathlib import Path
16
17 import neurots
18 from neurots import extract_input
19
20
21 def run(output_dir, data_dir):
22 """Run the example for generating a cell with a simple diameter model."""
23 # Extract distributions with diameters
24 distr = extract_input.distributions(
25 data_dir / "neurons", feature="path_distances", diameter_model="M5"
26 )
27
28 # Load default parameters dictionary
29 with open(data_dir / "bio_params.json", "r", encoding="utf-8") as F:
30 params = json.load(F)
31
32 # Set the diameter method
33 params["diameter_params"]["method"] = "M5"
34
35 # Initialize a neuron
36 N = neurots.NeuronGrower(input_distributions=distr, input_parameters=params)
37
38 # Grow the neuron
39 neuron = N.grow()
40
41 # Export the synthesized cell
42 neuron.write(output_dir / "generated_cell.asc")
43 neuron.write(output_dir / "generated_cell.swc")
44 neuron.write(output_dir / "generated_cell.h5")
45
46
47 if __name__ == "__main__":
48 result_dir = Path("results_neuron_with_diameters")
49 result_dir.mkdir(parents=True, exist_ok=True)
50
51 run(result_dir, Path("data"))