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

FIX: Miscelaneous revisions to make tests execute properly #84

Merged
merged 1 commit into from
Aug 22, 2022

Conversation

oesteban
Copy link
Member

@oesteban oesteban commented Jul 1, 2022

Although this is not going to make all tests to pass, it at least ensures tests can be executed provided with test data fount under $TEST_DATA_HOME.

This PR also fixes a bug on the AverageDWModel that resulting in the indexing error.

@pep8speaks
Copy link

Hello @oesteban! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 278:13: W503 line break before binary operator

Copy link
Collaborator

@arokem arokem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. I think that I understand this better now. In general, it seems that these model fit and predict methods should always take gradient table inputs (i.e. 4-by-n arrays). I note a place where this is not the case, and I wonder whether it should be enforced more strictly.

@@ -240,7 +240,7 @@ def predict(self, gradient, **kwargs):
class AverageDWModel:
"""A trivial model that returns an average map."""

__slots__ = ("_data", "_gtab", "_th_low", "_th_high", "_bias", "_stat")
__slots__ = ("_data", "_th_low", "_th_high", "_bias", "_stat")

def __init__(self, gtab, **kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to also remove the gtab input here?

Suggested change
def __init__(self, gtab, **kwargs):
def __init__(self, **kwargs):

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If yes, don't forget to remove it in the docstring as well.

self._th_low = kwargs.get("th_low", 50)
self._th_high = kwargs.get("th_high", self._gtab[3, ...].max())
self._th_high = kwargs.get("th_high", 10000)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is just a toy model, but we might want to document the default values for these, in case they get inherited into other places.

)
tmodel_2000 = model.AverageDWModel(
gtab=gtab, bias=False, th_high=2000, th_low=1000
gtab=gtab, bias=False, th_high=2000, th_low=900, stat="mean",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! I just noticed that the default statistic for the "mean" model is the median. Isn't that a bit confusing?


# Verify that the right statistics is applied and that the model discard b-values < 50
assert np.all(tmodel_mean.predict() == np.mean(gtab_w25[:, :2], axis=0))
assert np.all(tmodel_median.predict() == np.median(gtab_w25[:, :2], axis=0))
assert np.all(tmodel_mean.predict([0, 0, 0]) == 950)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the input to predict supposed to be a gradient table? That is, a 4-by-n array? Why does it accept a 3-vector?

@oesteban
Copy link
Member Author

oesteban commented Jul 6, 2022

Thanks for the review, I haven't had time to come back to it, but will ASAP! Sorry for the slow response. Overall, all you said seems very sensible.

@arokem
Copy link
Collaborator

arokem commented Aug 22, 2022

I will go ahead and merge this, so that we can keep working on this on our end with functioning tests. We can come back and fix my comments on a separate PR.

@arokem arokem merged commit b0ffc33 into main Aug 22, 2022
@oesteban oesteban deleted the fix/revise-tests branch August 23, 2022 10:02
@oesteban
Copy link
Member Author

Thanks, I'm coming back to this tomorrow and finishing up whatever is still missing. Running tests locally right now after merge.

oesteban added a commit that referenced this pull request Aug 25, 2022
Drops the use of a real AFNI series of transforms. Instead, generate a
number of large-yet-plausible transformations for head motion.

Follow-up: #84.
Part-of: #40.
oesteban added a commit that referenced this pull request Aug 25, 2022
Drops the use of a real AFNI series of transforms. Instead, generate a
number of large-yet-plausible transformations for head motion.

Follow-up: #84.
Part-of: #40.
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.

3 participants