connectome-neuprint / neuprint-python

Python client utilties for interacting with the neuPrint connectome analysis service
BSD 3-Clause "New" or "Revised" License
31 stars 15 forks source link

Set a threshold for far away fragments #12

Closed SridharJagannathan closed 4 years ago

SridharJagannathan commented 4 years ago

When skeletons are fetched in neuprint-python with the heal option enabled, sometimes it heals fragments that are far apart. For e.g.: Consider the body id 1670597533 when it is fetched with healing enabled it looks like below Screenshot 2020-05-05 at 13 45 27

On further inspection of the code at https://github.com/connectome-neuprint/neuprint-python/blob/b4dfd061bb12bf8d4834b9db05727b44cbd29c59/neuprint/utils.py#L498 it should be possible to set a threshold say 1000 for the d['distance'] beyond which fragments should not be connected, otherwise spurious fragments would be connected like this. The distance values for all edges added are as below:

91.91300234460846
94.65727652959386
98.63062404750362
101.19288512538814
103.69185117452577
108.51727973000429
112.0
114.2628548566856
115.37764081484765
116.48175822848829
122.89833196589773
125.98412598418898
125.98412598418898
125.98412598418898
131.93938001976514
136.03547331486732
140.39943019827396
176.72577627499618
184.52100151473275
219.96363335788033
227.9649095804001
229.64320151051717
232.6531108753977
1886.8471056235585
13000.5193742404
stuarteberg commented 4 years ago

Nice suggestion. (Sorry for the slow response.)

This is now implemented in neuprint-python-0.4.11. To use it, specify the threshold as an argument to heal_skeleton() or by providing a float for the heal argument in fetch_skeleton(). (The default behavior has not changed.)

Docs: