-
Notifications
You must be signed in to change notification settings - Fork 76
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
[FIX] ADNI-to-BIDS fmap conversion : delete real/imaginary files properly, enable converting to the same folder for fmap #1198
[FIX] ADNI-to-BIDS fmap conversion : delete real/imaginary files properly, enable converting to the same folder for fmap #1198
Conversation
9081e16
to
56db7a4
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.
Thanks @AliceJoubert !
Just two very small suggestions but LGTM otherwise.
Thanks for the review @NicolasGensollen ! I modified the code as suggested and also added the same kind of logic to delete files with invalid suffixes. Do you see anything else that could be improved ? |
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 @AliceJoubert !
I think the PR looks good but it'd be awesome to add some unit tests covering the file filtering and removal logic. A possible approach that I'm suggesting here is to isolate the related code in one or two helper functions and add unit tests for those.
Let me know what you think !
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 @AliceJoubert !
This is looking good ! Just a few small suggestions on the organization of these helper functions.
Thanks for the suggestions @NicolasGensollen ! I modified the code according to them. Do you see anything else ? |
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 @AliceJoubert !
I think this is almost ready. 👍
I have a small suggestion for the API of one of the helper functions (sorry for initially suggesting something different), as well as some minor suggestions to simplify the tests.
folder: Path, | ||
suffixes: Iterable[str], | ||
mod_to_update: bool = False, | ||
) -> bool: |
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.
Sorry, I know I asked for this, but re-looking at this, I think it would be more consistent to have this function return the list of files that were removed. This would offer the same API as _remove_files_with_unsupported_suffixes
and the caller code would be pretty much the same.
So it'd be something like:
...
-> Iterable[Path]:
from clinica.utils.stream import cprint
if images_to_remove := _get_images_with_suffix(folder, suffixes):
if mod_to_update:
cprint(...)
for path_to_unlink in images_to_remove:
(path_to_unlink).unlink()
else:
cprint(f"There already exist images :...")
return images_to_remove
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.
No worries @NicolasGensollen ! Thanks for the comments.
The thing is, I can't use the output of that function by itself if I want to get out of the create_file
function since it's totally possible for it to return either an empty or an actual list while we need the process to continue.
If we want to get the images_to_remove list we could call _get_images_with_suffix
separately and keep a function returning a flag to know if we continue the process. WDYT ?
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.
Indeed, you're totally right !
Let's forget about this comment and keep things like this.
Sorry for the noise.
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.
Did you commit the suggestions on the tests ? I see the conversations resolved but not the commits and modifications.
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.
My bad, I was waiting for your answer before committing the other changes. You should see them now @NicolasGensollen
test/unittests/iotools/converters/adni_to_bids/test_adni_utils.py
Outdated
Show resolved
Hide resolved
test/unittests/iotools/converters/adni_to_bids/test_adni_utils.py
Outdated
Show resolved
Hide resolved
test/unittests/iotools/converters/adni_to_bids/test_adni_utils.py
Outdated
Show resolved
Hide resolved
test/unittests/iotools/converters/adni_to_bids/test_adni_utils.py
Outdated
Show resolved
Hide resolved
test/unittests/iotools/converters/adni_to_bids/test_adni_utils.py
Outdated
Show resolved
Hide resolved
test/unittests/iotools/converters/adni_to_bids/test_adni_utils.py
Outdated
Show resolved
Hide resolved
test/unittests/iotools/converters/adni_to_bids/test_adni_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.
LGTM, thanks @AliceJoubert !
This PR proposes small changes to allow :