-
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
Add FMAP conversion capability for ADNI #1119
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 for the PR @tharpm95 !
I started reviewing it but stopped about halfway. I think there are some important points we need to tackle:
- First of all, the PR is huge and I believe this is mostly due to changes that are unrelated to the functionality you are adding. For example, changing the way CSV files are loaded, or changing the n_jobs option. It is clearly visible when looking at the number of files that are modified (basically all modalities of ADNI were modified while this PR is supposed to add a new one).
- These unrelated changes are actually undoing things that we did in the recent past (and for good reasons). If you are having issues with some of them, please open a dedicated issue such that we can work on what's going wrong.
I think we should remove all of these unrelated changes to focus on the core of your proposal. On this subject, I was mainly concerned with the giant for loop renaming files (see comment below).
It could be helpful to have a small toy dataset on which we could try the converter.
Do you have a small list of ADNI subjects you used to work on this ?
Do not hesitate if some points are unclear.
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_fmri.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_fmri.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_t1.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_t1.py
Outdated
Show resolved
Hide resolved
Apologies for this, you are correct that some changes are unrelated to the specific feature. I will work on removing them and open an issue related to the miscellaneous changes I made (mostly related to an issue where my CSV files contained double quotes which interfered with parsing)
I do have a small set of ADNI subjects I used for this. I used a set of approximately 30 of the most recent scans. I can share these IDs if needed or use another list of subjects if you prefer.
Thank-you, noted! |
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 your quick response @tharpm95 ! 👍
The diff is already much easier to make sense of. It is still pretty huge in adni_utils.py
and I'm not sure to understand why (will try to have a closer look soon).
I made another quick pass with some questions and suggestions along the way.
From what I understand from #1136, you were having some issues with additional double quotes in the CSV files but the load_clinical_csv()
function seems to be solving the problem, is that correct ? (Looking at the function it feels weird that it can solve this issue tbh).
Still, if this is the case, there are still a few places where this should be used and the manual cleaning of double quote be removed.
If not, we should definitely investigate this problem.
I think it'd be convenient to have a common toy dataset to try the converter on both sides. If you can send me the list of patient IDs you are using, that'd be perfect ! (My email address is on my profile, you can use either @gmail.com
or @inria.fr
).
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_fdg_pet.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_fmap.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_fmap.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_fmap.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_pib_pet.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_t1.py
Outdated
Show resolved
Hide resolved
Sure thing and sounds good! Yes, the diff is cluttered and difficult to make sense of. Upon looking at my code outside of the diff, it appears that the same functionality is there, but chopped to pieces and moved around, hence the diff confusion. The reason for this is because I wrote a special case to handle the field maps. For some reason, if I go only off the image IDs in MRILIST, then not every field map is captured for each visit. Instead, I take a particular image ID corresponding to a field map, and write a special case to move back a directory and search for other image IDs in that same visit, and use all IDs from the visit. This way we capture all the magnitude and phase scans as opposed to just one of the scans that was being grabbed from MRILIST.
Thank-you, I've now provided comments for these.
Yes, I had not seen the load_clinical_csv function previously so I thought that this fixed the double quote issue since it was mentioned as solving CSV inconsistencies, but I think this particular case is not written in the function so code could be added for removing double quotes if they exist. I will reopen the issue.
E-mail sent! |
The most recent commit incorrectly references issue #2, I meant to say that its the second round of adjusted comments. This version of the code ran successfully on the list of participants provided via e-mail. |
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.
Hello @tharpm95 ! I tested your PR and have succeeded in obtaining a BIDS after modifying it a bit. I will be adding my commits to your PR to share those changes with you.
Awesome! I will be glad to view those changes once you commit. |
@tharpm95 They are in this PR on your fork: IUSCA#1 |
@@ -109,11 +108,8 @@ def compute_t1_paths(source_dir, csv_dir, subjs_list, conversion_dir): | |||
mri_quality = load_clinical_csv(csv_dir, "MRIQUALITY") | |||
mayo_mri_qc = load_clinical_csv(csv_dir, "MAYOADIRL_MRI_IMAGEQC_12_08_15") | |||
|
|||
# Keep only T1 scans | |||
mayo_mri_qc = mayo_mri_qc[mayo_mri_qc.series_type == "T1"] |
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.
@tharpm95 any reasons for removing this line from the T1 converter ?
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 can't recall any reason. Maybe I mistakenly left it removed during debugging to figure out how specific modalities are accessed to build the image list. I will double check this to see if having it caused issues for any reason.
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.
Could you restore it ?
@tharpm95 also, I see that the linter is not happy. Could you install the pre-commit hook to automatically format your code ? The command is:
from the root folder of clinica. |
Sure, I will do this. |
I have incorporated pre-commit. Hopefully everything looks ok now. |
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 @tharpm95 !
A few small suggestions.
This PR is starting to grow a lot, I think a possible way forward would be to merge this into dev
once the review process is finished, and we will work with @AliceJoubert on refactoring a bit the portions of the code that are likely to become maintenance pain points in the future (thinking about the giant renaming loop for instance).
Would that work for you ?
@@ -109,11 +108,8 @@ def compute_t1_paths(source_dir, csv_dir, subjs_list, conversion_dir): | |||
mri_quality = load_clinical_csv(csv_dir, "MRIQUALITY") | |||
mayo_mri_qc = load_clinical_csv(csv_dir, "MAYOADIRL_MRI_IMAGEQC_12_08_15") | |||
|
|||
# Keep only T1 scans | |||
mayo_mri_qc = mayo_mri_qc[mayo_mri_qc.series_type == "T1"] |
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.
Could you restore it ?
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_t1.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_t1.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_pib_pet.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_fmri.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_flair.py
Outdated
Show resolved
Hide resolved
Yes, that works for me. I will go ahead and fix those other code issues highlighted above now as well. |
try: | ||
conversion_df = converted_dict[converted_mod] |
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.
Could you move that line again ? (1123 to 1119)
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.
Yes I will move conversion_df to above the try statement
if error_msg: | ||
cprint(msg=error_msg, lvl="error") | ||
raise ValueError(error_msg) | ||
file_without_extension.with_: wqsuffix(".nii").unlink() |
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.
file_without_extension.with_: wqsuffix(".nii").unlink() | |
file_without_extension.with_suffix(".nii").unlink() |
This one is definitely my mistake but it should go back to this, so I would appreciate it if you made the modification
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.
Noted
I've addressed the additional issues above! Thanks for the collaboration so far. |
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 think those are the last remaining complaints from the linter
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_av45_fbb_pet.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_dwi.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_fdg_pet.py
Outdated
Show resolved
Hide resolved
clinica/iotools/converters/adni_to_bids/adni_modalities/adni_tau_pet.py
Outdated
Show resolved
Hide resolved
More linting issues fixed. |
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 @tharpm95 !
The two failures on the converter test suite are expected since the ADNI-to-BIDS now produces a fmap.tsv
file in the conversion_info folder. I'll update the dataset on the CI machines to reflect that.
The PR LGTM and I think we can merge into dev and iterate on adni_fmap.py
in follow-up PRs, but let's wait for @AliceJoubert to approve first (or ask additional changes if needed).
Thanks @tharpm95 and @NicolasGensollen ! Looks good to me too |
Closes #1044
Features: