-
Notifications
You must be signed in to change notification settings - Fork 51
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
Addition of a LORIS tool to deface structural images and register the defaced images back into LORIS #366
Conversation
…acquisitions like t1, t2, flair etc... Need to work on multi-echo acquisitions and MP2RAGE now
…r special acquisition types such as MP2RAGE base on the minc header acquisition:image_type
uploadNeuroDB/bin/deface_minipipe.pl
Outdated
# (arguments without ,) | ||
|
||
# create the directory where the final outputs will be saved | ||
mkdir($output_dir) unless (-e $output_dir); |
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 result of the mkdir
command should be checked and an error message issued if it failed.
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
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.
Thank you @nicolasbrossard for your review!!
One note, you commented on the script I copied from the EZminc BIC repo so I did not integrate all your comments (like the exit code for example which is not implemented on the MINC tool side I believe). Since there are portions of the script I modified to make it more generic (it got merge before the holidays on the EZminc repo), I included your feedback on the parts I modified and will commit the changes to the EZminc repo so they can have it as well.
However, if you could review the script in the tools
directory called run_deface_script.pl
, that would be awesome!
Thank you so much!!
uploadNeuroDB/bin/deface_minipipe.pl
Outdated
# (arguments without ,) | ||
|
||
# create the directory where the final outputs will be saved | ||
mkdir($output_dir) unless (-e $output_dir); |
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
…ng tool (#4232) This adds to the imaging_pipeline section of the Config module 2 fields needed for the imaging defacing tool: - reference_scan_type_for_defacing: the reference image that will be used for registration (typically the t1w modality) - modalities_to_deface: multi-line options to list all 3D modalities that need to be defaced (for example t1w, flair, pd, t2w...) This goes with the LORIS-MRI PR: aces/Loris-MRI#366
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.
@nicolasbrossard Thank you very much for your review. I included your feedback in the next commit. Ready for another review! :)
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.
@PapillonMcGill Thank you for the comments. They should all be fixed in the last commit.
…scripts_md directory
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.
@PapillonMcGill thank you for the review. It should be taken care of in the last commit.
LGTM |
no more objection! |
@nicolasbrossard all your previous comments have been taken care of. Please re-review at your convenience. Thanks! |
uploadNeuroDB/NeuroDB/MRI.pm
Outdated
@@ -1280,7 +1280,9 @@ sub compute_hash { | |||
$ctx->add($file->getParameter('patient:birthdate')); # Patient DOB | |||
$ctx->add($file->getParameter('study_instance_uid')); # StudyInstanceUID | |||
$ctx->add($file->getParameter('series_description')); # SeriesDescription | |||
$ctx->add($file->getParameter('processing:intergradient_rejected')); | |||
if ($file->getParameter('processing:intergradient_rejected')) { |
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 do not know if this is possible but if parameter processing:intergradient_rejected
exists and is either ''
or 0
, then this test evaluates to false. Is this what you want?
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.
good catch!!! Should be corrected in the next commit.
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 but I do have a question (see comments above).
…ng tool (aces#4232) This adds to the imaging_pipeline section of the Config module 2 fields needed for the imaging defacing tool: - reference_scan_type_for_defacing: the reference image that will be used for registration (typically the t1w modality) - modalities_to_deface: multi-line options to list all 3D modalities that need to be defaced (for example t1w, flair, pd, t2w...) This goes with the LORIS-MRI PR: aces/Loris-MRI#366
Description
This PR adds a new tool that will allow defacing of the structural images listed in the Config module under the imaging pipeline section in the new field called
modalities_to_deface
(See PR aces/Loris#4232 on the LORIS side for the SQL patch).Note that the script
deface_minipipe.pl
inuploadNeuroDB/bin
has been taken out of the BIC EZminc GitHub repo (https://github.com/BIC-MNI/EZminc/tree/ITK4/scripts).Screenshot of a defaced scan:
How to use the tool
Make sure to populate the configuration
modalities_to_deface
in the imaging pipeline section of the Configuration module with all scan types that you wish to deface (typically, T1W, T2W, T2*, FLAIR and other 3D structural images)To run the tool, go to the
tools
directory and run:perl run_defacing_script.pl -profile <profile> [ -sessionIDs <list of sessionIDs> ]
Note that if the
-sessionIDs
is not passed to the script, it will deface images from all sessions with the modalities to deface.Note that the defaced images will be registered in LORIS as
modality-defaced
(where modality is replaced by t1, t2, flair...). The new MRI scan type calledmodality-defaced
is automatically created in themri_scan_type
table byrun_defacing_script.pl
based on the name of the modality to deface.Special notes for multi-contrast acquisitions:
At the top of the script, 2 variables have been implemented and can be customized:
1.
%SPECIAL_ACQUISITIONS_FILTER
:For acquisitions such as fieldmaps, a phase and two magnitude files are available. We only want to deface the magnitude files as the phase file does not have a face and we don't want to alter the phase image. To differentiate between the phase and magnitude files, we need to use the
acquisition:image_type
MINC header for which the value will be:ORIGINAL\\PRIMARY\\M\\ND
for the magnitude filesORIGINAL\\PRIMARY\\P\\ND
for the phase fileTherefore, to only deface the magnitude fieldmap images, we need to specify the value of
acquisition:image_type
in the constant variable%SPECIAL_ACQUISITIONS_FILTER
at the top of the script like that:In the script, this constant variable also shows examples for MP2RAGE and multi-echo acquisitions.
2.
@MULTI_CONTRAST_ACQUISITIONS_BASE_NAMES
The
@MULTI_CONTRAST_ACQUISITIONS_BASE_NAMES
variable will store the base names of multi-contrast acquisitions such asMP2RAGE
,qT2star
orfieldmap
. These will allow to call thedeface_minipipe.pl
tool properly for multi-contrast acquisition (a.k.a.fieldmap_file1,fieldmap_file2
). Callingdeface_minipipe.pl
with images separated by,
will tell the script not to create 2 XFMs (one for each fieldmap file) but instead reuse the XFM fromfieldmap_file1
to registerfieldmap_file2
.Notes for existing projects
If you desire to use this new tool, make sure you have:
bic-mni-models
anatomical template library and thebeast
library from the MINC tools in/opt/minc/
(https://bic-mni.github.io/#data-files-and-models)%SPECIAL_ACQUISITIONS_FILTER
,@MULTI_CONTRAST_ACQUISITIONS_BASE_NAMES
) at the top of thetools/run_defacing_script.pl
script to your project's need.Additional checks before running the script:
which deface_minipipe.pl
is returning the following$LORIS-MRI/uploadNeuroDB/bin/deface_minipipe.pl
script and not the one present in the MINC toolkit (/opt/minc/$VERSION
) as LORIS-MRI is using the version ofdeface_minipipe.pl
under development (which have not yet been released with the MINC tools). Ifwhich deface_minipipe.pl
is not pointing to the correct script, you will need to update your$PATH
bash variable to make sure$LORIS-MRI/uploadNeuroDB/bin
is the first path mentioned in the variable.See also