コード例 #1
0
 def test_extract_k_space_center_3D(self):
     """ This test ensures that the output of the non cartesian kspace
     extraction is same a that of mimicked cartesian extraction in 3D
     """
     _mask = np.ones((self.N, self.N, self.Nz))
     _samples = convert_mask_to_locations(_mask)
     Img = (np.random.randn(self.num_channel, self.N, self.N, self.Nz) +
            1j * np.random.randn(self.num_channel, self.N, self.N, self.Nz))
     Nby2_percent = self.N * self.percent / 2
     Nzby2_percent = self.Nz * self.percent / 2
     low = int(self.N / 2 - Nby2_percent)
     high = int(self.N / 2 + Nby2_percent + 1)
     lowz = int(self.Nz / 2 - Nzby2_percent)
     highz = int(self.Nz / 2 + Nzby2_percent + 1)
     center_Img = Img[:, low:high, low:high, lowz:highz]
     thresh = self.percent * 0.5
     data_thresholded, samples_thresholded = \
         extract_k_space_center_and_locations(
             data_values=np.reshape(Img, (self.num_channel,
                                          self.N * self.N * self.Nz)),
             samples_locations=_samples,
             thr=(thresh, thresh, thresh),
             img_shape=(self.N, self.N, self.Nz))
     np.testing.assert_allclose(center_Img.reshape(data_thresholded.shape),
                                data_thresholded)
コード例 #2
0
 def test_extract_k_space_center_2D_fft(self):
     """ Ensure that the extracted k-space center is right
     for cartesian case"""
     mask = np.random.randint(0, 2, (self.N, self.N))
     samples = convert_mask_to_locations(mask)
     Img = (np.random.randn(self.num_channel, self.N, self.N) +
            1j * np.random.randn(self.num_channel, self.N, self.N))
     Nby2_percent = self.N * self.percent / 2
     low = int(self.N / 2 - Nby2_percent)
     high = int(self.N / 2 + Nby2_percent + 1)
     center_Img = Img[:, low:high, low:high]
     cutoff_mask = mask[low:high, low:high]
     locations = np.where(cutoff_mask.reshape(cutoff_mask.size))
     center_Img = center_Img.reshape(
         (center_Img.shape[0], cutoff_mask.size))[:, locations[0]]
     thresh = self.percent * 0.5
     data_thresholded, samples_thresholded = \
         extract_k_space_center_and_locations(
             data_values=Img,
             samples_locations=samples,
             thr=(thresh, thresh),
             img_shape=(self.N, self.N))
     np.testing.assert_allclose(
         center_Img,
         data_thresholded)
コード例 #3
0
 def test_extract_k_space_center_2D(self):
     """ Ensure that the extracted k-space center is right"""
     _mask = np.ones((self.N, self.N))
     _samples = convert_mask_to_locations(_mask)
     Img = (np.random.randn(self.num_channel, self.N, self.N) +
            1j * np.random.randn(self.num_channel, self.N, self.N))
     Nby2_percent = self.N * self.percent / 2
     low = int(self.N / 2 - Nby2_percent)
     high = int(self.N / 2 + Nby2_percent + 1)
     center_Img = Img[:, low:high, low:high]
     thresh = self.percent * 0.5
     data_thresholded, samples_thresholded = \
         extract_k_space_center_and_locations(
             data_values=np.reshape(Img, (self.num_channel,
                                          self.N * self.N)),
             samples_locations=_samples,
             thr=(thresh, thresh),
             img_shape=(self.N, self.N))
     np.testing.assert_allclose(center_Img.reshape(data_thresholded.shape),
                                data_thresholded)