def get_airlab_transformed_coms(): shared_landmarks = get_shared_landmarks_between_dk52_and_atlas() atlas_com_dict = get_atlas_com() DK52_com_dict = get_dk52_com() atlas_com = np.array([atlas_com_dict[landmark] for landmark in shared_landmarks]) DK52_com_shared = {} for landmark in shared_landmarks: DK52_com_shared[landmark] = DK52_com_dict[landmark] prep_list = get_prep_list_for_rough_alignment_test() air_lab_transformed_list = [] air_lab_aligned_list = [] for prepi in prep_list: airlab_aligned_coms = {} transform = get_tranformation(prepi) airlab_transformed_coms = {} for name, com in DK52_com_shared.items(): com = np.array(com, dtype=float)/np.array([0.325,0.325,20]) airlab_transformed_coms[name] = (transform.forward_point(com)*np.array([0.325,0.325,20])).tolist() aligned_com,_ = get_and_apply_transform(np.array(list(airlab_transformed_coms.values())),atlas_com) for i in range(len(aligned_com)): name = list(airlab_transformed_coms.keys())[i] airlab_aligned_coms[name] = aligned_com[i] air_lab_transformed_list.append(airlab_transformed_coms) air_lab_aligned_list.append(airlab_aligned_coms) return air_lab_transformed_list,air_lab_aligned_list
def get_transformed_coms(): prep_list_for_rough_alignment = get_prep_list_for_rough_alignment_test() atlas_com = get_atlas_com() transformed_coms = [] for prepi in prep_list_for_rough_alignment: DK52_com_aligned_to_prep = get_DK52_com_aligned_to_prepi(prepi) DK52_com_aligned_to_atlas,_= get_and_apply_transform(DK52_com_aligned_to_prep,atlas_com) transformed_coms.append(DK52_com_aligned_to_atlas) transformed_coms = np.array(transformed_coms) return transformed_coms
def get_demons_diagonastics(): prep_list_for_rough_alignment = get_prep_list_for_rough_alignment_test() atlas_com_aligned_to_DK52 = get_atlas_com_aligned_to_DK52() reference_coms = [] transformed_coms = [] for prepi in prep_list_for_rough_alignment: print('loading demons transformation for prep: ' + prepi) demons_transform = get_demons_transform(prepi) reference_com = get_reference_com(prepi) transformed_com = transform_point_demons(demons_transform, atlas_com_aligned_to_DK52) transformed_coms.append(transformed_com) reference_coms.append(reference_com) transformed_coms = np.array(transformed_coms) reference_coms = np.array(reference_coms) return reference_coms, transformed_coms, atlas_com_aligned_to_DK52
def get_itk_demons_transformed_coms(): shared_landmarks = get_shared_landmarks_between_dk52_and_atlas() atlas_com_dict = get_atlas_com() DK52_com_dict = get_dk52_com() atlas_com = np.array([atlas_com_dict[landmark] for landmark in shared_landmarks]) DK52_com = np.array([DK52_com_dict[landmark] for landmark in shared_landmarks]) prep_list = get_prep_list_for_rough_alignment_test() itk_transformed_coms = [] itk_aligned_coms = [] for prepi in prep_list: demons_transform = get_demons_transform(prepi) DK52_com_transformed = transform_point_demons(demons_transform,DK52_com) DK52_com_aligned,_ = get_and_apply_transform(DK52_com_transformed,atlas_com) DK52_com_transformed = dict(zip(shared_landmarks,DK52_com_transformed)) DK52_com_aligned = dict(zip(shared_landmarks,DK52_com_aligned)) itk_transformed_coms.append(DK52_com_transformed) itk_aligned_coms.append(DK52_com_aligned) return itk_transformed_coms,itk_aligned_coms
def get_kui_transformed(): prep_list = get_prep_list_for_rough_alignment_test() kui_transformed_com = [] for prepi in prep_list: kui_transformed_com.append(get_transformed_com_dict(prepi)) return kui_transformed_com
air_lab_aligned_list.append(airlab_aligned_coms) return air_lab_transformed_list,air_lab_aligned_list if __name__ == '__main__': atlas_com_dict = get_atlas_com() dk52_com = get_dk52_com() prep_coms = get_prep_coms() affine_transformed_coms_itk,affine_aligned_coms_itk = get_itk_affine_transformed_coms() demons_transformed_coms_itk,demons_aligned_coms_itk = get_itk_demons_transformed_coms() transformed_coms_airlab,aligned_coms_airlab = get_airlab_transformed_coms() kui_airlab_aligned_coms = get_kui_airlab() kui_transformed_com = get_kui_transformed() atlas_prep_list = ['Atlas' for _ in range(5)] dk52_prep_list = ["DK52" for _ in range(5)] figs = [] prep_list = get_prep_list_for_rough_alignment_test() # compare_two_com_dict(dk52_com,prep_coms[0],['DK52' , 'DK39']) # compare_two_com_dict(kui_transformed_com[0],prep_coms[0],['DK52 kui airlab' , 'DK39']) # compare_two_com_dict(transformed_coms_airlab[0],prep_coms[0],['DK52 beth airlab' , 'DK39']) # compare_two_com_dict(affine_transformed_coms_itk[0],prep_coms[0],['DK52 kui airlab' , 'DK39']) print('plotting DK52 annotation against atlas') fig = get_fig_two_com_dict(dk52_com,atlas_com_dict,['DK52' , 'Atlas']) figs.append(ploty_to_matplot(fig)) print('plotting DK52 to annotation before image to image alignment') figs.append(get_fig_offset_from_coms_to_a_reference(prep_coms,dk52_com, get_prep_list_for_rough_alignment_test,get_all_landmarks_in_specimens, 'DK52 to brain preps before alignment')) fig = get_fig_corresponding_coms_in_dict_to_reference(prep_coms,dk52_com,prep_list,dk52_prep_list) figs.append(ploty_to_matplot(fig)) print('plotting DK52 after affine transform from itk')