Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the Better Tracing Suite into Main #932

Merged
merged 792 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
792 commits
Select commit Hold shift + click to select a range
a7d7ade
add topoly to dependancy list
MaxGamill-Sheffield Aug 31, 2024
18f243b
added total_branch_length into grainstats
MaxGamill-Sheffield Sep 2, 2024
435f928
tidy up new pruning method
MaxGamill-Sheffield Sep 3, 2024
427619e
pruning change applied throughput codebase
MaxGamill-Sheffield Sep 3, 2024
560d0b1
dis trace pruning re-structured
MaxGamill-Sheffield Sep 3, 2024
4b7d258
ordered traces adds topology & outputs molstats & splining takes mols…
MaxGamill-Sheffield Sep 3, 2024
83258bf
broad-exception-caught
MaxGamill-Sheffield Sep 3, 2024
ce90215
Added segment index image
MaxGamill-Sheffield Sep 4, 2024
351700a
Add min, median, mid, connections values to skan DF
MaxGamill-Sheffield Sep 5, 2024
25bd01e
fix argument missmatch
MaxGamill-Sheffield Sep 5, 2024
2993937
Remove np.saves from ordered tracing
MaxGamill-Sheffield Sep 6, 2024
b96de5a
Merge pull request #891 from AFM-SPM/maxgamill-sheffield/RIs
MaxGamill-Sheffield Sep 6, 2024
0a51d25
Merge pull request #882 from AFM-SPM/ns-rse/818-fix-broken-test_plotting
ns-rse Sep 9, 2024
51c5ce2
Make grains outputs multi-coloured so dark grains aren't hidden
MaxGamill-Sheffield Sep 9, 2024
4bdba9e
moves nodestats TS object after ordered to pickup changes
MaxGamill-Sheffield Sep 11, 2024
5f279e1
got writhe calc working - i think
MaxGamill-Sheffield Sep 11, 2024
f836e67
move get_two_combinations into tracing_funcs
MaxGamill-Sheffield Sep 11, 2024
6f9464a
self'd img_to_node dict & tidy pre-commit errors
MaxGamill-Sheffield Sep 11, 2024
a98c65e
Merge branch 'maxgamill-sheffield/800-better-tracing' into maxgamill-…
MaxGamill-Sheffield Sep 11, 2024
7259eef
chore: fix linting errors
ns-rse Sep 12, 2024
45cc212
tests(processing): Improves logic and tests for check_run_steps()
ns-rse Sep 13, 2024
a72f9a7
swapped dashes to underscores in my additions to skan df
MaxGamill-Sheffield Sep 16, 2024
a6d24b4
comments out tidy branches and finishes a docstring
MaxGamill-Sheffield Sep 16, 2024
a34e513
removes double dilation away from nodes so unpaired branches finish a…
MaxGamill-Sheffield Sep 16, 2024
4fa276c
chore: fix linting errors
ns-rse Sep 12, 2024
61d0014
style: meaningful names
ns-rse Sep 17, 2024
edc9c82
Merge pull request #900 from AFM-SPM/ns-rse/fix-linting-errors
ns-rse Sep 17, 2024
2f11c53
Merge pull request #903 from AFM-SPM/ns-rse/899-test-new-check_run_steps
ns-rse Sep 17, 2024
b9318f1
Merge branch 'maxgamill-sheffield/800-better-tracing' into SylviaWhit…
SylviaWhittle Sep 17, 2024
ad8f70c
Move test_splining into tests/tracing
SylviaWhittle Sep 17, 2024
08504db
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Sep 17, 2024
e6e70d8
test(utils): Fixing broken tests
ns-rse Sep 17, 2024
4b050dd
Merge pull request #907 from AFM-SPM/ns-rse/fix-test_utils
ns-rse Sep 17, 2024
6cbc79f
tests(plottingfuncs): fixes failing tests
ns-rse Sep 17, 2024
ba400d0
tests(splining): define PIXEL_TRACE once to reduce code duplication
ns-rse Sep 18, 2024
7c14124
Merge branch 'maxgamill-sheffield/800-better-tracing' into maxgamill-…
MaxGamill-Sheffield Sep 18, 2024
10514de
fixes merge errors
MaxGamill-Sheffield Sep 18, 2024
4f56d44
fixes bug plotting reversed crossing not normal & tidies
MaxGamill-Sheffield Sep 18, 2024
3c24622
fix molstats duplication bug by adding mol_num df field
MaxGamill-Sheffield Sep 18, 2024
2d664ed
Merge pull request #909 from AFM-SPM/ns-rse/fix-tests-test_plottingfuncs
ns-rse Sep 18, 2024
68f997d
moved second topology calculation to end of metrics as it messed up s…
MaxGamill-Sheffield Sep 18, 2024
b76b228
Merge pull request #892 from AFM-SPM/SylviaWhittle/800-splining-tests
SylviaWhittle Sep 18, 2024
8821855
+1 to ordered_trace_mask vals so 0 isn't missing in img
MaxGamill-Sheffield Sep 23, 2024
8086692
renamed tracing module grain and molstats vars
MaxGamill-Sheffield Sep 24, 2024
f4919b1
Start to test disordered_trace_grain, starting with height biasing
SylviaWhittle Sep 3, 2024
14101a6
test_disordered_trace_grain: Add test case for no pruning
SylviaWhittle Sep 3, 2024
730043f
test_disordered_trace_grain: Add test case for pruning small tail
SylviaWhittle Sep 3, 2024
e3462dc
test_disordered_trace_grain: Add test case for re-adding holes
SylviaWhittle Sep 4, 2024
4801a50
[WIP] Unpack and create test catenane image
SylviaWhittle Sep 6, 2024
b78b838
Replace example catenane with multiple catenanes
SylviaWhittle Sep 6, 2024
2b28188
Add grain mask for spliced catenane test image
SylviaWhittle Sep 6, 2024
c6f796e
Example catenanes: Replace grain mask with labelled grain mask
SylviaWhittle Sep 6, 2024
fbc895c
Add test_trace_image_disordered
SylviaWhittle Sep 6, 2024
5706ba2
Rename test files to not have 'result' in the filenames
SylviaWhittle Sep 6, 2024
6329d2c
Fix dict_almost_equal not being able to handle np.nan equal
SylviaWhittle Sep 9, 2024
211da3b
Fix test_analyse_node_branches by adding singlet_branch_vectors
SylviaWhittle Sep 9, 2024
c15f390
Fix pair_odd_branches not present in class constructor for test_conne…
SylviaWhittle Sep 9, 2024
05038ce
Add test_nodestats_image
SylviaWhittle Sep 9, 2024
b9d8008
Fix nodestats_catenane fixture pair_odd_branches argument not present
SylviaWhittle Sep 9, 2024
3fb2e19
Fix test_analyse_nodes
SylviaWhittle Sep 9, 2024
91b0970
Parametrize test_nodestats_image
SylviaWhittle Sep 9, 2024
6cc4418
Parametrize test_trace_image_disordered
SylviaWhittle Sep 9, 2024
353fe11
Include all test resources by default except under processed
SylviaWhittle Sep 10, 2024
0305f15
Exclude __pycache__ again
SylviaWhittle Sep 10, 2024
94ef1c3
Add replication intermediate parameterisation to test_trace_image_dis…
SylviaWhittle Sep 10, 2024
21eebae
Add missing file for test_analyse_node_branches
SylviaWhittle Sep 10, 2024
5539b8c
Add parameterisation for replication intermediates to test_nodestats_…
SylviaWhittle Sep 10, 2024
169e29c
Add test_ordered_tracing.py
SylviaWhittle Sep 11, 2024
f22b863
Add test_ordered_tracing_image with catenane parameterisation
SylviaWhittle Sep 11, 2024
da4b351
test_ordered_tracing > add parameterization for repliation intermediate
SylviaWhittle Sep 11, 2024
31e1003
Add test_splining
SylviaWhittle Sep 11, 2024
b7f45d2
Add test_splining_image
SylviaWhittle Sep 11, 2024
f57c196
test_splining_image > add replication intermediate parameterization
SylviaWhittle Sep 11, 2024
68bfd37
splining_image: Fix documentation not listing one of the outputs
SylviaWhittle Sep 11, 2024
1d62430
Move dict_almost_equal to io.py due to not being able to import it in…
SylviaWhittle Sep 11, 2024
c0607fe
Add missing test data files
SylviaWhittle Sep 11, 2024
3e0e77a
Add replication intermediate example image
SylviaWhittle Sep 11, 2024
91564b4
Remove tracing test image creation notebook
SylviaWhittle Sep 11, 2024
4c2504d
Linting documentation
SylviaWhittle Sep 11, 2024
0d41419
tests: Removes .pkl and .npy resources no longer used
ns-rse Sep 11, 2024
980f317
Fix find_connections returning list rather than string for csv compat…
SylviaWhittle Sep 12, 2024
eda855e
Don't compress images using 16-bit encoding as it messes with tests d…
SylviaWhittle Sep 12, 2024
da763bc
Delete the test image creation notebook again but keep it in git history
SylviaWhittle Sep 12, 2024
2f89d90
Use TopoStats' grains finding for example cat and RI segmentation
SylviaWhittle Sep 16, 2024
a1d1c5d
Fix ordered_tracing documentation
SylviaWhittle Sep 16, 2024
a46ba5b
Update test catenane and RI with correct config provided by Max
SylviaWhittle Sep 16, 2024
be4ee23
Parametrize all variables for test_trace_image_disordered
SylviaWhittle Sep 17, 2024
715b2ac
Update test ordered tracing to accept the molstats df
SylviaWhittle Sep 17, 2024
956516f
Fix wrong values used for generating images and masks
SylviaWhittle Sep 17, 2024
1d2e5cd
Create parameterisations for pairing odd branches or not and remove o…
SylviaWhittle Sep 17, 2024
aadbeae
Move ordered tracing test files into tests/ordered_tracing/
SylviaWhittle Sep 17, 2024
48930a4
Tidy up nomenclature and condense debug code
SylviaWhittle Sep 18, 2024
2e896d0
Move test files to relevant directory under tests/resources/tracing/
SylviaWhittle Sep 18, 2024
06a6417
Remove old test files and clean up
SylviaWhittle Sep 18, 2024
410fad0
Update ordered tracing and splining tests after Max's fix
SylviaWhittle Sep 18, 2024
ecbbcfb
Update tests again for latest tracing hotfix
SylviaWhittle Sep 18, 2024
dceb548
Remove singularly used fixtures
SylviaWhittle Sep 18, 2024
bcd2777
Remove comments that describe object structure
SylviaWhittle Sep 18, 2024
e9122e4
Remove temp notebook
SylviaWhittle Sep 24, 2024
af7a2d9
fix(plotting): remove dilation if images are large
ns-rse Sep 24, 2024
14cc3bd
tests: Remove restriction on pytest<8.0.0 (cherry pick)
ns-rse Sep 24, 2024
a21bffb
Merge pull request #918 from AFM-SPM/ns-rse/915-pytest-cherrypick
ns-rse Sep 27, 2024
1fa9988
Merge pull request #914 from AFM-SPM/ns-rse/fix-tests-test_plottingfuncs
ns-rse Sep 27, 2024
97160a2
Move the debugging plotting code to a function instead, thanks @ns-rse
SylviaWhittle Sep 30, 2024
3b74e4d
Update nomenclature | disordered tracing | grainstats_additions > gra…
SylviaWhittle Sep 30, 2024
7d3e91a
Update nomenclature | nodestats | grainstats_additions > grainstats
SylviaWhittle Sep 30, 2024
b9761e0
Update nomenclature | ordered tracing | grainstats_additions > grains…
SylviaWhittle Sep 30, 2024
3213a8d
Update nomenclature | splining | grainstats_additions > grainstats
SylviaWhittle Sep 30, 2024
f9d63bb
Remove unused files
SylviaWhittle Sep 30, 2024
8b09629
Fix files removed required by tests
SylviaWhittle Sep 30, 2024
219790c
Documentation linting
SylviaWhittle Sep 30, 2024
8ece357
Better definition of resource paths
SylviaWhittle Sep 30, 2024
91f74fa
Better definition of resource paths
SylviaWhittle Sep 30, 2024
8b69efb
Fix variable names
SylviaWhittle Sep 30, 2024
263f07c
Merge pull request #897 from AFM-SPM/SylviaWhittle/topology_tests
SylviaWhittle Sep 30, 2024
7dcd29d
replace px_2_nm with pixel_to_nanometre across new codebase + chg gra…
MaxGamill-Sheffield Oct 1, 2024
1858abf
change docstring combinatorics to cominatoric
MaxGamill-Sheffield Oct 1, 2024
ae7808e
change all instances of 'combs' to 'combinations'
MaxGamill-Sheffield Oct 1, 2024
ecd2868
get_two_combs() -> list(itertools.combinations()) + 'conf'->'confiden…
MaxGamill-Sheffield Oct 1, 2024
d4d6cae
Update topostats/validation.py
MaxGamill-Sheffield Oct 1, 2024
059a18b
use revert pylint use of rsplit to split for accessing last element
MaxGamill-Sheffield Oct 1, 2024
a324f24
Merge branch 'maxgamill-sheffield/topology' of https://github.com/AFM…
MaxGamill-Sheffield Oct 1, 2024
aa1d8ac
change skan columns to use '_' not '-'
MaxGamill-Sheffield Oct 1, 2024
d0c44ae
now plots ordered trace img when image_set=False
MaxGamill-Sheffield Oct 1, 2024
c9aaf64
Alphebetise dependencies
SylviaWhittle Oct 2, 2024
ed31997
Merge branch 'maxgamill-sheffield/800-better-tracing' into maxgamill-…
SylviaWhittle Oct 2, 2024
3b67b3a
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Oct 2, 2024
d0751ad
removed -1 pruning.max_length flag
MaxGamill-Sheffield Oct 2, 2024
7001b42
added rainbow / maskcmap to all grains imgs
MaxGamill-Sheffield Oct 2, 2024
9a73090
reduced terminal ouput to just essentials
MaxGamill-Sheffield Oct 2, 2024
f9172f1
ci: restrict supported python version to <3.12
ns-rse Oct 7, 2024
70c875a
Merge pull request #931 from AFM-SPM/ns-rse/930-python-version
ns-rse Oct 7, 2024
fe64eb4
Fix test_analyse_nodes (p2nm -> pixel_to_nm_scaling)
SylviaWhittle Oct 7, 2024
75f1e66
Fix test_nodestats_image
SylviaWhittle Oct 7, 2024
83294e2
Fix test_trace_image_disordered (csv column names)
SylviaWhittle Oct 7, 2024
8bf0b78
Fix test_splining_image (couple extra spline points)
SylviaWhittle Oct 7, 2024
acf36bc
Merge pull request #898 from AFM-SPM/maxgamill-sheffield/topology
MaxGamill-Sheffield Oct 7, 2024
ddae244
Update topostats/tracing/dnatracing.py
llwiggins Oct 8, 2024
c9aa5e4
Merge branch 'main' into maxgamill-sheffield/800-better-tracing
MaxGamill-Sheffield Oct 8, 2024
d8b229f
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Oct 8, 2024
c67267c
fixed bracket in measure confest
MaxGamill-Sheffield Oct 8, 2024
14d854e
Fix test_ferets.py
SylviaWhittle Oct 8, 2024
cfc60ec
re-added dnatraing import into conftest
MaxGamill-Sheffield Oct 8, 2024
5ac50ed
added disordered trace broad except ValueError comment
MaxGamill-Sheffield Oct 8, 2024
f7e62ad
Fix test_processing::test_process_scan_below regtest
SylviaWhittle Oct 8, 2024
c45ace6
Merge remote-tracking branch 'origin/maxgamill-sheffield/800-better-t…
SylviaWhittle Oct 8, 2024
d503f47
docs: Document refactored tracing
MaxGamill-Sheffield Oct 8, 2024
f43c4e3
docs(advanced): lint advanced/*.md
ns-rse Oct 8, 2024
a765a90
docs(conf): Add myst_heading_anchors option
ns-rse Oct 8, 2024
4ffbe78
docs: Remove Markdown footnotes
ns-rse Oct 8, 2024
278ad9e
docs: Fixing various links
ns-rse Oct 8, 2024
7db1600
ci: Update Sphinx to GH pages config with renamed options
ns-rse Oct 8, 2024
2824129
wip: troubleshooting Advanced Documentation toctree
ns-rse Oct 8, 2024
bf5f392
removes / 1e-9 as px_2_nm is alread in nm
MaxGamill-Sheffield Oct 9, 2024
6be2ec7
rm length -1 flag, + px_2_nm value, adjusts some output skeletons
MaxGamill-Sheffield Oct 9, 2024
471e0ab
style(tracing/nodestats): Fix all numpydoc-validation errors
ns-rse Oct 9, 2024
c657bc5
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Oct 9, 2024
b94340b
Add grain filtering based on pixel size in grains.py
SylviaWhittle Oct 9, 2024
54d83a6
Fix test_process_scan_below regtests
SylviaWhittle Oct 9, 2024
4ac1742
Merge branch 'maxgamill-sheffield/800-better-tracing' into maxgamill-…
MaxGamill-Sheffield Oct 9, 2024
3327404
Merge pull request #937 from AFM-SPM/ns-rse/919-numpydoc-validate-nod…
ns-rse Oct 9, 2024
56531d4
Fix test_process_scan_xxxx_height_profiles and below's index error
SylviaWhittle Oct 9, 2024
c535dc9
Fix test_save_format (missing channel specifier [:, :, 1]
SylviaWhittle Oct 9, 2024
b32d044
test_process_stages : remove .png references as they seem to be removed
SylviaWhittle Oct 9, 2024
567c8f2
test_process_scan_align_grainstats_dnatracing made redundant by smoke…
SylviaWhittle Oct 9, 2024
2bf219d
Fix test_process_scan_both
SylviaWhittle Oct 10, 2024
f4cfbfd
Fix test_run_grainstats 21 -> 22 cols (basename added)
SylviaWhittle Oct 10, 2024
6235729
Add removed_objects_too_small_to_process to validation
SylviaWhittle Oct 10, 2024
e8b596f
Add removed_objects_too_small_to_process to validation
SylviaWhittle Oct 10, 2024
c4ae22f
Merge remote-tracking branch 'origin/SylviaWhittle/800-tests-processi…
SylviaWhittle Oct 10, 2024
b0ac0c0
Add removed_objects_too_small_to_process to validation
SylviaWhittle Oct 10, 2024
583b6d1
Merge remote-tracking branch 'origin/SylviaWhittle/800-tests-processi…
SylviaWhittle Oct 10, 2024
f890e6d
Merge pull request #939 from AFM-SPM/SylviaWhittle/800-tests-processing
SylviaWhittle Oct 10, 2024
4393d71
update regtest which changes spacing (no value changes)
MaxGamill-Sheffield Oct 10, 2024
7f230c1
Move tests from test_dnatracing_methods to relevant new tracing files
SylviaWhittle Oct 10, 2024
cda5a17
Delete unused dnatracing tests
SylviaWhittle Oct 10, 2024
7fedd35
Merge pull request #941 from AFM-SPM/SylviaWhittle/800-delete-dnatrac…
SylviaWhittle Oct 10, 2024
05274ca
Merge pull request #940 from AFM-SPM/800-test-grainstats
MaxGamill-Sheffield Oct 10, 2024
ceafb31
Merge pull request #938 from AFM-SPM/800-tests_pruning
MaxGamill-Sheffield Oct 10, 2024
49aaa91
Import __future__.annotations to allow pipe
SylviaWhittle Oct 10, 2024
8dbd1ba
Fix lazyfixture deprecation
SylviaWhittle Oct 10, 2024
e74731a
Import __future__.annotations to allow pipe
SylviaWhittle Oct 10, 2024
fabac1c
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Oct 10, 2024
835a919
Fix lazy fixture error again but properly
SylviaWhittle Oct 10, 2024
4d8cee1
Disable pruning on test_process_scan_below to ensure our poor solitar…
SylviaWhittle Oct 10, 2024
e49042f
Remove erroneous static method from non-function (python 3.9 crashes)
SylviaWhittle Oct 10, 2024
c07d973
replaced dnatracing references in with new pipeline
MaxGamill-Sheffield Oct 10, 2024
2f47217
remove dnatracing.py and dnatracing references where appropriate
MaxGamill-Sheffield Oct 10, 2024
2119084
rm -1 length flag in disordered tracing tests and px2nm*1e-9 convseri…
MaxGamill-Sheffield Oct 10, 2024
3a622c5
changed splining lengths to SI and updated tests
MaxGamill-Sheffield Oct 10, 2024
e7c230f
Fix test_processing above, below, both (outputs in standard form)
SylviaWhittle Oct 10, 2024
53a8560
Set default plotting DPI to 100 for my sanity
SylviaWhittle Oct 10, 2024
b91434d
Fix tolerance issue in dictionary equality with dict_almost_equal
SylviaWhittle Oct 10, 2024
9205b2a
Linting
SylviaWhittle Oct 10, 2024
5dbd8c3
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Oct 10, 2024
32d2c9e
Fix more tolerance issues with assert dict_almost_equal
SylviaWhittle Oct 10, 2024
3489a8a
Linting
SylviaWhittle Oct 10, 2024
f29a340
Add topoly version to logs for ubuntu debugging
SylviaWhittle Oct 11, 2024
f9e9688
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Oct 11, 2024
a1a3a3c
Force topoly to be 1.0.2
SylviaWhittle Oct 11, 2024
675c717
Merge remote-tracking branch 'origin/maxgamill-sheffield/800-better-t…
SylviaWhittle Oct 11, 2024
1c1d0f6
Add tests/tracing/test_tracing_dna.py since CI thinks it exists (it d…
SylviaWhittle Oct 11, 2024
4e075a7
Update software architecture info and mark notebooks as outdated
SylviaWhittle Oct 11, 2024
2c4658f
Force grain endpoints and grain junctions to be int64 (for windows te…
SylviaWhittle Oct 11, 2024
07a4d96
Try to appease the worse operating system... (pyqt5 matplotlib backend)
SylviaWhittle Oct 11, 2024
0ad6ed3
Revert "Try to appease the worse operating system... (pyqt5 matplotli…
SylviaWhittle Oct 11, 2024
2620669
Merge branch 'maxgamill-sheffield/800-better-tracing' into maxgamill-…
ns-rse Oct 14, 2024
742cc92
style(tracingfuncs): Numpydoc validation, PEP8 & tidying
ns-rse Oct 14, 2024
45cdfac
fix(disordered_tracing): force branch_type to int64
ns-rse Oct 14, 2024
e59d1bd
Re-done pruning images so heights >> 1e-19 (now ~1) causing floating …
MaxGamill-Sheffield Oct 14, 2024
291c58a
fix(nodestats): Force dtype to np.int64() to appease Windows
ns-rse Oct 14, 2024
2b23815
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Oct 14, 2024
b228394
Type hints, thanks @ns-rse
SylviaWhittle Oct 14, 2024
c80459a
Type hints, thanks @ns-rse
SylviaWhittle Oct 14, 2024
1f41628
fix(nodestats): Explicitly set dtype to np.int64()/np.float64()
ns-rse Oct 14, 2024
e6ec695
style(test/tracing): pass > pytest.mark.skip() for missing tests
ns-rse Oct 15, 2024
7fc8fd7
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Oct 15, 2024
3051c79
Merge pull request #949 from AFM-SPM/ns-rse/fix-pandas-dtype
ns-rse Oct 15, 2024
db5910a
style(theme): RT01 Numpydoc Validation
ns-rse Oct 15, 2024
73f35f4
readjusts expected height values in height profile tests from fixture…
MaxGamill-Sheffield Oct 15, 2024
052b4b3
Fix process scan (formatting in csv)
SylviaWhittle Oct 15, 2024
d8ba71b
Merge remote-tracking branch 'origin/maxgamill-sheffield/800-better-t…
SylviaWhittle Oct 15, 2024
b36aef2
docs: Remove 2nd toctree and add advanced.md page
ns-rse Oct 15, 2024
4f113fa
Merge pull request #952 from AFM-SPM/ns-rse/linting
ns-rse Oct 15, 2024
bb6de5b
Fix typo
SylviaWhittle Oct 15, 2024
d3d0955
Re-done pruning images so heights >> 1e-19 (now ~1) causing floating …
MaxGamill-Sheffield Oct 14, 2024
53e8444
Type hints, thanks @ns-rse
SylviaWhittle Oct 14, 2024
450f202
Type hints, thanks @ns-rse
SylviaWhittle Oct 14, 2024
2e77325
fix(disordered_tracing): force branch_type to int64
ns-rse Oct 14, 2024
5323c28
fix(nodestats): Force dtype to np.int64() to appease Windows
ns-rse Oct 14, 2024
eaeac76
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Oct 14, 2024
5c2d836
fix(nodestats): Explicitly set dtype to np.int64()/np.float64()
ns-rse Oct 14, 2024
16499f0
style(test/tracing): pass > pytest.mark.skip() for missing tests
ns-rse Oct 15, 2024
a8d998c
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Oct 15, 2024
ee0aaaa
Fix process scan (formatting in csv)
SylviaWhittle Oct 15, 2024
93d71ef
readjusts expected height values in height profile tests from fixture…
MaxGamill-Sheffield Oct 15, 2024
cab4518
style(theme): RT01 Numpydoc Validation
ns-rse Oct 15, 2024
04fa5f3
fix(tracingfuncs): Remove unused parameters
ns-rse Oct 15, 2024
222e7a8
Merge pull request #948 from AFM-SPM/ns-rse/920-tracingfuncs-numpydoc…
ns-rse Oct 15, 2024
f476c65
Merge pull request #936 from AFM-SPM/maxgamill-sheffield/btr-docs
MaxGamill-Sheffield Oct 15, 2024
cd34c22
Remove print statement and revert default cores to 2
SylviaWhittle Oct 15, 2024
5f7a1bc
Fix not commenting out the test update scripts
SylviaWhittle Oct 15, 2024
94997db
moved fill diagonal inside calc_angles to ensure self vector angles a…
MaxGamill-Sheffield Oct 15, 2024
a940d8f
Merge pull request #956 from AFM-SPM/800-bt-angle_out_of_range
MaxGamill-Sheffield Oct 15, 2024
c64de97
docs: lower-case link
ns-rse Oct 16, 2024
30d4c43
Merge pull request #964 from AFM-SPM/ns-rse/fix-advanced-doc-link
ns-rse Oct 16, 2024
1122c2b
Removed "DNA Tracing" from advanced docs as it can be misleading
MaxGamill-Sheffield Oct 16, 2024
dc895fc
ci: Empty commit to trigger CI with updated workflow
ns-rse Oct 16, 2024
b953634
code blocks to address sphinx autodocs errors of key structure and eq…
MaxGamill-Sheffield Oct 16, 2024
42092ff
Merge pull request #968 from AFM-SPM/800-btr_doc-fix
MaxGamill-Sheffield Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# nodestats codespell corrections
f13f8d40d6768f14a46315d105b3d80beaa33aaf
284f113cf8416eed43b88b4c438d7552456616e3

# numpydoc validation - Linting docstrings with pre-commit numpydoc
836e1bf5347eb7a9f97e784e783045c0287b3fe9
2580811edefac867938ee0c4b705649a493e5d4f
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sphinx_docs_to_gh_pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
# defined as it defaults to 'main'.
branch: main
dir_docs: docs
sphinxapiexclude: "../*setup* ../*tests* ../*.ipynb ../demo.py ../make_baseline.py ../jupyter_notebook_config.py ../demo_ftrs.py"
sphinxapiopts: "--separate -o . ../"
sphinxopts: ""
sphinx-apidoc-exclude: "../*setup* ../*tests* ../*.ipynb ../demo.py ../make_baseline.py ../jupyter_notebook_config.py ../demo_ftrs.py"
sphinx-apidoc-opts: "--separate -o . ../"
sphinx-opts: ""
multiversion: true
multiversionopts: ""
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ output/config.yaml
*.npy
*.csv
*.spm
*.svg

# Notebook checkpoints
notebooks/.ipynb_checkpoints/
Expand All @@ -34,6 +35,7 @@ notebooks/.ipynb_checkpoints/
.vscode/
.idea/
*~
pytest-debug.ini

# Documentation
_build/
Expand All @@ -57,5 +59,10 @@ topostats/_version.py
# default output directory, often common from testing
output/

# Include all files in tests and all subdirectories except processed and __pycache__
!tests/**
tests/resources/processed/
__pycache__/

# Debugging
pytest-debug.ini
pytest-debug.ini
1 change: 1 addition & 0 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ config:
html:
allowed_elements:
- div
- br

# Globs
globs:
Expand Down
1 change: 0 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ fail-under=10.0
# Files or directories to be skipped. They should be base names, not paths.
ignore=CVS,
_version.py,
dnatracing.py,
dnacurvature.py,
conf.py,
test_dnacurvature.py,
Expand Down
14 changes: 11 additions & 3 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ not currently considered core elements of `topostats` apart from `Plotting.py`.
Currently the `topostats` module consists of:

- `default_config.ini` The default config file.
- `dnatracing.py` Applies tracing functions to each molecule.
- `pygwytracing.py` The "main" routine.
- `tracingfuncs.py` Skeletonises and generates backbone traces from masks.
- `run_topostats.py` The main script for running `topostats` and handles multiprocessing.
- `entry_point.py` Handles the entry point commandline commands.
- `processing.py` Handles processing a single AFM file.
- `filters.py` Handles flattening and pre-processing images.
- `grains.py` Handles grain segmentation.
- `grainstats.py` Calculates statistics for each grain.
- `disordered_tracing.py` Initial tracing of molecules.
- `nodestats.py` Handles any crossings / branches in DNA grains.
- `ordered_tracing.py` Proper tracing of molecules.
- `splining.py` Smooths / splines the traces for a more representative trace.
- `plotting.py` Handles plotting of the data.

The current working plan is to move to a more modular architecture with new (and existing) functionality being grouped
by theme within files. We expect to add such files as:
Expand Down
3 changes: 3 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
html[data-theme="dark"] .bd-content img:not(.only-dark, .dark-light) {
background-color: transparent !important;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/nodestats/convolved.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/nodestats/diagnostics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/nodestats/height_trace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/nodestats/joining.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/nodestats/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/nodestats/pairing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/nodestats/tidy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/ordered_tracing/ns_3d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/ordered_tracing/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/ordered_tracing/ts_trace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/splining/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/splining/rw_schematic.png
Binary file added docs/_static/images/splining/rw_sizes.png
Binary file added docs/_static/images/splining/spl_multi.png
Binary file added docs/_static/images/splining/spl_smooth.png
Binary file added docs/_static/images/splining/topostats_file.png
8 changes: 8 additions & 0 deletions docs/advanced.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Advanced Documentation

You can read more detailed information about the methods implemented in TopoStats in the pages below.

- [Disordered Tracing](advanced/disordered_tracing.md)
- [Nodestats](advanced/nodestats.md)
- [Ordered Tracing](advanced/ordered_tracing.md)
- [Splining](advanced/splining.md)
171 changes: 171 additions & 0 deletions docs/advanced/disordered_tracing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# Disordered Tracing

This section gives an in-depth overview of the steps taken in the disordered tracing module.

## At a Glance : Simple Representations

The `disordered_tracing.py` module handles all the functions associated with obtaining single-pixel wide, line
representations of masked objects.

The quality and likeness of the resultant pruned skeleton thus depends on the quality of the mask, the effectiveness of
smoothing parameters, the method of skeletonisation, and the quality of automating the pruning of incorrect skeletal
branches.

![object mask to pruned skeleton](../_static/images/disordered_tracing/overview.png)

This module measures the number of junctions and endpoints for each pruned skeleton object and appends these columns to
the `all_statistics.csv`. In addition, the `all_disordered_segment_statistics.csv` file is produced which measures the
length, type, connections, and pixel value (typically height); minimum, middle, median, mean and standard deviation for
each skeleton segment between junctions using [Skan](https://skeleton-analysis.org/stable/index.html). The branch types
are given by:

- 0: Endpoint-to-endpoint
- 1: Endpoint-to-junction
- 2: Junction-to-junction
- 3: Isolated cycle

Some useful points to bear in mind:

- **Bad mask, bad skeleton** - If the mask closes holes seen in the image, all skeletonisation methods will produce a
single line for this region.
- **No skeletons in image** - The disordered trace `core` image may not show the resultant skeletons if the plotting
`dpi` value is too low (varies based on image size).
- **Hard to remove branches** - If there are still spurious branches to prune after modifying the
`mask_smoothing_params` and `pruning_params`, try increasing the `filters.gaussian_size` value to smooth the image the
mask is created from.
- **Masked colours are relative** - Any mask colours that may be produced by plots are relative to the mask values in
that image as they will always span the masked colourmap, and will not compare well across images if the range of mask
values differ.

## Processing Steps

### 1. Smoothing the Mask

Generated masks can be quite jagged which causes a large increase in spurious skeletal branches which do not best
represent the image. This can be resolved by first smoothing the incoming mask.

![Image of smoothed vs un-smoothed skeletonisation result](../_static/images/disordered_tracing/smoothing.png)

Smoothing uses either binary dilation (expanding the borders of the mask `dilation_iterations` times) or an otsu
threshold applied to a gaussian filtered mask (with a smoothing factor of `gaussian_sigma`). If both values are provided
an input in the configuration file, they will compete, and the winning result is the one with the smallest number of
added pixels.

The reason for the competition is an attempt to conserve mask topology i.e. any small holes it has which may become
closed upon dilation / gaussian blurring. The dilation method seems to work best for larger masks where there are more
mask pixels, and the gaussian smoothing better when there are small holes.

In addition, this smoothing step also tries to preserve mask topology by re-adding any holes back into the mask that lie
within the `holearea_min_max` threshold. This has the resulting effect of only smoothing the outer edge of the mask.

### 2. Skeletonisation

Skeletonisation is the process of reducing a binary image to a single-pixel wide representation. This can be done using
the algorithms provided by [scikit-image](https://scikit-image.org/docs/stable/auto_examples/edges/plot_skeleton.html)
such as `zhang` (rule based + erosion), `lee` (connectivity preserving), `medial_axis` (pixels with >1 closest boundary
pixels), or `topostats` - a modification of Zhang's algorithm which uses the underlying height information to order and
then remove only a percentage of the pixels marked for removal on each skeletonisation iteration. The skeletonisation
methods are handled by the `tracing/skeletonize.py` module.

![Comparison between skeletonisation algorithms](../_static/images/disordered_tracing/skeletons.png)

We have found that by including the height information into the skeletonisation process and removing the lowest
`height_bias` percent, we can bias the skeleton to lie on the DNA backbone and generate a better representation of the
molecule, especially at crossing points and regions where the mask is less accurate.

![Different skeletonisation height bias examples](../_static/images/disordered_tracing/height_bias.png)

### 3. Pruning

Pruning is the act of removing spurious branches from a skeleton which does not follow the underlying masks' shape. To
this end, TopoStats provides a variety of methods and parameters to help clean up the skeletons.

![Pre and post pruning of skeletons](../_static/images/disordered_tracing/pruning.png)

Pruning can be done by branch length (using the `max_length` configuration parameter) and / or the branch height (using
the `height_threshold`, `method_values` and `method_outliers` configuration parameters).

Length pruning is the simplest, iteratively comparing the length (in nm) of each branch containing an endpoint with the
`max_length` parameter. If it's length is below this value, it is deemed as a spurious branch and removed, along with
any junction pixels until a single-pixel skeleton remains.

Height pruning also iteratively compares the branches pixel values (height) to a `height_threshold` parameter, again,
any branch heights which are below this value are pruned. However, as there are multiple pixels in a branch, we provide
different methods to obtain a single branch height value for comparison i.e. `method_values`:

- `min` - the minimum value of all the branch pixel values.
- `median`- the median value of all the branch pixel values.
- `mid` - the middle value (averaged if two) of the ordered branch pixels. This is particularly useful for pruning false
bridges where the height dips in the middle of the branch.

Additionally, how these branch height values compare to the `height_threshold` is also considered i.e `method_outliers`:

- `abs` - prunes branch values below the absolute value of the `height_threshold`.
- `mean_abs` - prunes branch values below the whole skeleton mean pixel value - absolute threshold. This is useful for
non-surface samples or periodic structures e.g. in DNA we expect the mean height to be around 2nm, but high resolution
imaging may cause this to dip to 0.8nm (the depth of a major groove), so we'd want to prune branch heights below this.
- `iqr` - prunes branch values below 1.5x inter-quartile range (IQR) of all the branches. Height pruning cannot produce
more than one skeleton and so avoids breaking up the skeleton into multiple parts.

## Outputs

The `<image>_<threshold>_disordered_trace` image shows the pruned skeletons that are used to obtain the below metrics
and passed onto future processing stages.

For each grain, the following new columns are added to the `grainstats.csv` file:

| Column Name | Description | Data Type |
| --------------------- | --------------------------------------------------------------------------------------- | --------- |
| `grain_endpoints` | The number of pixels designated as endpoints (only 1 neighbour) in the pruned skeleton. | `integer` |
| `grain_junctions` | The number of pixels designated as junctions (>2 neighbours) in the pruned skeleton. | `integer` |
| `total_branch_length` | The sum of all branch lengths in the pruned skeleton. | `float` |

&nbsp;

An `all_disordered_segment_statistics.csv` file is produced for each image which measures the following metrics from
each segment in each pruned skeleton:

| Column Name | Description | Data Type |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------- | --------- |
| `image` | The image name being processed. | `string` |
| `threshold` | The direction of the grain threshold being applied. | `string` |
| `grain_number` | The number of the grain being processed in the image. | `integer` |
| `index` | The branch index. | `integer` |
| `branch-distance` | The distance (in nm) of the branch. | `float` |
| `branch-type` | Branch classification of endpoint-to-endpoint (0), endpoint-to-junction (1), junction-to-junction (2), isolated cycle (3). | `integer` |
| `connected_segments` | The index of the branch segments that this current branch is connected to via a junction point. | `list` |
| `mean-pixel-value` | The mean of the branch pixel values (height), in nm. | `float` |
| `stdev-pixel-value` | The standard deviation of the branch pixel values (height), in nm. | `float` |
| `min-value` | The minimum value of the branch pixel values (height), in nm. | `float` |
| `median-value` | The median value of the branch pixel values (height), in nm. | `float` |
| `mid-value` | The value of a pixel halfway along the ordered branch (height), in nm. | `float` |
| `basename` | The directory path containing the image. | `string` |

## Diagnostic Images

Images produced by the `plotting.image_set: all` for this module are:

- `21-smoothed_grains` - The smoothed mask, used to check that the image topology is retained (holes) before
skeletonisation.
- `22-original_skeletons` - Skeletonised mask, used to ensure the skeletons follow the underlying structures. Used to
check if the skeletonisation parameters are suitable.
- `23-branch_indexes` - An integer mask of the pruned skeleton with branch pixel values matching the index value in the
data. Used to cross reference the `all_disordered_segment_statistics.csv` data with an image. Using the default
colourmap for this (viridris), darker (purple) colours are lower indexes, and brighter (yellow) colours are higher.
- `24-branch_types` - An integer mask of the pruned skeleton with branch pixel values matching the `branch-type`
(numbers and definitions in the "At a Glance" section). This can be used to count and check if the skeletonisation
process correctly identifies the different branch types. Using the default colourmap for this (viridris), darker
(purple) colours are lower indexes, and brighter (yellow) colours are higher.

![Examples of diagnostic images](../_static/images/disordered_tracing/diagnostics.png)

## Possible Uses

This module would lend itself to measuring branched structures and may aid the identification of particular regions by
filtering-out segments based on their branch type.

We have used this module to identify and measure the length of reverse forks in stalled DNA replication intermediates as
these structures should produce closed loops, however, the reverse forks can be identified as branches with endpoints
and their metrics identified from the data. It has also been used as part of the pipeline to obtain ordered traces along
topologically complex DNA molecules and topological classifications in our paper; [Under or Over? Tracing Complex DNA
Topologies with High Resolution Atomic Force Microscopy](https://www.biorxiv.org/content/10.1101/2024.06.28.601212v1).
Loading
Loading