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

allow any object with render method to be used for label distribution #83

Merged
merged 2 commits into from
Nov 9, 2024

Conversation

tlambert03
Copy link
Owner

fixes #82

this lets any object that implements a render() method be used as a fluorophore distribution object (via duck typing). which should make things like @melisande-c's kymograph generation easier to use without using from_ground_truth

class MyCustomDistribution:
    def render(self, space, xp: ms.NumpyAPI | None = None):
        # ...
        return space

sim = ms.Simulation(
    truth_space=ms.ShapeScaleSpace(shape=(64, 128, 128), scale=(0.2, 0.1, 0.1)),
    output_space={"downscale": 1},
    sample=ms.Sample(labels=[MyCustomDistribution()]),
)

it also exposes BaseDistribution publicly ... so if you prefer to subclass (rather than rely on Protocols and duck-typing) then you can.

@melisande-c, let me know if this would help out in your case

Copy link

codecov bot commented Oct 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.90%. Comparing base (9669067) to head (cd9ecff).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #83      +/-   ##
==========================================
+ Coverage   84.82%   84.90%   +0.08%     
==========================================
  Files          47       47              
  Lines        3130     3147      +17     
==========================================
+ Hits         2655     2672      +17     
  Misses        475      475              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@melisande-c
Copy link

@tlambert03 Amazing! Thanks so much, this is what I exactly what I meant. I will let you know how integrating it with my work goes, it might still be a little tricky with the time component, I might be asking some questions soon! 😄

@melisande-c
Copy link

@tlambert03 just to let you know, I successfully created my own custom distributions! and it was pretty easy to move the time loop outside of the the distribution initialisation

@tlambert03 tlambert03 merged commit 707981a into main Nov 9, 2024
17 of 18 checks passed
@tlambert03 tlambert03 deleted the fix-dist branch November 9, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make it easier to provide custom ground truth (Distribution) objects
2 participants