seung-lab / dijkstra3d

Dijkstra's Shortest Path for 6, 18, and 26-Connected 3D (Volumetric) Image Volumes
GNU General Public License v3.0
71 stars 13 forks source link

like dijkstra3d.distance_field gets distance for all fields, somehow get path for all fields #17

Closed Fabioni closed 3 years ago

Fabioni commented 3 years ago

I want to overlay all paths to all fields to find the most important pathway.

william-silversmith commented 3 years ago

Hi Fabioni,

I think you might be looking for:

parents = dijkstra3d.parental_field(field, source=(0,0,0), connectivity=6) # default is 26 connected
path = dijkstra3d.path_from_parents(parents, target=(511, 511, 511))
print(path.shape)

You can rapidly get the path for every point.

Fabioni commented 3 years ago

Okay, thank you very much. This was/is a function that I do not understand at all. We does it do? I could not find a explaining documentation about ist.

Am 17.01.2021 um 20:55 schrieb William Silversmith notifications@github.com:

Hi Fabioni,

I think you might be looking for:

parents = dijkstra3d.parental_field(field, source=(0,0,0), connectivity=6) # default is 26 connected path = dijkstra3d.path_from_parents(parents, target=(511, 511, 511)) print(path.shape) You can rapidly get the path for every point.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/seung-lab/dijkstra3d/issues/17#issuecomment-761869898, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK2C35D54RHVYHYVTCZ2XF3S2M6CXANCNFSM4WFZLUBQ.

william-silversmith commented 3 years ago

Hi Fabian,

The parental field computes the information to extract all shortest paths and then the query function extracts the path from a given target voxel.

You can get the same information by running dijkstra over and over but this is faster.

I can update the README to be clearer.

Is that what you needed?

Will

On Sun, Jan 17, 2021, 2:57 PM Fabian Scherer notifications@github.com wrote:

Okay, thank you very much. This was/is a function that I do not understand at all. We does it do? I could not find a explaining documentation about ist.

Am 17.01.2021 um 20:55 schrieb William Silversmith < notifications@github.com>:

Hi Fabioni,

I think you might be looking for:

parents = dijkstra3d.parental_field(field, source=(0,0,0), connectivity=6) # default is 26 connected path = dijkstra3d.path_from_parents(parents, target=(511, 511, 511)) print(path.shape) You can rapidly get the path for every point.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/seung-lab/dijkstra3d/issues/17#issuecomment-761869898>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AK2C35D54RHVYHYVTCZ2XF3S2M6CXANCNFSM4WFZLUBQ .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/seung-lab/dijkstra3d/issues/17#issuecomment-761870217, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATGQSJER5DL7P7GKWSQR7LS2M6KZANCNFSM4WFZLUBQ .

Fabioni commented 3 years ago

Thanks a lot. Yeah the Readme could be a lot clearer for that.

Is it possible to specify connectivity for dijkstra3d.distance_field()?

william-silversmith commented 3 years ago

Okay cool, I'll update the documentation later when I have a chance. The function currently doesn't support connectivity (https://github.com/seung-lab/dijkstra3d/blob/master/dijkstra3d.hpp#L726-L730). I have some updates I'm planning on making to this library, but that function isn't on my critical path so it might only happen if I have time. A PR is welcome!

william-silversmith commented 3 years ago

Would you consider this issue resolved as well? Thanks Fabian!

Fabioni commented 3 years ago

No actually not since the connectivity is not possible.

william-silversmith commented 3 years ago

I'm a bit confused, I believe both parental_field and distance_field have a connectivity argument.

Fabioni commented 3 years ago

Oh my false, sorry. If connectivity works for parental_field and distance_field than I have what I wanted. Btw the last time I tried so with the last version, parental_field did not work with a 2d array, only with 3d. That's for sure not a problem since I can just adjust add the dimension but it's inconsistent with the other methods that work with 2d arrays and 2d points.

william-silversmith commented 3 years ago

This works for me:

import numpy as np
import dijkstra3d

field = np.ones((512,512), dtype=np.uint8, order='F')
pt = (0,0)
field = dijkstra3d.parental_field(field, source=pt, connectivity=6)

Does that match what you tried before?

william-silversmith commented 3 years ago

Closing due to inactivity. Let me know if you still need help!