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

Open
wants to merge 740 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
740 commits
Select commit Hold shift + click to select a range
579d10e
Tidy up
SylviaWhittle Aug 15, 2024
c39a7f1
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Aug 15, 2024
85134e9
added ordered_tracing config params to config docs
MaxGamill-Sheffield Aug 14, 2024
5098a44
+ docstring for tracingfuncs.reorderTrace class
MaxGamill-Sheffield Aug 14, 2024
6483626
amended optional plot comment for clarity
MaxGamill-Sheffield Aug 14, 2024
d6be379
Re-add the run_ordered_tracing try / except
MaxGamill-Sheffield Aug 14, 2024
6cbf7c9
Nodestats list terminators use └
MaxGamill-Sheffield Aug 14, 2024
c30308f
FWHM references explained in each func
MaxGamill-Sheffield Aug 14, 2024
b4865c3
Amended compile_traces docstring and temp__heights references
MaxGamill-Sheffield Aug 14, 2024
db7b68b
removed '_''s from loops
MaxGamill-Sheffield Aug 14, 2024
e68b444
'z' array name changed to more informative 'stacking_order'
MaxGamill-Sheffield Aug 14, 2024
7faa5cd
clarify remove_common_values()
MaxGamill-Sheffield Aug 14, 2024
2bc1290
cleanup get_trace_idxs docstring and another comment
MaxGamill-Sheffield Aug 14, 2024
48a6eab
use list comprehension for compile trace start
MaxGamill-Sheffield Aug 14, 2024
70b271b
removed stacking_order referenced
MaxGamill-Sheffield Aug 14, 2024
0628d94
replaced remove_duplicates with remove_common_values
MaxGamill-Sheffield Aug 14, 2024
fd31aa1
remove redundant code from over/under img
MaxGamill-Sheffield Aug 14, 2024
514fda4
merge conflict with Neil's suggestions
MaxGamill-Sheffield Aug 14, 2024
d26911e
Merge branch 'maxgamill-sheffield/800-btr-splining' of https://github…
MaxGamill-Sheffield Aug 15, 2024
09cb6f5
else in rolling window smoothing while loop to avoid empty mean list
MaxGamill-Sheffield Aug 15, 2024
44e9268
Add test for pool_trace_circular
SylviaWhittle Aug 15, 2024
d371e74
Add test for pool_trace_circular
SylviaWhittle Aug 15, 2024
9d845e0
Merge branch 'SylviaWhittle/800-splining-tests' of github.com:AFM-SPM…
SylviaWhittle Aug 15, 2024
0cca27f
Add contingency for no mols found and failing modules
MaxGamill-Sheffield Aug 16, 2024
ebd3550
rm accidentally copied over files
MaxGamill-Sheffield Aug 16, 2024
c5d96e9
Changed input and output dir in default_config to ensure resources/mi…
llwiggins Aug 16, 2024
9fa717f
added endpoint and crossing T/F stats from disordered tracing
MaxGamill-Sheffield Aug 16, 2024
c8c91ca
Merge branch 'maxgamill-sheffield/800-btr-splining' of https://github…
MaxGamill-Sheffield Aug 16, 2024
a050763
returns results_df not None when run is false
MaxGamill-Sheffield Aug 16, 2024
2f518aa
create mol stats csv
MaxGamill-Sheffield Aug 19, 2024
9d5a03d
Edits cropped_masks so that each crop only contains one grain, all ot…
llwiggins Aug 21, 2024
3320b27
Fixes average_crossing_confs() so that it no longer terminates after …
llwiggins Aug 21, 2024
be5154d
Removes run_dnatracing import that was causing tests to break
llwiggins Aug 21, 2024
2588d8b
activate try/excepts, + odd-branch handling & config, + tidy
MaxGamill-Sheffield Aug 21, 2024
f6b350d
Fixes molecules being overwritten in all_mol_statistics.csv
llwiggins Aug 21, 2024
a1b61a1
Clean up all_mol_statistics.csv data table
llwiggins Aug 21, 2024
595d0c7
Merge pull request #889 from AFM-SPM/maxgamill-sheffield/800-btr-spli…
llwiggins Aug 22, 2024
937e253
+ pair_odd_branches to default config
MaxGamill-Sheffield Aug 22, 2024
4908394
Moved and added unmatched branch dict to results containing angles
MaxGamill-Sheffield Aug 23, 2024
bb6975d
Fix bugs in linear trace smoothing where windows were not correctly a…
SylviaWhittle Aug 23, 2024
29892d2
Add test for linear splining
SylviaWhittle Aug 23, 2024
0a274e2
+ disordered segment statistics using Skan & disgnostic branch type i…
MaxGamill-Sheffield Aug 23, 2024
332a7b5
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Aug 23, 2024
c6df70e
Add skan to installed libraries
MaxGamill-Sheffield Aug 23, 2024
8a8426b
Merge branch 'maxgamill-sheffield/RIs' of https://github.com/AFM-SPM/…
MaxGamill-Sheffield Aug 23, 2024
3c1c65a
cleanup and rtn results_df instead of empty df on ordered_tracing fai…
MaxGamill-Sheffield Aug 23, 2024
e63e2b9
change molstats dict keys to not overwrite prev grain values
MaxGamill-Sheffield Aug 23, 2024
66881b2
Update topostats/processing.py
MaxGamill-Sheffield Aug 27, 2024
a3c03bf
Merge branch 'maxgamill-sheffield/800-btr-splining' into maxgamill-sh…
MaxGamill-Sheffield Aug 27, 2024
60c9d16
re-add nodestats to config.md
MaxGamill-Sheffield Aug 27, 2024
f6f8d33
counts endpoints and junctions
MaxGamill-Sheffield Aug 29, 2024
d989fe4
Merge pull request #886 from AFM-SPM/maxgamill-sheffield/800-btr-spli…
MaxGamill-Sheffield Aug 30, 2024
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
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
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
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
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
120 changes: 67 additions & 53 deletions docs/configuration.md

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ keywords = [
"afm",
"image processing"
]
requires-python = ">=3.9"
requires-python = ">=3.9, <3.12"
dependencies = [
"AFMReader",
"h5py",
Expand All @@ -44,18 +44,20 @@ dependencies = [
"numpy",
"numpyencoder",
"pandas",
"pySPM",
"pyfiglet",
"pySPM",
"pyyaml",
"ruamel.yaml",
"schema",
"scikit-image",
"scipy",
"seaborn",
"skan",
"snoop",
"tensorflow",
"tifffile",
"topoly",
"tqdm",
"tensorflow",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -127,8 +129,10 @@ write_to = "topostats/_version.py"

[tool.pytest.ini_options]
minversion = "7.0"
addopts = ["--mpl", "-ra", "--strict-config", "--strict-markers"]
log_cli_level = "Info"
addopts = ["--cov", "--mpl", "-ra", "--strict-config", "--strict-markers"]
log_level = "INFO"
log_cli = true
log_cli_level = "INFO"
testpaths = [
"tests",
]
Expand Down Expand Up @@ -185,7 +189,6 @@ exclude = [
"dist",
"docs/conf.py",
"node_modules",
"pygwytracing.py",
"tests/tracing/test_dnacurvature.py",
"tests/tracing/test_dnatracing.py",
"tests/tracing/test_tracing_dna.py",
Expand Down Expand Up @@ -258,7 +261,7 @@ convention = "numpy"
fixture-parentheses = true

[tool.codespell]
skip = '*.spm*,*.mplstyle'
skip = '*.spm*,*.mplstyle,*.svg'
count = ''
quiet-level = 3

Expand All @@ -275,9 +278,10 @@ exclude = [ # don't report on objects that match any of these regex
"\\.__repr__$",
"^test_",
"^conftest",
"^dnatrcing",
"^nodestats",
"^tracingfuncs",
"^conf$",
"^theme",
]
override_SS05 = [ # override SS05 to allow docstrings starting with these words
"^Process ",
Expand Down
103 changes: 103 additions & 0 deletions temp.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from scipy.spatial.distance import cdist"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# point arrays\n",
"array1 = np.array([[1, 2], [2, 3], [3, 3]])\n",
"array2 = np.array([[4, 4], [4, 5], [5, 5], [6, 6]])\n",
"\n",
"img = np.zeros((10, 10))\n",
"# set all array1 points to 1\n",
"for point in array1:\n",
" print(point)\n",
" img[point[0], point[1]] = 1\n",
"\n",
"print(\"----\")\n",
"\n",
"# set all array2 points to 2\n",
"for point in array2:\n",
" print(point)\n",
" img[point[0], point[1]] = 2\n",
"\n",
"plt.imshow(img)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Numpy approach\n",
"\n",
"# How to create this matrix from array1 and array2?\n",
"# [1 4] [1 4] [1 5] [1 6]\n",
"# [2 4] [2 4] [2 5] [2 6]\n",
"# [3 4] [3 4] [3 5] [3 6]\n",
"\n",
"grid1, grid2 = np.meshgrid(array1, array2)\n",
"print(grid1)\n",
"print(grid2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# test if any points are touching between the two arrays, using vectorisation\n",
"\n",
"diffs = np.subtract.outer(array1, array2)\n",
"print(diffs)\n",
"print(\"---\")\n",
"# linalg the diffs\n",
"dists = np.linalg.norm(diffs, axis=1)\n",
"print(dists)\n",
"\n",
"print(\"---\")\n",
"\n",
"\n",
"cdists = cdist(array1, array2, \"euclidean\")\n",
"print(cdists)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "new",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
centre_x centre_y radius_min radius_max radius_mean radius_median height_min height_max height_median height_mean volume area area_cartesian_bbox smallest_bounding_width smallest_bounding_length smallest_bounding_area aspect_ratio threshold max_feret min_feret image
molecule_number
grain_number
0 7.500895e-08 4.775362e-08 4.044948e-09 2.542964e-08 1.600048e-08 1.647888e-08 1.006306e-09 2.696640e-09 1.597337e-09 1.596062e-09 1.084371e-24 6.794043e-16 1.319762e-15 2.053897e-08 5.037861e-08 1.034725e-15 0.407692 above 5.037861e-08 2.053897e-08 None
1 8.028649e-08 7.895237e-08 6.658610e-09 2.623645e-08 1.609777e-08 1.573693e-08 1.009513e-09 2.480685e-09 1.668932e-09 1.683197e-09 1.031843e-24 6.130257e-16 1.526707e-15 2.017441e-08 4.942135e-08 9.970467e-16 0.408213 above 4.987228e-08 2.017441e-08 None
2 4.001424e-08 7.585689e-08 9.745734e-09 2.369314e-08 1.746942e-08 1.818722e-08 1.006681e-09 2.139365e-09 1.646541e-09 1.598842e-09 1.123717e-24 7.028320e-16 1.546230e-15 3.359220e-08 4.149625e-08 1.393950e-15 0.809524 above 4.440534e-08 3.176819e-08 None
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
image_size_x_m image_size_y_m image_area_m2 image_size_x_px image_size_y_px image_area_px2 grains_number_above grains_per_m2_above grains_number_below grains_per_m2_below rms_roughness
image
minicircle_small 1.2646e-07 1.2646e-07 1.5993e-14 64 64 4096 3 1.8758e+14 0 0.0000e+00 6.8208e-10
centre_x centre_y radius_min radius_max radius_mean radius_median height_min height_max height_median height_mean volume area area_cartesian_bbox smallest_bounding_width smallest_bounding_length smallest_bounding_area aspect_ratio threshold max_feret min_feret image contour_length circular end_to_end_distance
molecule_number
0 7.5100e-08 4.7559e-08 3.9431e-09 2.5631e-08 1.6016e-08 1.6680e-08 9.1991e-10 2.6422e-09 1.5338e-09 1.5341e-09 1.0543e-24 6.8721e-16 1.3198e-15 2.0539e-08 5.0379e-08 1.0347e-15 4.0769e-01 above 5.0379e-08 2.0539e-08 minicircle_small 6.0226e-08 False 8.6738e-09
1 8.0241e-08 7.8677e-08 6.8951e-09 2.7188e-08 1.6272e-08 1.6263e-08 9.0630e-10 2.4586e-09 1.6144e-09 1.6264e-09 1.0352e-24 6.3645e-16 1.5931e-15 2.0174e-08 5.1212e-08 1.0332e-15 3.9394e-01 above 5.1262e-08 2.0174e-08 minicircle_small 6.6355e-08 True 0.0000e+00
2 4.0012e-08 7.5644e-08 9.9461e-09 2.3654e-08 1.7561e-08 1.8364e-08 9.0641e-10 2.1066e-09 1.5939e-09 1.5493e-09 1.1192e-24 7.2236e-16 1.5462e-15 3.3592e-08 4.1496e-08 1.3940e-15 8.0952e-01 above 4.4405e-08 3.2528e-08 minicircle_small 9.6106e-08 True 0.0000e+00
centre_x centre_y grain_number radius_min radius_max radius_mean radius_median height_min height_max height_median height_mean volume area area_cartesian_bbox smallest_bounding_width smallest_bounding_length smallest_bounding_area aspect_ratio threshold max_feret min_feret image grain_endpoints grain_junctions total_branch_lengths num_crossings avg_crossing_confidence min_crossing_confidence num_mols writhe_string total_contour_length average_end_to_end_distance
0 7.5100e-08 4.7559e-08 0 3.9431e-09 2.5631e-08 1.6016e-08 1.6680e-08 9.1991e-10 2.6422e-09 1.5338e-09 1.5341e-09 1.0543e-24 6.8721e-16 1.3198e-15 2.0539e-08 5.0379e-08 1.0347e-15 4.0769e-01 above 5.0379e-08 2.0539e-08 minicircle_small 1 1 8.4571e+01 1 None None 2 6.5881e+01 8.8370e+00
1 8.0241e-08 7.8677e-08 1 6.8951e-09 2.7188e-08 1.6272e-08 1.6263e-08 9.0630e-10 2.4586e-09 1.6144e-09 1.6264e-09 1.0352e-24 6.3645e-16 1.5931e-15 2.0174e-08 5.1212e-08 1.0332e-15 3.9394e-01 above 5.1262e-08 2.0174e-08 minicircle_small 0 0 7.3054e+01 0 None None 1 NaN 5.8272e+01 0.0000e+00
2 4.0012e-08 7.5644e-08 2 9.9461e-09 2.3654e-08 1.7561e-08 1.8364e-08 9.0641e-10 2.1066e-09 1.5939e-09 1.5493e-09 1.1192e-24 7.2236e-16 1.5462e-15 3.3592e-08 4.1496e-08 1.3940e-15 8.0952e-01 above 4.4405e-08 3.2528e-08 minicircle_small 0 0 1.0447e+02 0 None None 1 NaN 8.7183e+01 0.0000e+00
91 changes: 59 additions & 32 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ def grainstats_config(default_config: dict) -> dict:
"""Configurations for grainstats."""
config = default_config["grainstats"]
config["direction"] = "above"
# Set cropped image size to 40nm
config["cropped_size"] = 40.0
config.pop("run")
return config

Expand Down Expand Up @@ -732,30 +734,39 @@ def minicircle_grainstats(
)


# Derive fixtures for DNA Tracing
GRAINS = np.array(
[
[0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 2],
[0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 2],
[0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 2],
[0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 2],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2],
[0, 0, 3, 3, 3, 3, 3, 0, 0, 0, 2],
[0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 2],
[0, 0, 3, 3, 3, 3, 3, 0, 0, 0, 2],
[0, 0, 4, 4, 4, 4, 4, 0, 0, 0, 2],
]
)
FULL_IMAGE = RNG.random((GRAINS.shape[0], GRAINS.shape[1]))
# Random shapes
# Generate a random skeletons, first is a skeleton with a closed loop with side branches
kwargs = {
"image_shape": (60, 32),
"max_shapes": 10,
"channel_axis": None,
"shape": None,
"allow_overlap": True,
"min_size": 20,
}


@pytest.fixture()
def test_dnatracing() -> dnaTrace:
"""Instantiate a dnaTrace object."""
return dnaTrace(image=FULL_IMAGE, grain=GRAINS, filename="Test", pixel_to_nm_scaling=1.0)
def utils_skeleton_linear1() -> npt.NDArray:
"""Linear skeleton."""
random_images, _ = draw.random_shapes(rng=1, **kwargs)
return skeletonize(random_images != 255)


@pytest.fixture()
def utils_skeleton_linear2() -> npt.NDArray:
"""Linear skeleton T-junction and side-branch."""
random_images, _ = draw.random_shapes(rng=165103, **kwargs)
return skeletonize(random_images != 255)


@pytest.fixture()
def utils_skeleton_linear3() -> npt.NDArray:
"""Linear skeleton with several branches."""
random_images, _ = draw.random_shapes(rng=7334281, **kwargs)
return skeletonize(random_images != 255)


def minicircle_dnatracing(
minicircle_grain_gaussian_filter: Filters,
minicircle_grain_coloured: Grains,
Expand Down Expand Up @@ -900,11 +911,13 @@ def _generate_random_skeleton(**extra_kwargs):
"shape": None,
"allow_overlap": True,
}
# kwargs.update
heights = {"scale": 100, "sigma": 5.0, "cval": 20.0}
random_image, _ = draw.random_shapes(**kwargs, **extra_kwargs)
kwargs = {**kwargs, **extra_kwargs}
random_image, _ = draw.random_shapes(**kwargs)
mask = random_image != 255
skeleton = skeletonize(mask)
return {"img": _generate_heights(skeleton, **heights), "skeleton": skeleton}
return {"original": mask, "img": _generate_heights(skeleton, **heights), "skeleton": skeleton}


@pytest.fixture()
Expand Down Expand Up @@ -937,13 +950,21 @@ def skeleton_linear3() -> dict:
return _generate_random_skeleton(rng=894632511, min_size=20)


# Helper functions for visualising skeletons and heights
#
@pytest.fixture()
def pruning_skeleton() -> dict:
"""Smaller skeleton for testing parameters of prune_all_skeletons(). Has a T-junction."""
return _generate_random_skeleton(rng=69432138, min_size=15, image_shape=(30, 30))


## Helper function visualising for generating skeletons and heights


# import matplotlib.pyplot as plt
# def pruned_plot(gen_shape: dict) -> None:
# """Plot the original skeleton, its derived height and the pruned skeleton."""
# img_skeleton = gen_shape()
# img_skeleton = gen_shape
# pruned = topostatsPrune(
# img_skeleton["heights"],
# img_skeleton["img"],
# img_skeleton["skeleton"],
# max_length=-1,
# height_threshold=90,
Expand All @@ -952,17 +973,23 @@ def skeleton_linear3() -> dict:
# )
# pruned_skeleton = pruned._prune_by_length(pruned.skeleton, pruned.max_length)
# fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)
# ax1.imshow(img_skeleton["skeleton"])
# ax2.imshow(img_skeleton["heights"])
# ax3.imshow(pruned_skeleton)
# ax1.imshow(img_skeleton["original"])
# ax1.set_title("Original mask")
# ax2.imshow(img_skeleton["skeleton"])
# ax2.set_title("Skeleton")
# ax3.imshow(img_skeleton["img"])
# ax3.set_title("Gaussian Blurring")
# ax4.imshow(pruned_skeleton)
# ax4.set_title("Pruned Skeleton")
# plt.show()


# pruned_plot(skeleton_loop1)
# pruned_plot(skeleton_loop2)
# pruned_plot(skeleton_linear1)
# pruned_plot(skeleton_linear2)
# pruned_plot(skeleton_linear3)
# pruned_plot(pruning_skeleton_loop1())
# pruned_plot(pruning_skeleton_loop2())
# pruned_plot(pruning_skeleton_linear1())
# pruned_plot(pruning_skeleton_linear2())
# pruned_plot(pruning_skeleton_linear3())
# pruned_plot(pruning_skeleton())


# U-Net fixtures
Expand Down
Loading
Loading