Skip to content

get_sample_pts_euclidean: interpolation weights appear swapped #22

@tatsuookubo

Description

@tatsuookubo

Summary

When get_sample_pts_euclidean samples points along an SWC edge, the interpolation appears to place each point at the mirrored location on that edge. In a simple 3-node chain, this changes the actual distances from the root returned by the sampler, not just their order.

I’m including:


Minimal reproducible example

  • Save the following as demo.swc. The example neuron has 3 nodes on the x-axis at x = [0, 3, 10].
# id type x  y  z  radius parent
1  1    0  0  0  1     -1
2  3    3  0  0  1      1
3  3   10  0  0  1      2
  • Run:
python sampling_with_demo_swc.py
  • Observe output:
expected: [ 0.  2.  4.  6.  8. 10.]
got     : [0. 1. 3. 5. 7. 9.]

Potential fix

In get_sample_pts_euclidean inside src/cajal/sample_swc.py, interpolation currently uses:

(root_triple * x) + (child_triple * (1 - x))

If sampled points are intended to be measured from the parent/root along the edge, the weights seem swapped. A possible change would be:

(root_triple * (1 - x)) + (child_triple * x)
  • sampling_potential_fix.py demonstrates the output before and after swapping these weights, again using the 3-node example above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions