def build(self): main_scroll = ScrollView(do_scroll_x=False) main_grid = GridLayout(cols=1, spacing=100, padding=[0, 50, 0, 50], size_hint_y=None) main_grid.bind(minimum_height=main_grid.setter('height')) main_scroll.add_widget(main_grid) scroll_count = 4 for _ in range(scroll_count): scroll = ScrollView(size_hint_y=None, height=300, do_scroll_y=False) grid = GridLayout(rows=1, spacing=1, size_hint=(None, 1)) grid.bind(minimum_width=grid.setter('width')) scroll.add_widget(grid) for r in range(0, 50): bt = Button(text='Button ' + str(r), size_hint_x=None, width=cm(2)) bt.bind(on_press=self.print_btn) grid.add_widget(bt) main_grid.add_widget(scroll) return main_scroll
border_width=3, border_radius=10, font_kwargs={"bold": True, "italic": True}, dest=(0.1, 0.1, 0.1, 0.1), # position within parent on_click=lambda self, event: self.run_hook("NAVIGATE_TO", "level_select"), ), ScrollView( dest=(0.6, 0.1, 0.35, 0.4), canvas_size_factors=(1.0, 3.0), border_width=3, aspect_ratio=1, children=[ View(bg_color=GREEN, dest=(0.1, 0.0, 0.2, 1.0), margins=(0, 10, 0, 10)), Button(bg_color=RED, dest=(0.4, 0.1, 0.2, 0.2), text="!", on_click=lambda s, e: print("HI")), View(bg_color=BLUE, dest=(0.4, 0.4, 0.2, 0.2)), View(bg_color=MAGENTA, dest=(0.8, 0.6, 0.2, 0.2)), ScrollView( border_width=1, dest=(0.4, 0.7, 0.3, 0.2), canvas_size_factors=(2.0, 2.0), children=[ Image(image=test_image_source) ] ) ] ), ScrollView( dest=(0.1, 0.7, 0.4, 0.2), canvas_size_factors=(2.0, 1.0), border_width=3, children=[ Text(
itk_image_opr = sitk.ReadImage(opr_image_path) image_array_opr = sitk.GetArrayFromImage(itk_image_opr) pr_image_path = os.path.join(patient, 'prostaat.mhd') itk_image_pr = sitk.ReadImage(pr_image_path) image_array_pr = sitk.GetArrayFromImage(itk_image_pr) mr_image_path = os.path.join(patient, 'mr_bffe.mhd') itk_image_mr = sitk.ReadImage(mr_image_path) image_array_mr = sitk.GetArrayFromImage(itk_image_mr) overlay = image_array_mr - 7000 * image_array_pr fig, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(1, 5, figsize=(25, 5)) ScrollView(image_array_unseen).plot(ax1, cmap='gray') ScrollView(overlay).plot(ax2, cmap='gray') ax1.set_title('Unseen') ax2.set_title('Prostate overlay') # Define a new elastix object 'el' with the correct path to elastix el = elastix.ElastixInterface(elastix_path=ELASTIX_PATH) # Execute the registration. Make sure the paths below are correct, and # that the results folder exists from where you are running this script el.register(fixed_image=unseen_image_path, moving_image=mr_image_path, parameters=[ os.path.join('parameterfiles', 'parameters_affine.txt'), os.path.join('parameterfiles', 'parameters_bspline142.txt') ],
#path_to_transformed_image = T.transform_image(im1, output_dir='results') # ## Get the Jacobian matrix #path_to_jacobian_matrix = T.jacobian_matrix(output_dir='results') # ## Get the Jacobian determinant #path_to_jacobian_determinant = T.jacobian_determinant(output_dir='results') # ## Get the full deformation field #path_to_deformation_field = T.deformation_field(output_dir='results') # from scrollview import ScrollView #image = np.load('path/to/image') #aspect_ratio = [2.3, 0.95, 0.95] # i.e. the ElementSpacing aspect_ratio = [2.3, 2.3, 2.3] # i.e. the ElementSpacing # Define viewers for every axis viewer1 = ScrollView(im_arr1) viewer2 = ScrollView(im_arr2) viewer3 = ScrollView(im_arrres) #viewer2 = ScrollView(im.transpose(1, 0, 2)) #viewer3 = ScrollView(im.transpose(2, 0, 1)) # Make three Matplotlib supblots, and populate them with the viewers objects # The aspect ratios of the different axes need to be defined here as well. fig, ax = plt.subplots(1, 3) viewer1.plot(ax[0], cmap='gray', aspect=aspect_ratio[1] / aspect_ratio[2]) viewer2.plot(ax[1], cmap='gray', aspect=aspect_ratio[0] / aspect_ratio[2]) viewer3.plot(ax[2], cmap='gray', aspect=aspect_ratio[0] / aspect_ratio[1]) plt.show()
num_rows = NUM_LEVELS // LEVELS_PER_ROW level_select_layout = [ level_select_buttons[row * LEVELS_PER_ROW:(row + 1) * LEVELS_PER_ROW] for row in range(NUM_LEVELS // LEVELS_PER_ROW) ] level_select_screen = View(children=[ Text(LEVELS_PER_ROW, 0.5, text="Levels", dest=(0.25, 0.0, 0.5, 0.1), **menu_h2_style), # TODO: some sort of border or bg-color change to differentiate this region ScrollView( children=[GridView(level_select_layout, margins=(12, 0) * 2)], canvas_size_factors=(1.0, 2.0), dest=(0.1, 0.1, 0.8, 0.7), ), Button(text="Back", dest=(0.4, 0.85, 0.2, 0.1), on_click=lambda self, event: self.run_hook("NAVIGATE_BACK"), **menu_button_style) ]) # --- Settings Screen --- # # TODO # --- Credits Screen --- # # TODO hoster = Hoster(
patients2 = ['p116', 'p117', 'p119', 'p120', 'p125'] patients3 = ['p127', 'p128', 'p129', 'p133', 'p135'] # load images and masks images_org = [ sitk.GetArrayFromImage(sitk.ReadImage(os.path.join(patient, "mr_bffe.mhd"))) for patient in patients1 ] # normalize images images_norm = normalization(images_org) fig, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(1, 5, figsize=(25, 5)) ScrollView(images_norm[0]).plot(ax1, cmap='gray') ScrollView(images_norm[1]).plot(ax2, cmap='gray') ScrollView(images_norm[2]).plot(ax3, cmap='gray') ScrollView(images_norm[3]).plot(ax4, cmap='gray') ScrollView(images_norm[4]).plot(ax5, cmap='gray') ax3.set_title("genormaliseerd") fig, (ax6, ax7, ax8, ax9, ax10) = plt.subplots(1, 5, figsize=(25, 5)) ScrollView(images_org[0]).plot(ax6, cmap='gray') ScrollView(images_org[1]).plot(ax7, cmap='gray') ScrollView(images_org[2]).plot(ax8, cmap='gray') ScrollView(images_org[3]).plot(ax9, cmap='gray') ScrollView(images_org[4]).plot(ax10, cmap='gray') ax8.set_title("origineel") plt.show()
import matplotlib.pyplot as plt import numpy as np import imageio import os import SimpleITK as sitk from scrollview import ScrollView #image = sitk.ReadImage(r'C:\Users\s166646\Downloads\Capita Selecta\results2\result.0.mhd') image = sitk.ReadImage( r'C:\Users\s166646\Downloads\TrainingData\TrainingData\p102\mr_bffe.mhd') #image = sitk.ReadImage(r'C:\Users\s166646\Downloads\TrainingData\TrainingData\p102\prostaat.mhd') image_array = sitk.GetArrayFromImage(image) #print(image_array) #print(np.max(image_array)) fig, ax = plt.subplots() ScrollView(image_array).plot(ax) #fixed_image = sitk.ReadImage(r'C:\Users\s166646\Downloads\ImagesforPractical\ImagesforPractical\chest_xrays\fixed_image.mhd') #moving_image = sitk.ReadImage(r'C:\Users\s166646\Downloads\ImagesforPractical\ImagesforPractical\chest_xrays\moving_image.mhd') #fixed_image_path = sitk.GetArrayFromImage(fixed_image) #moving_image_path = sitk.GetArrayFromImage(moving_image) #fig, ax = plt.subplots(1, 3, figsize=(20, 5)) #ax[0].imshow(fixed_image_path) #ax[1].imshow(moving_image_path) #ax[2].imshow(image_array[24], cmap='gray') plt.show()
ax.scatter(pos_fixed[0], pos_fixed[1], pos_fixed[2], c='black') ax.set_title('Fixed') ax = fig.add_subplot(1, 3, 2, projection='3d') ax.scatter(pos_moving[0], pos_moving[1], pos_moving[2], c='black') ax.set_title('Moving') ax = fig.add_subplot(1, 3, 3, projection='3d') ax.scatter(pos_transformed[0], pos_transformed[1], pos_transformed[2], c='black') ax.set_title('Transformed') plt.show() ''' #3d beeld test fig, ax = plt.subplots() ScrollView(fixed_img).plot(ax) #resultaat geeft maar een beeld waarmee niet doorheen te scrollen is met touchpad plt.show() ''' ################################################################################################### #quantifying the results #using dice score dice2 = ((2.0 * np.sum(np.logical_and(t_seg_img, fixed_mask))) / (np.sum(t_seg_img) + np.sum(fixed_mask))) print('Dice similarity score 2 is {}'.format(dice2))