Passed
Pull Request — master (#353)
by Fernando
01:09
created

torchio.transforms.fourier   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A FourierTransform.fourier_transform() 0 5 1
A FourierTransform.inv_fourier_transform() 0 5 1
1
import numpy as np
2
3
4
class FourierTransform:
5
6
    @staticmethod
7
    def fourier_transform(array: np.ndarray) -> np.ndarray:
8
        transformed = np.fft.fftn(array)
9
        fshift = np.fft.fftshift(transformed)
10
        return fshift
11
12
    @staticmethod
13
    def inv_fourier_transform(fshift: np.ndarray) -> np.ndarray:
14
        f_ishift = np.fft.ifftshift(fshift)
15
        img_back = np.fft.ifftn(f_ishift)
16
        return img_back
17