File size: 1,104 Bytes
83e314f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import numpy as np

def complex_to_two_channel_image(complex_img: np.ndarray) -> np.ndarray:
    """Converts a complex valued image to a 2 channel image (real and imaginary channels)"""
    real, imag = np.real(complex_img), np.imag(complex_img)
    return np.concatenate((real, imag), axis=0)

def two_channel_to_complex_image(two_ch_img: np.ndarray) -> np.ndarray:
    """Converts a 2 channel image (real and imaginary channels) to a complex valued image"""
    two_ch_img = two_ch_img[0]
    real = two_ch_img[0]
    imag = two_ch_img[1]
    complex_image = real + 1j*imag
    return complex_image[None,...]

def normalize_complex_coil_image(complex_coil_img: np.ndarray) -> np.ndarray:
    """Scales the complex valued coil image """
    max_val = np.percentile(np.abs(complex_coil_img), 99.5)
    return complex_coil_img / max_val

def create_three_channel_image(complex_coil_img: np.ndarray) -> np.ndarray:
    """Converts a complex valued coil image to a 3 channel image (magnitude channels repated 3 times)"""
    mag = np.abs(complex_coil_img)
    return np.concatenate((mag, mag, mag), axis=0)