-
Notifications
You must be signed in to change notification settings - Fork 84
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
[GENFI] Converter improvements #909
[GENFI] Converter improvements #909
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.
Thanks @MatthieuJoulot !
I made a few suggestions to improve readability of the code.
More generally, I think we need to do two things:
- Add more documentation to functions that you added.
- Add unit tests for them (you'll have a generate fake dataframes for this)
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
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.
Thanks @MatthieuJoulot !
Some suggestions to improve readability and maintainability.
Please fully update the helper function or use my suggestion. Doing it half way results in documentation and examples that are wrong compared with the function's behavior. Moreover, you'd need to update the variable names (like first_scan_flags
) to convey the right idea, otherwise it is extremely misleading...
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Gensollen <[email protected]>
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.
Thanks @MatthieuJoulot !
This is looking good.
I made some new suggestions to simplify things a bit more.
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
test/unittests/iotools/converters/genfi_to_bids/test_genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Gensollen <[email protected]>
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.
Thanks for adding unit tests @MatthieuJoulot ! 👍
Just a couple small suggestions for these tests.
test/unittests/iotools/converters/genfi_to_bids/test_genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
) | ||
], | ||
) | ||
def test_compute_runs(input, expected): |
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.
The idea of pytest's parametrize is to provide multiple inputs for which the test function will be executed. If you only have a single input and single expected value, this is overkill.
In this situation, you have basically two main options:
- If you don't need the input data for other tests, just define it within the test function and use it there (I think this is your situation here)
- If you need the data for multiple tests, you can define a fixture:
@pytest.fixture
def input_df():
return pd.DataFrame(....)
def test_compute_runs(input_df):
# you can use input_df here
def test_compute_runs_2(input_df):
# you can also use input_df 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.
Thanks @MatthieuJoulot !
This looks good. I made a few small suggestions but otherwise seems ready to me.
test/unittests/iotools/converters/genfi_to_bids/test_genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
test/unittests/iotools/converters/genfi_to_bids/test_genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
test/unittests/iotools/converters/genfi_to_bids/test_genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
test/unittests/iotools/converters/genfi_to_bids/test_genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
test/unittests/iotools/converters/genfi_to_bids/test_genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Gensollen <[email protected]>
@NicolasGensollen Just did a PR#32, that contains the new CI data for this converter. |
Great ! Thanks ! clinica/test/nonregression/iotools/test_run_converters.py Lines 210 to 213 in 268b64c
|
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.
Thanks @MatthieuJoulot !
I made a couple formatting suggestions but everything LGTM otherwise.
I have merged the linked data PR and updated the datasets on the CI machines, so all tests should pass now. If they do pass as expected, I think this can be merged.
clinica/iotools/converters/genfi_to_bids/genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
test/unittests/iotools/converters/genfi_to_bids/test_genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
test/unittests/iotools/converters/genfi_to_bids/test_genfi_to_bids_utils.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Gensollen <[email protected]>
The purpose of this PR is to improve the
genfi-to-bids
converter.To do so, different things are to be done:
-mcd
ormore_clinical_data
is to be a tsv specifying the additionnal data the user wants.Not WIP anymore ! It is pressing that we handle the things currently handled (1 and 3). The rest can be done later on.