the-virtual-brain / tvb-gdist

Geodesic Library (adaptation by TVB Team)
Other
48 stars 30 forks source link

Return index of closest point for compute_gdist() #68

Closed GostInShell closed 3 years ago

GostInShell commented 3 years ago

If I get this right, when more than one source_indices are given, the function compute_gdist() will return the distance of a target to the closest source. Can the function compute_gdist() also return the index of the closest source? Are there any interfaces in the orignal C++ code?

ayan-b commented 3 years ago

Hi @GostInShell, the cython code doesn't provide the index as of now, however, you can use GeodesicAlgorithmExact::best_source method to obtain the index.

https://github.com/the-virtual-brain/tvb-gdist/blob/943c0e019e921b8d8181e076fc009d50b54738b1/geodesic_library/geodesic_algorithm_exact.h#L1175-L1191

If you want to obtain the values from the cython code, first change compute_gdist_impl method here: https://github.com/the-virtual-brain/tvb-gdist/blob/943c0e019e921b8d8181e076fc009d50b54738b1/geodesic_library/geodesic_utils.h#L5 https://github.com/the-virtual-brain/tvb-gdist/blob/943c0e019e921b8d8181e076fc009d50b54738b1/geodesic_library/geodesic_utils.h#L33-L35

Then, update the compute_gdist method here: https://github.com/the-virtual-brain/tvb-gdist/blob/943c0e019e921b8d8181e076fc009d50b54738b1/gdist.pyx#L119

Make sure to update the method signature as well: https://github.com/the-virtual-brain/tvb-gdist/blob/943c0e019e921b8d8181e076fc009d50b54738b1/gdist.pyx#L82-L83

GostInShell commented 3 years ago

Hi, @ayan-b! Thank U so much for the detailed reply! Feeling condifent to implement this by following your instructions!