navis 1.4.0
  • Install
  • Quickstart
  • Tutorials
  • API
  • Changelog
  • Github
  • Ecosystem
  • Site
    • Page
        • navis.form_factor
          • form_factor()

    navis.form_factor¶

    navis.form_factor(x, start=-3, stop=3, num=601, parallel=False, n_cores=1, progress=True)[source]¶

    Calculate form factor for given neuron.

    The form factor F(q) is a Fourier transform of density-density correlation of particles used to classify objects in polymer physics. Based on Choi et al., 2022 (bioRxiv). Code adapted from github.com/kirichoi/FqClustering.

    Parameters:
    • x (TreeNeuron | Meshneuron | Dotprops | NeuronList) –

      Neurons to calculate form factor for. A few notes:
      • data should be in micron - if not, you might want to adjust start/stop/min!

      • since this is all about density, it may make sense to resample neurons

    • start/stop/num (int) – Start/stop/num describe the (log) space over which to calculate the form factor. Effectively determining the resolution. Assuming x is in microns the defaults mean we pay attention to densities between 1 nm (1e-3 microns) and 1 mm (1e+3 microns). The x-value corresponding to the form factor(s) in Fq will be np.logspace(start, stop, num).

    • parallel (bool) – Whether to use multiple cores when x is a NeuronList.

    • n_cores (bool) – Number of cores to use when x is a NeuronList and parallel=True. Even on a single core this function makes heavy use of numpy which itself uses multiple threads - it is therefore not

    • progress (bool) – Whether to show a progress bar.

    Returns:

    Fq – For single neurons: (num,) array For Neuronlists: (len(x), num) array

    Return type:

    np.ndarray

    References

    Polymer physics-based classification of neurons Kiri Choi, Won Kyu Kim, Changbong Hyeon bioRxiv 2022.04.07.487455; doi: https://doi.org/10.1101/2022.04.07.487455

    Examples

    >>> import navis
    >>> nl = navis.example_neurons(3)
    >>> # Resample to 1 node / micron
    >>> rs = navis.resample_skeleton(nl, '1 micron')
    >>> # Calculate form factor
    >>> Fq = navis.form_factor(rs, start=-3, stop=3, num=301,
    ...                        parallel=True, n_cores=3)
    >>> # Plot
    >>> import matplotlib.pyplot as plt
    >>> import numpy as np
    >>> x = np.logspace(-3, 3,  301)
    >>> fig, ax = plt.subplots()
    >>> for i in range(len(Fq)):
    ...     _ = ax.plot(x, Fq[i])
    >>> # Make log-log
    >>> ax.set_xscale('log')
    >>> ax.set_yscale('log')
    >>> plt.show()                                              
    >>> # Cluster
    >>> from scipy.spatial.distance import pdist
    >>> from scipy.cluster.hierarchy import dendrogram, linkage
    >>> dists = pdist(Fq)
    >>> Z = linkage(dists, method='ward')
    >>> dn = dendrogram(Z)                                      
    

    Back to top

    Source

    © Copyright 2018, Philipp Schlegel.
    Created using Sphinx 5.3.0.