epi_b0_correct.py error

Hello AFNI experts,

I am attempting to run epi_b0_correct.py to perform spatial distortion correction of my EPI dataset but I am running into some issues. I am attempting to execute epi_b0_correct.py following as per Example 1 in the documentation. My frequency dataset (fieldmap volume in rad/s) was created using FSL’s FUGUE program.

Here is my command:
epi_b0_correct.py
-epi_pe_echo_sp 0.2
-epi_pe_dir PA
-in_freq fieldmap_rads_regularised.nii.gz
-in_mask pm2_brain_mask.nii.gz
-in_magn pm2.nii
-in_epi eWM.nii
-prefix b0_corr

I receive the following error:

ERROR: can’t have freq dset datum type be ‘float’ and then
use (def) ‘mode’ to recenter its values;
see -do_recenter_freq for recentering in other ways
(like ‘median’?).

I then tried to addressing this by adding the following option: -do_recenter_freq MEAN
However, I received the following output with another error:
++ EPI and phase have same obliq? True
++ Using PE effective echo spacing to calc BWPP: 0.04901960784313725

++ ================== Start B0 correction ==================
Ver : 2.63
Date : June 3, 2020

++ -------------------- copy inputs -----------------------
wdir: ./__work_B0_corr_oN6KeBMs5PG

+++ Command Echo:
3dcalc -a fieldmap_rads_regularised.nii.gz -expr a -prefix ./__work_B0_corr_oN6KeBMs5PG/fieldmap_rads_regularised.nii.gz

++ 3dcalc: AFNI version=AFNI_21.2.06 (Sep 1 2021) [64-bit]
++ Authored by: A cast of thousands
++ Output dataset ././__work_B0_corr_oN6KeBMs5PG/fieldmap_rads_regularised.nii.gz

+++ Command Echo:
3dcalc -a eWM.nii -expr a -prefix ./__work_B0_corr_oN6KeBMs5PG/eWM.nii

++ 3dcalc: AFNI version=AFNI_21.2.06 (Sep 1 2021) [64-bit]
++ Authored by: A cast of thousands
++ Output dataset ././__work_B0_corr_oN6KeBMs5PG/eWM.nii

+++ Command Echo:
3dcalc -a pm2.nii -expr a -prefix ./__work_B0_corr_oN6KeBMs5PG/pm2.nii

++ 3dcalc: AFNI version=AFNI_21.2.06 (Sep 1 2021) [64-bit]
++ Authored by: A cast of thousands
++ Output dataset ././__work_B0_corr_oN6KeBMs5PG/pm2.nii

+++ Command Echo:
3dcalc -a pm2_brain_mask.nii.gz -expr a -prefix ./__work_B0_corr_oN6KeBMs5PG/pm2_brain_mask.nii.gz

++ 3dcalc: AFNI version=AFNI_21.2.06 (Sep 1 2021) [64-bit]
++ Authored by: A cast of thousands
++ Output dataset ././__work_B0_corr_oN6KeBMs5PG/pm2_brain_mask.nii.gz

++ -------------------- calc B0 corr -----------------------
freq dset: fieldmap_rads_regularised.nii.gz

2381.124618

+++ Command Echo:
3dcalc -a fieldmap_rads_regularised.nii.gz -b pm2_brain_mask.nii.gz -expr (1.0/6.2831853)(a-(2381.124618))/0.049019607843137252.5098*b -datum float -prefix bc_00.nii.gz

++ 3dcalc: AFNI version=AFNI_21.2.06 (Sep 1 2021) [64-bit]
++ Authored by: A cast of thousands
++ Output dataset ./bc_00.nii.gz
Program 3dmerge

+++ Command Echo:
3dmerge -doall -1blur_sigma 9 -datum float -prefix bc_01_smoo.nii.gz bc_00.nii.gz

3dmerge: edit and combine 3D datasets, by RW Cox
++ editing input dataset in memory (2.5 MB)
.

++ 3dmerge: AFNI version=AFNI_21.2.06 (Sep 1 2021) [64-bit]
++ default -1dindex = 0
++ default -1tindex = 1
– Wrote edited dataset: ./bc_01_smoo.nii.gz
20.0 -1250.262695 40.0 -57.175697 60.0 584.526978 80.0 1263.749023 100.0 4331.105957

++ 3dWarp: AFNI version=AFNI_21.2.06 (Sep 1 2021) [64-bit]
++ Authored by: RW Cox
** ERROR executing this command in the shell:
3dNwarpApply -echo_edu -warp “mat_obl_epi_freq.aff12.1D PA:1.0:bc_01_smoo.nii.gz” -master eWM.nii -ainterp quintic -prefix bc_02_smoo_wrpd2epi.nii.gz -source bc_01_smoo.nii.gz

** Exit status : 1
** Standard error : ++ 3dNwarpApply: AFNI version=AFNI_21.2.06 (Sep 1 2021) [64-bit]
++ Authored by: Zhark the Warped
++ -master dataset is ‘eWM.nii’
++ opened source dataset ‘bc_01_smoo.nii.gz’
++ Processing -nwarp ** FATAL ERROR: malloc (out of memory) error for dataset sub-brick #0
** Program compile date = Sep 1 2021

Any guidance on how to address this error is much appreciated.

Thank you!

Michael

It looks like it ran out of memory. How much memory is available, and how big is this dataset?

The first problem complains about the dataset in float point, but a mode statistic is calculated. You can convert that dataset to an integer value with 3dcalc.

Thanks, Daniel. I was able to use 3dcalc to convert the b0map float to integer. I’m still getting the memory error though. This is surprising because the EPI dataset is 500mb and this machine has more than ample disk space and RAM. So I’m not sure what that error message means.

Thanks,

Michael

Is that 500MB uncompressed? What resolution and number of voxels are in the data? Is the data oblique? You can use 3dinfo to get some of these answers.

Hi Daniel,

The EPI dataset is 540MB in uncompressed nifti format. It contains 405 volumes with a voxel resolution of 2.5mm x 2.5mm x 2.5mm. Matrix size is 102x102 with 64 axial slices. I guess this is perhaps a larger than average matrix size?

Thank you,

Michael

Not really that big. You may be running into problems where the datasets have moved very far apart. That can have dramatic implications for 3dNwarpApply. You can move datasets first with @Align_Centers to center over each other.

Thank you, Daniel. I will try this approach.

Michael