e-koch / FilFinder

Detection of filamentary structure in molecular clouds
http://fil-finder.readthedocs.io/en/latest
MIT License
41 stars 21 forks source link

Some attributes are not described in the docs #49

Open e-koch opened 5 years ago

e-koch commented 5 years ago

Some properties in FilFinder2D are not described in the docs (i.e. FilFinder2D.skeleton_longpath).

pippo1990 commented 8 months ago

Hi I am trying to make use of your nice tool (would say more than just a tool) , I am using basic exaples just to find FilFinder2D.skeleton_longpath, is there any way to get the lenght of it in pixels ? I tried branch_lenghts but is just sizes of the various segment found and cannot use them because I dont know which were selected for theh skelethon_longpath , unless I need tu sum them all because these are just the ones selected to create the seleton ? I can get the number of pixels with np.where(skeleton.longpath == 1) or np.sum(mask) but that won't be the Euclidean distance for pixel neighbor on a diagonal (1,4 vs 1)

e-koch commented 8 months ago

Hi @pippo1990 -- you're looking for this function to get the longest path lengths: https://fil-finder.readthedocs.io/en/latest/api/fil_finder.FilFinder2D.html#fil_finder.FilFinder2D.lengths

pippo1990 commented 8 months ago

dodgy I can run print('\nfil.branch_lenghts() : ' , fil.branch_lengths()) but print('\nfil.lenghts() : ' , fil.lenghts()) gives AttributeError: 'FilFinder2D' object has no attribute 'lenghts' I am on fil_finder.version : 1.7.2

e-koch commented 8 months ago

Just checking: was the lenghts a typo in the comment above?

pippo1990 commented 8 months ago

yep sorry, my right hand is faster than the left one sorry, It's working now

pippo1990 commented 8 months ago

for one of my test fil.lengths is in between the number of pixel and the geometric distance calculated on the skeleton_longpath by hand (pixel_to_pixel) i.e. : my measures length 1315.8813844421359 vs number of pixels 1128 while fil.lengths is fil.lenghts() : [1298.91082169] pix any reason about that , is it geometric lenght ? I am not able to interpret the filament.py part describing lenght: line 331 filament.py

e-koch commented 8 months ago

There can be a moderate discrepancy between the geometric length and the one filfinder finds from the longest path. FilFinder generalizes the identification of the intersections between branches along the longest path to allow them to be made up of several pixels. The distance it uses if then a median of the intersection pixels, added to the geometric distances along each branch.

There's also an option when running FilFinder2D.find_widths where 2 * width is added to the filament length to account for the shortening from the skeletonization process: https://fil-finder.readthedocs.io/en/latest/api/fil_finder.FilFinder2D.html#fil_finder.FilFinder2D.find_widths. If you are running that step, you can disable this with add_width_to_length=False

pippo1990 commented 8 months ago

thanks for your nice and complete explanation