AFNI Message Board

History of AFNI updates  

|
July 09, 2013 02:41PM
Hi all,
I had been searching for a way to use the field map correction of FSL and transform back to AFNI with the minimum steps of interpolation. The threads on the forum about this seemed not complete. And the major problem I encountered is the coordinate seems to be messed up after bringing FSL result back to AFNI (especially if I want to align epis of multiple sessions to a common structure). So here is some tips I would like to share after my struggling. Please feel free to correct me if you have done similar things and found me wrong, or if you know a better way.

preparation:
provide a T1 image and skull stripped version. Use 3dresample to make sure it has the same orientation as the EPI (usually RAI, otherwise I notice FSL can do a huge rotation to map the epi to structure, and I am not really sure if it can flip left with right in that rotation). Do 3dAFNItoNIFTI to them (FSL assumes the skull-stripped brain has a _brain suffix to the original T1 image).

Make an example epi sub-brik (I used the median of 3dTshifted and 3dvolreged version of the epi run that is closest in time to the field map sequence, other example should be fine) and write it as nifiti.

Prepare the fieldmap with FSL utility ( [fsl.fmrib.ox.ac.uk] ): strip the magnitude image of the field map sequence, erode it with one voxel (these can be done with bet and fsl_maths, or AFNI as well) and use the fsl_prepare_fieldmap script to generate the fieldmap file. When you scan, make sure the field map sequence reconstructs both magnitude and phase.

Use Feat of fsl to register epi to structure with field map correction (epi_reg of fsl probably does similar thing but I have not tried). Select first-level analysis and pre-stats only. Put the example epi generated above to the Data tab of the gui. In the pre-stats tab, do not do motion correction (as we only supply one sub-brik of EPI) Select B0 unwarping, put the fieldmap and the brain stripped magnitude of the fieldmap sequence into the gui (note that Feat also requires both original magnitude file and a skull stripped version, the latter needs a suffix of _brain to the former). Type the correct parameters you would get from your sequence (for A>>P phase encoding direction, the unwarp direction seems to be y, but it is worth trying -y or other parameter as well to find the correct option). Select BET brain extraction (unless the epi is already skull stripped), no spatial smoothing, intensity normalization or highpass filtering. In the registration tab, provide a main structure image (the skull stripped T1 brain). I did not check the "standard space" because I found the templates of FSL seems to be in RPL orientation and I am worried that FSL may mess up the orientation by rotating everything to be similar to the template, plus I am happy to analyze in original space for now.

Hit "Go". After Feat finishes, go to the output folder, in the reg/unwarp directory, there is a file called FM_UD_fmap2epi_shift.nii.gz. This is the calculated shift in order to unwarp epi, in the epi space. I am using the neurodebian distribution of FSL 5.0 installed on Ubuntu. FSL guys say there is a naming error of this file ( [www.jiscmail.ac.uk] ). I am not sure on other distribution whether the naming is changed. In my observation, this shift file seems to be in the unit of voxel. But it is worth double checking.

(assuming the voxel size is 3.5 mm on AP or y direction)
3dNwarpCat -prefix unwarp_afni AP:3.5:FM_UD_fmap2epi_shift.nii.gz
3drefit -duporigin (Your_epi_example_sub_brik) unwarp_afni+orig (For whatever reason, the origin from fsl output is changed)
3dNwarpApply -source (Your_epi_example_sub_brik) -nwarp unwarp_afni+orig -prefix example_epi_ud

This example_epi_ud+orig looks pretty good. Then I use align_epi_anat.py to calculate a rigid-body transform matrix that aligns this undistorted epi to the structure. At this moment I can check the registration. I use rigid-body because in this way it is easier to know if I mistaked the encoding direction or the unit of the shift file.
Assuming the name of the transformation matrix from align_epi_anat.py is example_epi_ud_al_mat.aff12.1D, then we concatenate this matrix with the unwarp file:

3dNwarpCat -prefix nwarp_epi2anat example_epi_ud_al_mat.aff12.1D unwarp_afni+orig
(This step is my least confident one. Can AFNI friends correct me if this is the correct concatenation order? And can anyone point out how to replace this command with 3dNwarpCalc to get the "hexvol"?)

After this, we can use 3dvolreg to write the motion correction matrix from the 3dTshifted version of the 3D+time EPI to the example EPI. Then do a '3dNwarpApply -nwarp nwarp_epi2anat -source Your_epi_tshifted -affter The_aff12_matrix -prefix whatever -master some_file' to nonlinearly warp the epi to match the structure.

This way, there are only two steps of interpolation: slice timing correction and the final nonlinear warping, if my understanding of AFNI is right. The result seems good for one session. And I am going to see how cross-session registration looks with this field map correction incorporated.

Hope this can be helpful to someone and please point any errors I have. Thanks!

Mingbo Cai



Edited 1 time(s). Last edit at 07/09/2013 02:57PM by lcnature.
Subject Author Posted

One way to incorporate FSL field map correction

Mingbo July 09, 2013 02:41PM

Re: One way to incorporate FSL field map correction

Mingbo July 09, 2013 02:44PM

Re: One way to incorporate FSL field map correction

Bob Cox July 10, 2013 09:56AM

Re: One way to incorporate FSL field map correction

Mingbo July 10, 2013 10:39AM

Re: One way to incorporate FSL field map correction

Phil Burton April 14, 2014 02:18PM

Re: One way to incorporate FSL field map correction

Emperor Zhark April 15, 2014 07:11PM

Re: One way to incorporate FSL field map correction

Phil Burton April 16, 2014 06:05PM

Re: One way to incorporate FSL field map correction

jkeidel December 09, 2014 09:31AM

Re: One way to incorporate FSL field map correction

jkeidel November 28, 2014 09:29AM

Re: One way to incorporate FSL field map correction

maria April 29, 2015 01:16PM

Re: One way to incorporate FSL field map correction

jmbjork January 12, 2017 08:17AM

Re: One way to incorporate FSL field map correction

rick reynolds January 12, 2017 09:31AM

Re: One way to incorporate FSL field map correction

jmbjork January 25, 2017 11:26AM

Re: One way to incorporate FSL field map correction

rick reynolds January 25, 2017 11:41AM

Re: One way to incorporate FSL field map correction

Chern-Chyi (Cecil) Yen April 05, 2017 05:04PM



Sorry, only registered users may post in this forum.

Click here to login