Converting phase image to radians with mrmath

I am trying to convert phase DWI images to radians before combining them with the magnitude images and running dwidenoise. I currently do this with Python using nibabel and numpy, but I think it would probably be more memory efficient to use mrmath. Does anyone have any tricks they use to accomplish this?

Hi @Taylor_Salo,

Would something like this work?

mrcalc $input_img -acos - | mrcalc - 6.2831 -mult $output_radians.

Calculates the arccosine and then multiplies the output by 2pi


Thanks @smeisler! I think the phase data are typically in arbitrary units that scale to radians though, so I don’t think that would work. For Siemens BOLD data in the past I’ve done what SDCFlows does:

import nibabel as nb
import numpy as np

phase_img = nb.load(phase_file)
phase_data = phase_img.get_fdata()
imax = phase_data.max()
imin = phase_data.min()
scaled = (phase_data - imin) / (imax - imin)
phase_in_radians = 2 * np.pi * scaled
radians_img = nb.Nifti1Image(phase_in_radians, affine=phase_img.affine, header=phase_img.header)