BlueBrain / NeuroTS

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

Trouble running extract_synthesis_inputs.py #63

Closed riddick-the-furyan closed 1 year ago

riddick-the-furyan commented 1 year ago

I used the code on the epfl website for NeuroTS to extract inputs. I copied the code as is and got this error:

UnboundLocalError                         Traceback (most recent call last)
Cell In[2], line 52
     49 result_dir = Path("results_extract_synthesis_inputs")
     50 result_dir.mkdir(parents=True, exist_ok=True)
---> 52 run(result_dir, Path("data"))

Cell In[2], line 11, in run(output_dir, data_dir)
      9 """Run the example for extracting inputs for synthesis."""
     10 # Generate distribution from directory of neurons
---> 11 distr = extract_input.distributions(
     12     data_dir / "neurons", feature="path_distances", diameter_model="default"
     13 )
     15 # Save distributions in a json file
     16 with open(output_dir / "test_distr.json", "w", encoding="utf-8") as f:

File ~\anaconda3\lib\site-packages\neurots\extract_input\input_distributions.py:81, in distributions(filepath, neurite_types, threshold_sec, diameter_input_morph, feature, diameter_model)
     78         neurite_type_warning(neurite_type)
     79         neurite_types[i] = neurite_type + "_dendrite"
---> 81 pop_tmd = tmd.io.load_population(filepath, use_morphio=True)
     82 pop_nm = load_morphologies(filepath)
     84 input_distributions = {"soma": {}, "basal_dendrite": {}, "apical_dendrite": {}, "axon": {}}

File ~\anaconda3\lib\site-packages\tmd\io\io.py:168, in load_population(neurons, user_tree_types, name, use_morphio)
    164     name = name if name is not None else os.path.basename(neurons)
    166 pop = Population.Population(name=name)
--> 168 for filename in files:
    169     try:
    170         if not use_morphio:

UnboundLocalError: local variable 'files' referenced before assignment

I changed the directory in every possible way I know how to it still hasn't been working. Any help is greatly appreciated.

adrien-berchet commented 1 year ago

Hi @riddick-the-furyan

This error actually comes from TMD, not directly from NeuroTS. Anyway, I guess you use the last version TMD==2.2.0? If it is the case, there is currently no check on the given inputs and this can lead to this UnboundLocalError (this was fixed in https://github.com/BlueBrain/TMD/commit/9bab7bd95be8197a4839ad03c2e6ec0ad16d2fbe but it's not released yet).

Anyway, this error can be caused by several things but in your case it seams the directory data_dir / "neurons" does not exist. Is this possible?

riddick-the-furyan commented 1 year ago

Thanks I managed to fix it.

adrien-berchet commented 1 year ago

Ok, great! In the mean time I released a new version of TMD, which should provide more information about such error.