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

[GENFI] Converter improvements #909

Merged
merged 32 commits into from
May 11, 2023

Conversation

MatthieuJoulot
Copy link
Contributor

@MatthieuJoulot MatthieuJoulot commented Apr 13, 2023

The purpose of this PR is to improve the genfi-to-bids converter.

To do so, different things are to be done:

  • Improve verbosity. Right now it doesn't say anything which can be frightening to the user since the conversion takes time.
  • Handle different ways of downloading the data or indicate the precise way to get them
  • Open the number of runs to more than 2. Sometimes 3 or 4 can be found.
  • Solve the problem of DTI sequences acquired with a Philips machine.
  • Option to get more clinical data then what is already given. -mcd or more_clinical_data is to be a tsv specifying the additionnal data the user wants.
  • Option to choose modalities to be converted.
  • Option to choose the subjects and sessions to be converted.

Not WIP anymore ! It is pressing that we handle the things currently handled (1 and 3). The rest can be done later on.

@MatthieuJoulot MatthieuJoulot marked this pull request as ready for review April 20, 2023 15:21
Copy link
Member

@NicolasGensollen NicolasGensollen left a 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)

Copy link
Member

@NicolasGensollen NicolasGensollen left a 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...

Copy link
Member

@NicolasGensollen NicolasGensollen left a 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.

Copy link
Member

@NicolasGensollen NicolasGensollen left a 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.

)
],
)
def test_compute_runs(input, expected):
Copy link
Member

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

Copy link
Member

@NicolasGensollen NicolasGensollen left a 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.

@MatthieuJoulot
Copy link
Contributor Author

@NicolasGensollen Just did a PR#32, that contains the new CI data for this converter.

@NicolasGensollen
Copy link
Member

@NicolasGensollen Just did a PR#32, that contains the new CI data for this converter.

Great ! Thanks !
Shouldn't we update the functional tests to use this updated version and verify the added functionalities ?
Probably here:

def run_genfitobids(
input_dir: PathLike, output_dir: PathLike, ref_dir: PathLike
) -> None:
from pathlib import PurePath

Copy link
Member

@NicolasGensollen NicolasGensollen left a 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.

@NicolasGensollen NicolasGensollen merged commit c30f8c2 into aramis-lab:dev May 11, 2023
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.

2 participants