AFM-SPM / TopoStats

An AFM image analysis program to batch process data and obtain statistics from images
https://afm-spm.github.io/TopoStats/
GNU Lesser General Public License v3.0
58 stars 10 forks source link

dnatracing refactor - skeletonisation tests required #412

Open MaxGamill-Sheffield opened 1 year ago

MaxGamill-Sheffield commented 1 year ago

(branch: maxgamill-sheffield/183-dnatracing-refactor) This branch centres around refactoring dnatracing.py upto and including the disrodered_traces function. This means this PR centers around organising the skeletonisation code from tracingfuncs, removing the unused code, adding docstrings and putting it into skeletonize.py.

The regtests remain unaltered and pass so things are working as expected, some dnatracing tests have been made, but no additional tests have been made for Joe's skeletonisation code as I'm unsure what some of them do, there is a lot, and the class is meant to act like Zhangs method (but produces different results). - If anyone can offer assistance here, that would be very helpful!

I also altered some of the utility functions in dnatracing.py to be more understandable. However, I do have an issue with a bit of the code - dilation requires each grain to have their own binary image (to prevent close grains touching), but this also dramatically slows processing times and workflow as the whole image can't be skeletonised/pruned at once (which all the skeletonisation methods can do).

ns-rse commented 1 year ago

I've undertaken refactoring dnatracing.py on ns-rse/183a-dnatracing-refactor and am abstracting out the processing of the whole image so that single grains are the unit of processing for DNA tracing.

Tests are being written and the Skeletonisation (and in due course ridge detection) methods from Scikit Image are being incorporated.

I'll look at the dilation issue as I've used the scipy.ndimage.binary_dilation() function which may already be faster (not had time/inclination to check but am vectorising the linear/circular detection rather than current conversion to lists and looping and will be timing that).

MaxGamill-Sheffield commented 1 year ago

I think @SylviaWhittle has actually written tests for all of joes functions on a branch. Sylvia, was this on my branch or another?

SylviaWhittle commented 1 year ago

@ns-rse @MaxGamill-Sheffield I wrote tests for skeletonization in maxgamill-sheffield/183-dnatracing-refactor, though IIRC there was one function where I needed more information on intended behaviour before writing a test. Also I don't want to claim that these tests are in a publish-ready form.

SylviaWhittle commented 1 year ago

(Pushed just now - realised I hadn't pushed 😨 )

MaxGamill-Sheffield commented 1 year ago

With the binary dilation issue, I've looked into this a little more and understand why it's there:

So what do people think about gaussian filtering and redoing grainfinding again in dnatracing, or maybe applying a gaussian filter to the mask would work to smooth it? Instead of

Also @ns-rse I've taken a brief look at ridge detection and while these filters seem very useful, they don't seem to produce skeletons so might need to undergo skeletonisation afterwards anyway?