BlueBrain / NeuroTS

Topological Neuron Synthesis
https://neurots.readthedocs.io/en/stable
Apache License 2.0
36 stars 5 forks source link

How to resolve SomaErrror #69

Closed riddick-the-furyan closed 1 year ago

riddick-the-furyan commented 1 year ago

A few weeks ago when trying to extract distributions from the morphologies I had I ran into a SomaError because the soma was already defined. Intially I thought the problem was because of tmd as the call was traced back to it but now I'm not sure. I think the traceback is because of an error in line 81 input_distributions.py as that is where the traceback begins.

Any help would be greatly appreciated.

Source Code:

import json
from pathlib import Path
import neurots
from neurots import extract_input

def run(distr_dir, params_dir, neuron_dir, data_dir):
    for i in range(0,50,1):
        """Run the example for extracting inputs for synthesis."""
        # Generate distribution from directory of neurons

        distr_name = "test_distr_{}.json".format(i)
        params_name = "test_params_{}.json".format(i)
        neuron_name = "test_neuron_{}.swc".format(i)

        distr = extract_input.distributions(
            data_dir / "neurons", 
            neurite_types = ["basal_dendrite"],
            feature="path_distances", 
            diameter_model="default"
        )

if __name__ == "__main__":
    data_dir = Path("C:\\Users\\user\\Documents\\Experiment_01\\Data\\Human\\Neocortex_interneurons")
    params_dir = Path("C:\\Users\\user\\Documents\\Experiment_01\\Parameters\\Neocortex_interneuron")
    distr_dir = Path("C:\\Users\\user\\Documents\\Experiment_01\\Distributions\\Neocortex_interneuron")
    neuron_dir = Path("C:\\Users\\user\\Documents\\Experiment_01\\Synthesized\\Neurons\\Neocortex_interneuron")

    #result_dir.mkdir(parents=True, exist_ok=True)

    run(distr_dir, params_dir, neuron_dir, data_dir)
    print("DONE!!!")

Morphologies: morphologies.zip

adrien-berchet commented 1 year ago

Hi @riddick-the-furyan I checked the morphologies that are failing, and it appears that these files contain several somata, which makes no sense. Do they come from NeuroMorpho? These files are asc files, so if you look inside them there are several blocks that start with "Cell Body", each of them defining a contour of the soma. If you keep only one of these blocks it should work properly. The issue is that it's hard to know which block should be kept, but I think it does not really matter in your case (since you are mainly interested in the neurite data, right?).

riddick-the-furyan commented 1 year ago

H, thanks I appreciate it a lot and yes, you're right.

adrien-berchet commented 1 year ago

My pleasure!