Coder Social home page Coder Social logo

Comments (10)

schlegelp avatar schlegelp commented on June 11, 2024

Afraid this is not how the cn_color parameter works. From help(navis.plot3d):

cn_colors :       str | tuple | dict | "neuron"
                  Overrides the default colors:

                  - single color as str (e.g. ``'red'``) or rgb tuple (e.g.
                    ``(1, 0, 0)``)
                  - dict mapping the connectors tables ``type`` column to a
                    color (e.g. `{0: (1, 0, 0)}`)
                  - with "neuron", connectors will receive the same color as
                    their neuron

Bottom line: cn_dict lets you choose whether you want e.g. presynapses in green instead of red. I will update the help to make this clearer.

For what you want to do there are two options:

  1. Subset the connectors table in nl to only those synapses from/to the APL. This is a bit tricky with neuprint IIRC.
  2. Fetch the synapses between APL and your neuron separately and add them as a scatter plot

An illustrative example for option 2:

Here I'm visuazing inputs from APL (425790257) onto LHMB1 (5813020988)

>>> # Fetch LHMB1
>>> nl = neu.fetch_skeletons(5813020988, with_synapses=True)
>>> # Fetch connections from APL onto LHMB1
>>> cn = neu.fetch_synapse_connections(source_criteria=neu.NeuronCriteria(bodyId=425790257), target_criteria=neu.NeuronCriteria(bodyId=5813020988))
>>> # Subset to those in the CA 
>>> cn = cn[cn.roi_post == 'CA(R)']
>>> # Get the xyz locations 
>>> locs = cn[['x_post', 'y_post', 'z_post']].values
>>> # Plot 
>>> navis.plot3d([nl, locs, ca], scatter_kws={'color': 'green', 'size': 5}, color='k')

Screenshot 2021-04-22 at 14 18 54

from navis.

Gigi-prisco avatar Gigi-prisco commented on June 11, 2024

Understood, and I have managed to get the plot I was looking for. Just one further issue, the color='k' piece makes both my neuron and the calyx roi black. How can I change the color of the skeleton while keeping the roi in its typical light grey.

Thank you very much for your help

from navis.

schlegelp avatar schlegelp commented on June 11, 2024

Hmm... It shouldn't do that. What version of navis are you using?

from navis.

schlegelp avatar schlegelp commented on June 11, 2024
>>> import navis
>>> print(navis.__version__)

from navis.

Gigi-prisco avatar Gigi-prisco commented on June 11, 2024

Thanks for literally reading my mind while I was trying to look for that. it says 0.5.2

from navis.

schlegelp avatar schlegelp commented on June 11, 2024

Try updating: the most recent version is 0.5.3.

pip3 install navis -U

Also what browser are you using? I had some issues with plotly plots in Safari in the past.

from navis.

schlegelp avatar schlegelp commented on June 11, 2024

Also note that you will have to restart the Python kernel in your notebook and re-run your code for the update to take effect.

from navis.

Gigi-prisco avatar Gigi-prisco commented on June 11, 2024

It worked! Once again, thank you!
One last question. Would all this work on a mesh instead of a skeleton? If yes, can I just substitute neu.fetch_skeletons with neu.fetch_mesh_neuron to do that?

from navis.

schlegelp avatar schlegelp commented on June 11, 2024

Yep

from navis.

schlegelp avatar schlegelp commented on June 11, 2024

@Gigi-prisco can this issue be closed?

from navis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.