-
Notifications
You must be signed in to change notification settings - Fork 0
Align function outputs with the MATLAB version #6
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…s have beeen updated to bettter align with the matlab verison (NanoLocz library). True-False convetion has also been aligned. Docstrings at all levels have been updated to explain the alignment with matlab and where differences may remain. Expect test breakage.
…s where True reprisents the pixels to be excluded from leveling in level and level_weighted and False is valid/included pixels. Updated docstrings to reflect this too.
…were aligned with the MATLAB funciton, updated so that masks from threshold work correctly and docstrings updated.
…ing and also calculating gaussian limits and well as updateing some routines to match the matlab Nanolocz
…ocz-Library into align_with_matlab
…t used as indices. Swapped the min_size argument for remove_small_objects in thresholder to max_size asmis_size is depreciateing. Pinned scikit-image to scikit-image>=0.26,<0.27 iin pyproject.toml
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6 +/- ##
==========================================
- Coverage 96.64% 90.55% -6.10%
==========================================
Files 5 5
Lines 776 942 +166
==========================================
+ Hits 750 853 +103
- Misses 26 89 +63 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ile which supresses other warnings.
…nd use this to expand level_auto tests.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
Using a MATLAB test script that runs Python functions within it, I've tried to align the output
of the Python verison of the Nanolocz library with the output of the Python verison.
This PR substantially improves MATLAB alignment, correctness, and documentation
of the Python NanoLocz leveling pipeline, with a particular focus on mask semantics,
numerical parity, and automated routines.
Key changes
1. MATLAB-aligned mask semantics across all leveling methods
thresholdermodule generate exclusion masks (True = excluded)where data is 'masked' or edges highlighted, this sets the interpretation for downstream functions.
_validity_maskhelper to consistently convert publicexclusion masks (
True = excluded) into internal validity masks(
True = valid).matching MATLAB behaviour more closely and eliminating subtle inconsistencies
between methods.
2. Numerical parity improvements in core levelling routines (
level.py)standard deviation (
ddof=0), matching MATLAB’spolyfit(..., mu)behaviour.plane,line,med_line,med_line_y,smed_line, andmean_planeto:(
polyy > 0) and median fallback logic.3. Correct and complete implementation of automated routines (
level_auto.py)multi-plane-edgesandmulti-plane-otsu, replacing“not yet implemented” placeholders.
previously absent, resolving observed discrepancies.
med_linepreconditioning, mirroring MATLAB’sadaptive behaviour.
gauss1) for adaptivethreshold bounds, with explicit documentation of the remaining frame-wise vs
stack-wise difference.
4. API clean-up and consistency
apply_thresholder(updated README and internal usage).
level,level_weighted,thresholder, andlevel_auto.5. Documentation and citation improvements
CITATION.cfffile to support proper software citation.level.pyandlevel_auto.py, clearly documenting MATLAB alignment goals and knowndeviations.
Overall impact
This PR moves the Python NanoLocz library from “functionally similar” to
algorithmically aligned with the MATLAB reference, especially for automated
Levelling workflows. It reduces hidden numerical drift, clarifies intended
Behaviour, and makes future validation and extension much easier.