Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Voxelwise glm residuals/R2 #173

Closed
wants to merge 218 commits into from
Closed

Conversation

Gilles86
Copy link
Contributor

This commit makes it possible to calculate voxelwise residuals and R-squareds for a given GLM. Note that you can only do so when the "full" RegressionResults are returned (by setting minimize_memory of the FirstlevelModel to False). When this is asked from a SimpleRegressionResults, an exception with explanation is thrown.

I also fixed this issue:
https://github.com/nistats/nistats/issues/150

@Gilles86 Gilles86 changed the title Voxelwise glm stats Voxelwise glm residuals/R2 Mar 16, 2018
@bthirion
Copy link
Member

I'll check more in detail tomorrow -- hopefully-- but you need to add test for these functionalities to ensure that they work properly.

@KamalakerDadi
Copy link
Contributor

If I understood correctly, you are trying to fix two issues in the same PR. It makes reviewing harder. I think it is better to fix one issue in a PR. My general comment.

@Gilles86
Copy link
Contributor Author

If I understood correctly, you are trying to fix two issues in the same PR. It makes reviewing harder. I > think it is better to fix one issue in a PR. My general comment.

OK, I made a separate pull request for that #174

@Gilles86
Copy link
Contributor Author

I'll check more in detail tomorrow -- hopefully-- but you need to add test for these functionalities to ensure that they work properly.

OK. I added some tests in last commit.

else:
return output

@property
Copy link
Member

Choose a reason for hiding this comment

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

We tend to avoid properties, which makes the code hard to undertand and debug.


@setattr_on_read
@property
def resid(self):
Copy link
Member

Choose a reason for hiding this comment

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

residuals. I would not make it a property.

@@ -310,28 +311,35 @@ def norm_resid(self):
"""
return self.resid * pos_recipr(np.sqrt(self.dispersion))

@setattr_on_read
@property
Copy link
Member

Choose a reason for hiding this comment

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

Same comment.

# assert that we only have one theta as there is only on voxel in our image
assert_true(first_level_model.results_[0][0].theta.shape == (1, 1))
# assert that the theta is equal to the one voxel value
#def test_high_level_glm_one_session():
Copy link
Member

Choose a reason for hiding this comment

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

Please do not leave commented code:

@jdkent
Copy link
Contributor

jdkent commented Nov 5, 2018

@Gilles86: Do you still have time to work on this?

Just an interested third party since I would be rather happy to investigate regional model fit using nistats.

@Gilles86
Copy link
Contributor Author

Gilles86 commented Nov 6, 2018

Hey @jdkent ,

Yes. Time is always so precious, since so much is expected from new postdocs. I would still really like to finish this sometime soon though. Your ping motivates me to put it on my todo for the coming weeks again :).

tsalo added 12 commits December 7, 2018 15:13
- Don’t report peaks in matrix space.
- Report cluster size in mm3 instead of voxels.
- Report top 3 subpeaks more than 8mm separated when available.
- Add argument for voxel-connectivity for cluster definition.
Also, I removed the connectivity argument for get_clusters_table. I
kept the separate neighborhood matrix function (`_get_conn`), just in
case.
Currently, it uses 6-connectivity (aka NN1, faces-only connectivity, or
first-nearest neighbor clustering).
Also, I’ve made the subpeak detection explicitly work around binary
clusters. Now it just reports the center of mass.
Numpy did not have `cbrt` function in 1.8.2, the version used for
Python2.7 CI.
_local_max now checks distance between subpeaks explicitly, since the
approach used in the StackOverflow post wasn’t quite doing it.
- Use minimum distance in millimeters in _local_max.
    - Requires including the image affine in the arguments as well.
    - Should also be robust to non-isotropic voxels.
- Add min_distance argument to get_clusters_table, for minimum distance
in millimeters. Default is 8mm.
- Address PEP8 problems.
@Gilles86
Copy link
Contributor Author

Gilles86 commented Dec 7, 2018

OK. I rebased and revised the code a bit.

I notice that in the regression-module, the setattr_on_read-class attribute is now used. E.g., here:
https://github.com/nistats/nistats/blob/d97ea36198fe36c8846dd98c3c8118f3ed27080c/nistats/regression.py#L286

I thus now also used it in the FirstLevelModel-object

@kchawla-pi
Copy link
Collaborator

Hey @Gilles86 thanks so much for attending to this. It has been a while so the conflicts in master might take more work than usual to resolve. Let me know if I can help.

@Gilles86
Copy link
Contributor Author

Gilles86 commented Dec 7, 2018

Yes. I'm sorry that the commit history got a bit messy. I'm not very used to work with multiple branches like this. We'll get there though.

@Gilles86
Copy link
Contributor Author

Gilles86 commented Dec 7, 2018

Yup. Tests passed. Anyone?

@kchawla-pi
Copy link
Collaborator

kchawla-pi commented Dec 7, 2018

The good news is CI is green. The not yet good news is the commit history now makes it impossible to review.
We'll figure out how to fix that. I made this mistake as well once (so far) as a contributor. #gitlife
@Gilles86
Could you write the exact command you used here to bring your branch up to date with master?
Your other PR #174 also has this problem, could you type the commands you used to update that one as well?
Update: Okay well maybe not impossible, but if this can e cleaned up we should do that.

@Gilles86
Copy link
Contributor Author

Gilles86 commented Dec 7, 2018

I'm sorry. I'm learning.

I made a clean version of this pull request:
#298

@kchawla-pi
Copy link
Collaborator

Hey @Gilles86 that's totally fine, you are helping us out here.
Thanks for this!

@kchawla-pi
Copy link
Collaborator

@Gilles86 Never mind the cleaned up one. let's continue working here. I was concerned about GIthub showing number of files changed to be 49 something (which was in your other PR and makes it very difficult to review) but in this one it's showing the files pertinent to this PR only so it's fine.

Bertrand reviewed the PR earlier, we can start by working on those.

jdkent pushed a commit to jdkent/nistats that referenced this pull request Nov 20, 2019
jdkent pushed a commit to jdkent/nistats that referenced this pull request Nov 20, 2019
@jdkent jdkent mentioned this pull request Nov 20, 2019
@kchawla-pi kchawla-pi closed this Dec 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants