コード例 #1
0
ファイル: test_base.py プロジェクト: twj2417/DPAD
 def test_filter(self):
     energy_window = np.array([350, 650])
     events = self.data.filter_with_energy_window(energy_window)
     assert all_close(events.block1, np.array([1, 12]))
     assert all_close(events.crystal1, np.array([82, 28]))
     assert all_close(events.block2, np.array([8, 1]))
     assert all_close(events.crystal2, np.array([58, 42]))
コード例 #2
0
 def test_sort_time(self):
     time = np.array([6878008,6882499,6882499,8082068,8084519,8084519,8084830,8088913,
                     8088913,8089688,8090193,8597195,10422958,10423383,10423758,10424489,
                     10426423,10427465,10427495,10429860])
     energy = np.array([489,278,322,521,176,370,619,324,404,352,198,286,443,277,546,517,218,167,529,228])
     blockid = np.array([1,1,1,2,2,2,2,2,2,2,2,3,0,0,0,0,0,0,0,0])
     crystalid = np.array([99,64,83,74,79,70,73,47,19,42,23,60,35,21,24,11,14,92,78,67])
     assert all_close(self.data.sort_by_time().time,time)
     assert all_close(self.data.sort_by_time().energy,energy)
     assert all_close(self.data.sort_by_time().blockid,blockid)
     assert all_close(self.data.sort_by_time().crystalid,crystalid)
コード例 #3
0
 def test_16module_dernezo(self):
     cmd = '. ' + self.get_16module_cylinder_path() + '/run_lmrec.sh'
     os.system(cmd)
     fortest_result = np.fromfile(
         self.get_16module_cylinder_path() + '/output_10.rec', np.float32)
     new_recon_result = np.fromfile('output_10.rec', np.float32)
     assert all_close(fortest_result, new_recon_result)
コード例 #4
0
 def test_effective_data(self):
     self.data = Module_data(0,np.array([[174,10,159,143],
                     [21,1,20,142],
                     [87,12,159,143],
                     [34,2,23,142],
                     [5,2,10,142],
                     [169,16,159,143],
                     [218,0,13,142],
                     [55,24,159,143],
                     [103,28,159,143],
                     [167,0,91,142],
                     [73,28,159,143],
                     [228,0,66,142],
                     [164,37,159,143]]))
     result = np.array([[21,1,20,142],
                     [87,12,159,143],
                     [5,2,10,142],
                     [169,16,159,143],
                     [218,0,13,142],
                     [55,24,159,143],
                     [167,0,91,142],
                     [73,28,159,143],
                     [228,0,66,142],
                     [164,37,159,143]])
     assert all_close(self.data.extract_effective_data().data,result)
コード例 #5
0
 def test_16module_dernezo(self):
     cmd = '. ' + self.get_16module_cylinder_path() + '/run_tor.sh'
     os.system(cmd)
     fortest_result = np.load(self.get_16module_cylinder_path() +
                              '/recon_10.npy')
     new_recon_result = np.load('recon_10.npy')
     assert all_close(fortest_result, new_recon_result)
コード例 #6
0
ファイル: test_mct_bbs.py プロジェクト: tech-pi/SRF
 def test_16module_dernezo(self):
     cmd = '. ' + self.get_mct_path() + '/run_bbs.sh'
     os.system(cmd)
     fortest_result = np.fromfile(self.get_mct_path() + '/output_10bin.rec',
                                  dtype='float32')
     new_recon_result = np.fromfile('output_10bin.rec', dtype='float32')
     assert all_close(fortest_result, new_recon_result)
コード例 #7
0
 def test_16module_dernezo(self):
     cmd = '. ' + self.get_16module_derenzo_path() + '/run_castor.sh'
     os.system(cmd)
     fortest_result = np.fromfile(
         self.get_16module_derenzo_path() +
         '/cylinder_cas/cylinder_cas_it10.img', np.float32)
     new_recon_result = np.fromfile('./cylinder_cas/cylinder_cas_it10.img',
                                    np.float32)
     assert all_close(fortest_result, new_recon_result)
コード例 #8
0
 def test_reshaped_data(self):
     data = np.array([[187,1,34,142,174,10,159,143],
                     [21,1,20,142,87,12,159,143],
                     [34,2,23,142,206,13,159,143],
                     [5,2,10,142,169,16,159,143],
                     [218,0,13,142,55,24,159,143],
                     [17,2,77,142,103,28,159,143],
                     [167,0,91,142,73,28,159,143],
                     [228,0,66,142,164,37,159,143]])
     assert all_close(self.data.reshaped_data,data)
コード例 #9
0
def testdelay():
    data = h5py.File(
        '/mnt/gluster/Techpi/brain16/preprocess/16module_pt3_1GainCorrectt.mat',
        'r')['single_event_data'].value
    data = np.transpose(data)
    event = Single_event(data[:, 2], data[:, 1], data[:, 3], data[:, 0])
    block_grid = np.array([1, 10, 10])
    time = timedelay(event, 2**24, 16, block_grid)
    assert all_close(
        np.transpose(time),
        np.array([
            0, -2434447, -5862977, -4415601, -4675805, -4838861, -4203983,
            -5791165, -4576211, -6638585, -4152363, -5494579, -5930491,
            -6143003, -6245015, -5597371
        ]))
コード例 #10
0
ファイル: test_base.py プロジェクト: twj2417/DPAD
 def test_get_coordinate(self):
     config = {
         "ring": {
             "inner_radius": 99.0,
             "outer_radius": 119.0,
             "axial_length": 33.4,
             "nb_rings": 1,
             "nb_blocks_per_ring": 16,
             "gap": 0.0
         },
         "block": {
             "grid": [1, 10, 10],
             "size": [20.0, 33.4, 33.4],
             "interval": [0.0, 0.0, 0.0]
         }
     }
     scanner = get_scanner(config)
     coordinate = self.data.filter_with_energy_window(np.array(
         [350, 650])).get_coordinate(scanner)
     comprison = np.array(
         [[96.22929972, 52.51264586, -8.35, -109, -1.67, 11.69],
          [-8.35, -109, 11.69, 101.34195038, 40.16961531, -8.35]])
     assert all_close(coordinate, comprison)
コード例 #11
0
 def test_uniform_cylinder(self):
     config = self.load_config()
     model = CompleteLoRsModel(
         'model', **config['algorithm']['projection_model']['siddon'])
     projection = ProjectionOrdinary(model)
     lors = np.load(config['input']['listmode']['path_file'])
     projection_data = ListModeData(lors,
                                    np.ones([lors.shape[0]], np.float32))
     image_config = config['algorithm']['correction']['atten_correction']
     image = np.load(image_config['path_file'])
     center = image_config['center']
     size = image_config['size']
     g = Attenuation('attenuation', projection, projection_data, image,
                     center, size)
     g.make()
     with Session() as sess:
         value = g.run(sess)
     sess.reset()
     len_lors = np.power(lors[:, 3] - lors[:, 0], 2) + np.power(
         lors[:, 4] - lors[:, 1], 2) + np.power(lors[:, 5] - lors[:, 2], 2)
     weight = 1.0 / (np.exp(-value * len_lors) + sys.float_info.min)
     previous_result = np.load(
         '/mnt/gluster/Techpi/attenuation/test2/result.npy')[:, 7]
     assert all_close(previous_result, weight)
コード例 #12
0
 def test_update_time(self):
     time = np.array([6878008,6882499,6882499,8082068,8084519,8084519,8084830,8088913,
                     8088913,8089688,8090193,8597195,10422958,10423383,10423758,10424489,
                     10426423,10427465,10427495,10429860])
     event = self.data.update_time(time)
     assert all_close(event.time,time)
コード例 #13
0
 def test_split(self):
     data = _split_data_into_module(_rm_loss_data(self.data),16)
     assert all_close(np.vstack((self.data[114:124,:],self.data[390:404,:])),data[0].data)
     assert all_close(np.vstack((self.data[216:232,:],self.data[492:506])),data[6].data)
コード例 #14
0
 def test_rm_loss_data(self):
     result = np.vstack((self.data[114:386,:],self.data[390:662,:]))
     assert all_close(_rm_loss_data(self.data),result)
コード例 #15
0
 def test_update_energy(self):
     energy = np.array([489,278,322,521,176,370,619,324,404,352,198,286,443,277,546,517,218,167,529,228])
     event = self.data.update_energy(energy)
     assert all_close(event.energy,energy)
コード例 #16
0
ファイル: test_base.py プロジェクト: twj2417/DPAD
 def test_effective_data(self):
     result = np.array([[98, 1, 77, 142], [210, 234, 93, 143]])
     assert all_close(self.data.extract_effective_data(), result)
コード例 #17
0
 def test_update_crystalid(self):
     relation = np.arange(1,101)
     result = 100-np.array([35,21,24,11,14,78,92,67])
     assert all_close(self.data.update_crystal_id(relation).channel_id,result)
コード例 #18
0
 def test_channelid(self):
     channel_id = np.array([34,20,23,10,13,77,91,66])
     assert all_close(self.data.channel_id,channel_id)
コード例 #19
0
 def test_energy(self):
     energy = np.array([443,277,546,517,218,529,167,228])
     assert all_close(self.data.energy,energy)
コード例 #20
0
 def test_time(self):
     time = np.array([10422958,10423383,10423758,10424489,10426423,10427495,10427465,10429860])
     assert all_close(self.data.time,time)