-
Notifications
You must be signed in to change notification settings - Fork 58
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
[FIX,REF] start changing how to handle resampling #439
Conversation
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.
One minor change that will hopefully fix the tests, and one other thing I think we should discuss before merging.
Codecov Report
@@ Coverage Diff @@
## master #439 +/- ##
==========================================
+ Coverage 82.50% 82.56% +0.06%
==========================================
Files 40 40
Lines 3892 3907 +15
==========================================
+ Hits 3211 3226 +15
Misses 681 681
Continue to review full report at Codecov.
|
The docs failure seems to be the random bug documented in #418. I still don't have a solution, so I think we can just restart the CI and it might go away. |
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.
Looks good, with exception of one minor tweak to the logic when passing resample__
kwargs. (I left a couple of other comments you can respond to or ignore as you see fit).
nimare/base.py
Outdated
self.resample = kwargs.get("resample", False) | ||
|
||
# defaults for resampling images (nilearn's defaults do not work well) | ||
self.resample_kwargs = { |
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.
Do we want to expose these to users? If not, maybe self._resample_kwargs
? I forget what the conventions we're using are; if this is how we're doing it elsewhere, then it's fine this way.
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 do not think I want to expose this to users, and yes you are right that appears to be the convention, changed!
nimare/base.py
Outdated
|
||
# defaults for resampling images (nilearn's defaults do not work well) | ||
self.resample_kwargs = { | ||
k.split("resample__")[1]: v for k, v in kwargs.items() if k.startswith("resample__") |
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 the or
here will force the user to specify both arguments even if they only want to override one default (and they may not realize that, which is likely to lead to unintended behavior). Probably better to create the default dict
and then update it with any matching argument names in kwargs
.
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.
great point, changed it so there is a default dict and arguments can update that dict.
nimare/base.py
Outdated
if not self.resample: | ||
check_imgs = {img: nb.load(img) for img in self.inputs_[name]} | ||
check_imgs["reference_masker"] = mask_img | ||
_check_same_fov(**check_imgs, raise_error=True) |
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 pretty trivial, and would only slightly improve readability, but to save the del
call later you could just pass reference_masker
as an argument directly to _check_same_fov
instead of adding it to check_imgs
, since you remove it right away
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.
clean code is happy code :), changed.
- change resample_kwargs to _resample_kwargs - improve readability of _check_fov - update instead of overwrite defaults
Closes #438
Changes proposed in this pull request:
fit
method or should we make it a part of initializing the estimator object so the user's decision is saved in a more permanent way? and to keep thefit
method clean)