-
Notifications
You must be signed in to change notification settings - Fork 14
support for multiple slice positions in 2D heatmaps with automatic layout #87
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
base: main
Are you sure you want to change the base?
Conversation
- Allow position parameter to accept a list of positions in 2D format - Generate plt.Figure with up to 25 positions each in a grid layout. - Add validations to decrease some human error. - Add some assert for mipy, self.slicer depends on position parameter value(s) and can be None
- remove filename from example
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #87 +/- ##
==========================================
- Coverage 70.03% 63.17% -6.86%
==========================================
Files 5 5
Lines 327 372 +45
==========================================
+ Hits 229 235 +6
- Misses 98 137 +39 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Ready for review, will leave it as draft for now.
Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @zenWai
Sorry that other work commitments and Easter holidays have meant it's taken me a long time to look at this.
In general, I like that this PR makes it a lot easier for users to make 2D subplots in a standard way! I've made some nitpicky comments (sorry!) and asked some clarifying questions :)
My two-cents on your questions:
The self.slicer initialization as None followed by conditional assignment, this pattern feels a bit awkward but I'm not sure of a better approach.
An alternative approach I can think of is that in the 2D case, self.slicer
is always a list, and we cover the current case by making it a list of length 1 when users pass a single value. That way, we don't need self.multiple_slicers
, and internally always make the code iterate over self.slicer
- what do you think?
Using position values as default titles when self.title is None, feels a bit akward and is confusing, at same time I see value on users understanding what they're looking at and a better way to handle all choices does not come to my mind.
Currently self.title=None does default title with positions, self.title="" would have empty title, self.title="title" makes all subplots with given title wich is akward, maybe.
Probably could make self.title give a title for the figure instead?!
I don't mind position values as default titles or empty title as is now - I think this is fine.
But 25x the same title is definitely NOT what we want. So I would vote to make self.title
be a title for the figure by default? Given that IIUC the PR is backwards compatible, if people want more control over subplot titles they can script that as they could before in the old example?
@@ -127,6 +127,7 @@ def __init__( | |||
magnitudes as the values. | |||
position : list, tuple, np.ndarray, float | |||
Position of the plane in the atlas. | |||
list of positions create multiple slices. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list of positions create multiple slices. | |
List of positions create multiple slices. |
typo.
"List of positions not supported in 3D format. " | ||
"Did you mean to use a tuple as a 3D position?" | ||
) | ||
if len(position) <= 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be OK to pass a list of length 1 (but not an empty list)? If you agree, please adapt accordingly?
@@ -275,6 +297,9 @@ def show(self, **kwargs) -> Union[Scene, plt.Figure]: | |||
Creates a 2D plot or 3D rendering of the heatmap | |||
""" | |||
if self.format == "3D": | |||
assert ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a case where self.slicer
is ever still None
after running __init__
? I don't see it, so not sure this is needed?
# Create a list of scenes to plot | ||
# Note: it's important to keep reference to the scenes to avoid a | ||
# segmentation fault | ||
scenes = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe still worth keeping this example too, for advanced users (like when users want more control over figure size, or more than 25 subplots... or something else) to have more flexibility?
Hey @zenWai - let us know whether you're planning to respond/address my comments (no rush - it took me long enough to even get to review! 😅) or you'd like the core team to take this on (when they find time) |
Thanks for the pings, I will revisit it this weekend, I believe I want to
For sure, this sounds like a good approach, I will implement it and see if I run into any edge issues.
Sounds good, I will make the self.title provide a title for the figure would make things easier and makes sense. I will take a full look this next weekend hopfully have it ready with tests👋 |
Description
What is this PR
Why is this PR needed?
solves #54
What does this PR do?
Example
Is this a breaking change?
No
Does this PR require an update to the documentation?
no
Checklist: