-
Notifications
You must be signed in to change notification settings - Fork 386
Adding quilt viewer to visualize how FOV is broken up into patches #1156
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
Conversation
Note the natural names for these are patches: in the paper and code we talk about splitting the FOV into patches with stride and overlap. Unfortunately there are already a bunch of patch plotting functions that are for plotting contours of spatial components. Luckily mesmerize had a great name for it: quilt! I have to admit I just recently turned the corner on type hinting because of @pgunn . A couple of notes: I went ahead and used matplotlib/matplotlib#20504 In particular, eventually we'll want to replace For array-like things numpy's |
caiman/utils/visualization.py
Outdated
col_minmax: array-like | ||
[col_min, col_max] -- int bounds for rect cols | ||
color : string | ||
rectangle color, default 'yellow' |
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.
Can we stick a link in here indicating what colours are valid?
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.
Good catch. I shouldn't have specified string there. Any Matplotlib color specification, e.g., rgb tuple or list, or string 'red'
is fine (https://matplotlib.org/stable/tutorials/colors/colors.html). I should probably just put Any
for this, and be more clear in docs.
rectangle color, default 'yellow' | ||
alpha : float | ||
rectangle alpha (0. to 1., where 1 is opaque), default 0.3 | ||
ax : pyplot.Axes object |
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.
Eventually we'll want to add proper typing for this, but no rush
caiman/utils/visualization.py
Outdated
""" | ||
Plot patches on template image given stride and overlap parameters. | ||
|
||
Given stride and overlap, plot overlapping patch blocks on template image. |
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.
Seems to have some redundancy between the 1-sentence and longer description; is this because some tool treats those as separate?
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.
Yes this is sort of silly. I can just combine them.
caiman/utils/visualization.py
Outdated
row x col summary image upon which to draw patches (e.g., correlation image) | ||
stride (int) stride between patches in pixels | ||
overlap (int) overlap between patches in pixels | ||
color (str): color of patches, default 'white' |
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.
probably no need to mention default when it's visible in params.
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.
This is debated all over the place. I've noticed in our code we have it in both places, so I've done this too. But it is a maintenance headache and is asking for trouble/inconsistencyes. Happy to stop doing it moving forward.
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.
It's not really a big deal either way, it's just another thing to maintain if it changes in one place.
caiman/utils/visualization.py
Outdated
alpha: Optional[float]=0.3, | ||
vmin: Optional[float]=0.0, | ||
vmax: Optional[float]=0.6, | ||
figsize: Optional[Tuple]=(6,6)) -> Any: |
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 this Optional[Tuple[float,float]] or Optional[Tuple[int,int]]?
The default seems to disagree with the comment section
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.
Good catch, fixing (it's float,float)
caiman/utils/visualization.py
Outdated
axes object upon which rectangle will be drawn, default None | ||
|
||
Returns: | ||
ax (Axes object) |
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.
If we don't want to specify types for these, can we say a little bit more about what we expect them to be? matplotlib.axes?
caiman/utils/visualization.py
Outdated
ax (Axes object) | ||
rect (Rectangle object) | ||
""" | ||
from matplotlib.patches import Rectangle |
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.
Imports don't go in methods/functions; please move this to the head of the file
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.
Fixing
Description
Adds functionality to visualize overlapping patches that split up field of view for motion correction and cnmf for parellelization. Useful when picking different spatial parameters (
rf/stride/gSig/gSiz
for 8000 cnmf, andstrides/overlaps
for motion correction).Thanks to @kushalkolar (mesmerize) for idea of
quilt
name, aspatches
is already used for viewing spatial contours.Fixes #1116
Type of change
Has your PR been tested?
I ran the tests there are no new errors introduced in dev branch. I have tested the plotting functionality fairly extensively, have not yet added new tests to
caiman/tests