BlueBrain / diameter-synthesis

Synthesize diameters of neuronal morphologies
Apache License 2.0
3 stars 2 forks source link

Recieving ValueError when running extract_synthesis_inputs.py #35

Closed riddick-the-furyan closed 1 year ago

riddick-the-furyan commented 1 year ago

When running the .py file I get "ValueError: zero-size array to reduction operation maximum which has no identity." The error seems to be in line 61 of simple_diametrizer.py indicated by lengths /= lengths.max(). The source code of extract_synthesis_inputs.py is syntactically different to what I am used to in python so I am not throwing out the probability that the error is with a change I made. Though I assume the slash is the error but I made a change to the source code of extract_synthesis_inputs.py. Which was only adding the directory to the reconstructions of neurons on my pc.

Here is the source code for extract_synthesis_inputs.py:

import json
from pathlib import Path

import neurots
from neurots import extract_input

def run(output_dir, data_dir):
    """Run the example for extracting inputs for synthesis."""
    # Generate distribution from directory of neurons
    distr = extract_input.distributions(
        data_dir / "neurons", feature="path_distances", diameter_model="default"
    )

if __name__ == "__main__":
    result_dir = Path("results_extract_synthesis_inputs")
    result_dir.mkdir(parents=True, exist_ok=True)

    run(result_dir, Path("C:\\Users\\user\\Documents\\Experiment_01\\Data\\Human\\Neocortex_interneurons"))
    print("DONE!")

Package versions neurots==3.3.1, tmd==2.3.0, diameter-synthesis==0.5.3 and morphio==3.3.4. None of these packages have been edited in anyway.

adrien-berchet commented 1 year ago

Hello again @riddick-the-furyan I think that you have to provide a value to the neurite_types parameter. The default value for this parameter is ["basal_dendrite", "apical_dendrite", "axon"], but if none of your morphologies has axon for example, then you should provide neurite_types=["basal_dendrite", "apical_dendrite"] to the neurots.extract_input.distributions function. Nevertheless I think we should support this case, WDYT @arnaudon ?

arnaudon commented 1 year ago

Yes, I got this error once as well but I didn't make it crash more gracefully. I can send a PR for this later today if you want.

riddick-the-furyan commented 1 year ago

@adrien-berchet when you say morphologies are you still referring to the variable neurite_types or the morphologies parameter when talking about if it has axon??

adrien-berchet commented 1 year ago

"morphologies" refers to the data in the files contained in the data_dir / "neurons" (or neurons if you prefer)

riddick-the-furyan commented 1 year ago

I see. I misread what you meant.

riddick-the-furyan commented 1 year ago

By any chance do you have an idea of the timeframe in which the next micro version of NeuroTS can support morphologies without axons? Sorry in advance if this sounds forward.

arnaudon commented 1 year ago

Hello, it is already, in the function distribution, there is a neurite_types argument which you didn't use in your script above. Just give it the neurite types you want to synthesize. I suppose for you it would be distr = extract_input.distributions(..., neurite_types=["basal_dendrite", "apical_dendrite"]), or without apical_dendrites if you don't have any.

riddick-the-furyan commented 1 year ago

Hi, thank you so much! The extract_synthesis_inputs.py ran with no errors and the parameters, distributions and morphologies were created so I am really grateful for your help. Though after the program terminated, I got this message "Selected step size 1.000000 is too big for bars of size 0.681029" in red in jupyter notebook. Should I be worried about it?

arnaudon commented 1 year ago

Great! For this warning, it should not be an issue, but maybe @lidakanari could tell you more on this one. It is related to a bar being smaller than the distance between two points. I see this sometimes, and the created morphologies are ok.

adrien-berchet commented 1 year ago

Hi, thank you so much! The extract_synthesis_inputs.py ran with no errors and the parameters, distributions and morphologies were created so I am really grateful for your help. Though after the program terminated, I got this message "Selected step size 1.000000 is too big for bars of size 0.681029" in red in jupyter notebook. Should I be worried about it?

Glad to know it worked! I close this issue as it seems solved but don't hesitate to reopen it if you need more help on this topic (or open a new one if it's about about something else).