-
Notifications
You must be signed in to change notification settings - Fork 297
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
[ENH/WIP] Robust EPI Mask for heavily nonuniform image #1050
Conversation
…ullstrip_bold_wf. add robust option for FSL BET.
Hi, thanks for this. Sorry about the slow response. Looking at this, my main concern is that we're adding steps when we may achieve the same result by rearranging. That is Under the hypothesis that these two steps are doing very little after having been run previously, I would try removing That said, if 9 steps are required, that's fine. I just want to consider whether we can simplify before we go ahead and add. |
I think this is all very reasonable (the proposed solution to a particular problem, and further revision from @effigies). On the other hand, I have the feeling that we are touching on an edge case here. I checked visually more than 2000 masks (of 10000 which run without errors), and it'd be a waste to have a regression on this. I propose the following: @ZhifangYe would you be satisfied if we add a flag (say In a future, if more and more users report they are using the flag, we could make it the default. WDYT? |
Hi all, after discussing this issue, we would like to set up some extra tests to avoid regressions on masking. We plan to work on these new tests along next week. This way this PR can be accepted as is (without implementing new optional arguments etc) when the new tests are passing. |
After review the process, I agree to the comment from @effigies that we can simplify the workflow. The idea here is we need to feed a uniformed image to MaskEPI node. The histogram based masking method in MaskEPI would fail for heavily nonuniform data no matter what parameters we use. As long as we normalize epi data before MaskEPI, I think results should be fine. In my experience, BET always gives a more loose mask for both corrected and uncorrected image. So I think remove As for an addition flag suggest by @oesteban , I'm satisfied with it. But I'm little concerned that other users would be confused without context. So if this tweak don't change behaviors on tested data, I think we may want to include it as default. Look forward to the extra tests results. |
Use dilated MaskEPI result as first pass mask.
I've asked for these data (https://neurostars.org/t/ica-aroma-error-in-fmriprep-mask-and-image-must-be-the-same-size/1605/4) to add in the test battery. When "prescan normalize" is on, it seems that images are more homogeneous and our masking heuristics get lost. I wonder if this PR would fix that. |
I inspected the report and have a impression that prescan normalization add additional noise in non-brain regions. The noise intensity seems fall into the range of brain signal. In current PR, the mask from FSL BET before n4 correct is included in final mask calculation. This generally gives a coarse but robust mask which could exclude these noisy voxels. @oesteban If you could share some test data with me, I would like to test them locally and evaluate the performance. |
@effigies is currently working on setting up the masks tests for current and future implementations of this stage. Will let you know when this is available 👍 |
Hi @ZhifangYe. Sorry for taking so long to get back to you on this. #1074 is almost done, so I'm going to merge it in here to see what effect your changes have on our existing datasets. |
Well, that's failing. Running locally to see what the differences are. They could be minor. |
combine_masks node is now combine_masks2
Tests passing at a symmetric overlap threshold of 0.95. Here are the absolute sizes (in voxels) before and after: 1,14c1,14
< ds000116/sub-12_task-visualoddballwithbuttonresponsetotargetstimuli_run-02_bold_mask.nii.gz float32 [ 64, 64, 32] 3.00x3.00x4.00 sform 1:44517
< ds000133/sub-06_ses-post_task-rest_run-01_bold_mask.nii.gz float32 [ 64, 64, 30] 4.00x4.00x4.00 sform 1:24680
< ds000140/sub-32_task-heatpainwithregulationandratings_run-02_bold_mask.nii.gz float32 [ 80, 80, 42] 2.80x2.80x3.00 1:60263
< ds000157/sub-23_task-passiveimageviewing_bold_mask.nii.gz float32 [ 64, 64, 30] 4.00x4.00x3.99 sform 1:21536
< ds000210/sub-06_task-rest_run-01_echo-1_bold_mask.nii.gz float32 [ 72, 72, 46] 3.00x3.00x3.00 sform 1:57475
< ds000210/sub-06_task-rest_run-01_echo-2_bold_mask.nii.gz float32 [ 72, 72, 46] 3.00x3.00x3.00 sform 1:55082
< ds000210/sub-06_task-rest_run-01_echo-3_bold_mask.nii.gz float32 [ 72, 72, 46] 3.00x3.00x3.00 sform 1:52088
< ds000216/sub-03_task-rest_echo-1_bold_mask.nii.gz float32 [ 80, 80, 36] 3.00x3.00x3.00 sform 1:45485
< ds000216/sub-03_task-rest_echo-2_bold_mask.nii.gz float32 [ 80, 80, 36] 3.00x3.00x3.00 sform 1:42676
< ds000216/sub-03_task-rest_echo-3_bold_mask.nii.gz float32 [ 80, 80, 36] 3.00x3.00x3.00 sform 1:40151
< ds000216/sub-03_task-rest_echo-4_bold_mask.nii.gz float32 [ 80, 80, 36] 3.00x3.00x3.00 sform 1:38029
< ds000237/sub-03_task-MemorySpan_acq-multiband_run-01_bold_mask.nii.gz float32 [ 64, 64, 48] 3.00x3.00x3.00 sform 1:60327
< ds000237/sub-06_task-MemorySpan_acq-multiband_run-01_bold_mask.nii.gz float32 [ 64, 64, 48] 3.00x3.00x3.00 sform 1:51879
< ds001362/sub-01_task-taskname_run-01_bold_mask.nii.gz float32 [ 88, 88, 64] 2.39x2.39x2.40 sform 1:8526
---
> ds000116/sub-12_task-visualoddballwithbuttonresponsetotargetstimuli_run-02_bold_mask.nii.gz float32 [ 64, 64, 32] 3.00x3.00x4.00 sform 1:42037
> ds000133/sub-06_ses-post_task-rest_run-01_bold_mask.nii.gz float32 [ 64, 64, 30] 4.00x4.00x4.00 sform 1:24342
> ds000140/sub-32_task-heatpainwithregulationandratings_run-02_bold_mask.nii.gz float32 [ 80, 80, 42] 2.80x2.80x3.00 1:59962
> ds000157/sub-23_task-passiveimageviewing_bold_mask.nii.gz float32 [ 64, 64, 30] 4.00x4.00x3.99 sform 1:21592
> ds000210/sub-06_task-rest_run-01_echo-1_bold_mask.nii.gz float32 [ 72, 72, 46] 3.00x3.00x3.00 sform 1:57717
> ds000210/sub-06_task-rest_run-01_echo-2_bold_mask.nii.gz float32 [ 72, 72, 46] 3.00x3.00x3.00 sform 1:54989
> ds000210/sub-06_task-rest_run-01_echo-3_bold_mask.nii.gz float32 [ 72, 72, 46] 3.00x3.00x3.00 sform 1:51198
> ds000216/sub-03_task-rest_echo-1_bold_mask.nii.gz float32 [ 80, 80, 36] 3.00x3.00x3.00 sform 1:45502
> ds000216/sub-03_task-rest_echo-2_bold_mask.nii.gz float32 [ 80, 80, 36] 3.00x3.00x3.00 sform 1:42192
> ds000216/sub-03_task-rest_echo-3_bold_mask.nii.gz float32 [ 80, 80, 36] 3.00x3.00x3.00 sform 1:38919
> ds000216/sub-03_task-rest_echo-4_bold_mask.nii.gz float32 [ 80, 80, 36] 3.00x3.00x3.00 sform 1:35955
> ds000237/sub-03_task-MemorySpan_acq-multiband_run-01_bold_mask.nii.gz float32 [ 64, 64, 48] 3.00x3.00x3.00 sform 1:60031
> ds000237/sub-06_task-MemorySpan_acq-multiband_run-01_bold_mask.nii.gz float32 [ 64, 64, 48] 3.00x3.00x3.00 sform 1:52943
> ds001362/sub-01_task-taskname_run-01_bold_mask.nii.gz float32 [ 88, 88, 64] 2.39x2.39x2.40 sform 1:99964 |
The multi-echo runs in particular seem to produce more conservative masks. @oesteban I might want your eyes for some of this. It's hard to tell if they're over-conservative, given the overall image contrast level. |
Plots of the old/new masks are being saved as artifacts. |
What's red and what's green? Can I assume that red == old? |
Yes
…-------- Original message --------
From: Oscar Esteban <[email protected]>
Date: 8/10/18 15:54 (GMT-05:00)
To: poldracklab/fmriprep <[email protected]>
Cc: Christopher Markiewicz <[email protected]>, Mention <[email protected]>
Subject: Re: [poldracklab/fmriprep] ENH: Robust EPI Mask for heavily nonuniform image (#1050)
What's red and what's green? Can I assume that red == old?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#1050 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAFF8nmlJqUn9vUlx8rIsl0JVho-bwguks5uPeTwgaJpZM4TR4_8>.
|
Oh, you mean the contours? I think the more conservative masks are the new ones. Which I think does align red/green. But you wrote ROIsPlot, so you'll know better than I. |
Since #1074 wa merged we should work on getting this contribution incorporated in FMRIPREP (since we can check if nothing regresses). |
Right, sorry, Oscar and I discussed off-thread that there are regressions where previously good masks are now (slightly) too conservative. It's unclear whether the best path forward is further tweaking on this PR or permitting options. |
Okay, getting back to this. If I remember correctly, @oesteban's thought was to use a quick affine registration to register a template EPI image, then dilate the mask by a few voxels to create the initial pre-N4 mask. Once that's done, we may be able to otherwise use the existing method. I'll be looking into this this afternoon. |
I've added some code to save a bundle of the mask files so that, in cases like this where we change the mask algorithm, we can easily upload the new files to OSF. |
@ZhifangYe, in addition to #1050 (comment), please have a look on #1322 (comment) and let us know whether you want to have your name added in the |
Hi, @oesteban , thanks for the efforts on this PR. The regression test looks really good. I'm happy to have my data included in the battery of regression test. The BOLD files should already be anonymized. I have a quick look at #1321 and feel it is very promising. I will build an image for this PR to test it locally and report back. There're several failed examples in my dataset I could test on. Also, there's a related issue I recently discovered. For some BOLD image, the N4 correction works fine on the generated reference image before fieldmap unwrapping but fails on the unwrapped image. It produced bad final brain mask even in my current PR. I will see whether #1321 resolve this problem. If not, I think we should look into it. BTW, I'm already in the |
Closed via #1321 |
Ref #1000
When processing heavily nonuniform bold data (eg, from 64 channels head coils), the MaskEPI step in init_enhance_and_skullstrip_bold_wf often give bad results.
This PR tweaks some parameters in MaskEPI and adds an addition N4 correction step before MaskEPI. I have tested the code on a multiband dataset and several legacy images. Generally it gives better or equal results with little additional computation cost.