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
BF: SFM prediction with mask #2041
Conversation
@arokem - this is great! are there any further optimizations that can be made in runtime for the predict method of isotropic specifically? (Or maybe a better question would be what particular lines take the longest to run at the moment?) |
Codecov Report
@@ Coverage Diff @@
## master #2041 +/- ##
==========================================
+ Coverage 91.13% 91.15% +0.01%
==========================================
Files 246 246
Lines 31546 31611 +65
Branches 3307 3314 +7
==========================================
+ Hits 28750 28815 +65
Misses 2081 2081
Partials 715 715
|
@dPys : without a doubt, the most time is spent in this line: https://github.com/dipy/dipy/blob/master/dipy/reconst/sfm.py#L433, which is where sklearn's ElasticNet fit is being called. Unfortunately, I don't think there's much we can do about it. |
@arokem - A few more questions:
And curious to hear from anyone else who might want to chime in. |
This was previously broken, because of the way the isotropic model handles the mask.
Singleton cases.
ba0ea83
to
c2dbaa8
Compare
That depends on the data. In my experience, signal prediction can be almost equally accurate with various ratios, leading to quite different fODFs.
Yes. As suggested by @mattcieslak, one way to make this go much faster is to provide an initialized sklearn Ridge object as the input to the
I am not sure. There might be different levels of regularization that work better in different tissue types, but it would require quite a bit of empirical work to sort this out. I would be inclined to first try one ridge regularization parameter everywhere and see how that works. |
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.
Hi @arokem, Overall it looks good but there is only one thing I do not get. See below.
if mask is None: | ||
mask = np.ones(data.shape[:-1], dtype=bool) | ||
# Turn it into a 2D thing: | ||
if len(mask.shape) > 0: |
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 do not understand this part. Can you tell us more about this part?
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 just to deal with the (rather unusual) case that your data is a one-dimensional vector representing one voxel's worth of data. In that case, data.shape[:-1]
is ()
and you might run into trouble here.
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.
ok, I see, thanks. I wonder if there is a better way to do that but It is fine like this too
Anyone to review this PR? Do you want to have a last look @dPys? I will wait until Sunday to merge it. |
ok, Thanks @arokem, merging |
This fixes a bug in the way that SFM does signal prediction when fit with a mask. This is something I just stumbled upon earlier today while I was working with @dPys on nipreps/dmriprep#62. This should fix the issues we were seeing there.