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
[ENH] Handle GLM designs with null or nan durations / onsets #3943
Conversation
👋 @Remi-Gau Thanks for creating a PR! Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft. Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.
For new features:
For bug fixes:
We will review it as quick as possible, feel free to ping us with questions if needed. |
to be merged after #3939 is merged |
Codecov Report
@@ Coverage Diff @@
## main #3943 +/- ##
==========================================
+ Coverage 91.75% 91.79% +0.03%
==========================================
Files 134 134
Lines 15751 15772 +21
Branches 3283 3284 +1
==========================================
+ Hits 14453 14478 +25
+ Misses 753 751 -2
+ Partials 545 543 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 4 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
8aa3af7
to
a6b848a
Compare
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.
LGTM so far, thx.
Maybe having this occur once in the doc is a good idea (rather than testing). |
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.
LGTM! While reviewing this, I was looking at plot_event
function example in the docs and in the user guide there is a link to an example that shows its use but the wrong example is linked. It is a small change so maybe it can be done here.
This is referring to this section https://nilearn.github.io/dev/glm/first_level_model.html#event-based in the paragraph right after the bullet points where this example is linked Decoding of a dataset after GLM fit for signal extraction but it should be this one Generate an events.tsv file for the NeuroSpin localizer task
@@ -19,27 +19,25 @@ | |||
|
|||
print(__doc__) | |||
|
|||
######################################################################### | |||
# %% |
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.
Done. Thanks for catching this one. |
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.
Please add a whatsnew entry, even if this is a limited change.
Thx,
OK I was not 100% sure about this one. Will do. |
doc/changes/latest.rst
Outdated
@@ -54,6 +54,7 @@ Enhancements | |||
Changes | |||
------- | |||
|
|||
- :func:`~glm.first_level.experimental_paradigm.check_events` will now throw a warning if some events have a 0 second duration and will throw an error if an event has ``NaN`` onset or duration (:gh:`3943` by `Rémi Gau`_). |
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.
:func:~glm.first_level.experimental_paradigm.check_events
and
:func:~glm.first_level.check_events
give me the same doc build error.
Am I missing something obvious?
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.
check_events
is not exposed in the docs so there is nothing to link to. I'm not sure if it is supposed to be part of the public API or not. If so, it would need to be added to doc/modules/glm.rst
first before you can use that role
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 wouldn't put it in the public API.
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.
Then we just refer to it with the backticks without the func role
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.
Wait... Just to make sure I understand.
What is the rationale of saying it is not in the public API but check_design_matrix is when both of them are found this init file?
https://github.com/nilearn/nilearn/blob/main/nilearn/glm/first_level/__init__.py#L24
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.
As the codebase stands I wouldn't take what is in the init file for what is in the public API and supposed to be exposed to users since we know there is heterogeneity in the way "private" functions are written and also, we can have public API of a private module so that would be ok to include in the init. I agree though that given the refactoring we are doing regarding this, check_events should either be in a file named with a leading underscore or, since it is only used in design_matrix.py, it can be moved there and renamed with a leading underscore. I don't see that, following this convention, it would then be a problem if it is imported in a module's init file since it'll be clear from the import statement, which would then have a leading underscore, that it is private. This is what I understand from PEP8, though we may also want to make a decision on that aspect if it's confusing.
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 thanks for the clarification.
OK so for the moment it really feels the public API is whatever the doc days is in the public API. Hopefully things should get clearer once we clean things up.
For now I will use the backticks without the func role.
Changes proposed in this pull request: