Exemplo n.º 1
0
def test_slice_viewmodel_displays_app_section_image():
    model = AppModel(_injector=Mock(DependencyInjector))
    view = SliceViewModel(_model=model)

    for _ in range(6):  # Run multiple iterations to check link
        image = np.random.randint(1, 10, size=(4, 4))
        model.section_image = image
        npt.assert_almost_equal(view.section_image, image)
Exemplo n.º 2
0
def test_slice_viewmodel_displays_app_clim2d_values():
    model = AppModel(_injector=Mock(DependencyInjector))
    view = SliceViewModel(_model=model)

    for _ in range(6):  # Run multiple iterations to check link
        image = np.random.randint(1, 10, size=(4, 4))
        model.section_image = image
        model.clim_2d = (np.random.random() * 0.5,
                         np.random.random() * 0.5 + 0.5)
        assert view.clim == model.clim_2d_values
Exemplo n.º 3
0
def test_atlas_camera_center_and_scale_depend_on_the_atlas_shape_and_resolution(
):
    app_model = AppModel(
        _injector=DependencyInjector(),
        coronal_atlas_image=np.random.randint(0, 100, (10, 10), np.uint16),
    )
    atlas_section_view = AtlasSectionViewModel(plane='coronal',
                                               _model=app_model)
Exemplo n.º 4
0
def test_volume_viewmodel_multiple_slices_visible(app_model: AppModel,
                                                  view_model: VolumeViewModel):
    image1 = SectionViewData(image=np.random.randint(0, 100, size=(3, 3)),
                             transform=np.eye(4),
                             clim=(0, 2))
    image2 = SectionViewData(image=np.random.randint(0, 100, size=(3, 3)),
                             transform=np.eye(4),
                             clim=(0, 2))
    app_model.loaded_sections = [image1, image2]
    assert view_model.sections == app_model.loaded_sections
Exemplo n.º 5
0
def test_atlas_section_viewmodel_updates_atlas_section_image_to_match_cooresponding_coord(
        plane):
    app_model = AppModel(_injector=DependencyInjector(),
                         superior=2,
                         anterior=5,
                         right=10)
    atlas_section_view = AtlasSectionViewModel(plane=plane, _model=app_model)
    section_image = np.random.randint(0, 100, (10, 10), np.uint16)
    setattr(app_model, f"{plane}_atlas_image", section_image)
    npt.assert_almost_equal(atlas_section_view.atlas_section_image,
                            section_image)
Exemplo n.º 6
0
def launch_gui(create_qapp: bool = True):
    # Set special os environ if mac Big Sur is being used
    # https://stackoverflow.com/questions/64818879/is-there-any-solution-regarding-to-pyqt-library-doesnt-work-in-mac-os-big-sur
    if is_mac_big_sur():
        os.environ['QT_MAC_WANTS_LAYER'] = '1'

    # Initialize the State
    injector = DependencyInjector(
        _repo=InMemoryRepo(),
        _remote_atlas_reader=BrainglobeRemoteAtlasReader(),
        _local_atlas_reader=ImioLocalAtlasReader(),
        _image_reader=ImageReader(),
    )

    # Wire up the GUI
    if create_qapp:
        app = QApplication([])

    model = AppModel(_injector=injector)

    coronal_section_view = AtlasSectionView(
        _model=AtlasSectionViewModel(plane='coronal', _model=model))
    axial_section_view = AtlasSectionView(
        _model=AtlasSectionViewModel(plane='axial', _model=model))
    sagittal_section_view = AtlasSectionView(
        _model=AtlasSectionViewModel(plane='sagittal', _model=model))
    slice_view = SliceView(_model=SliceViewModel(_model=model))
    volume_view = VolumeView(_model=VolumeViewModel(_model=model))
    sidebar_view = SidebarView(_model=SidebarViewModel(_model=model))

    window = MainWindowView(
        _model=MainWindowViewModel(_model=model),
        coronal_widget=coronal_section_view.qt_widget,
        axial_widget=axial_section_view.qt_widget,
        sagittal_widget=sagittal_section_view.qt_widget,
        volume_widget=volume_view.qt_widget,
        slice_widget=slice_view.qt_widget,
        side_controls=sidebar_view.qt_widget,
    )

    # Start the Event Loop!
    if create_qapp:
        app.exec_()

    return window
Exemplo n.º 7
0
def test_load_section_appends_new_section_and_updates_current_section_id():
    DI = Mock(DependencyInjector)
    load_section = Mock(LoadSectionCommand)
    load_section.return_value = Ok(
        LoadImageData(section_id=uuid4(),
                      section_image=numpy.empty([4, 4]),
                      resolution_um=200,
                      num_channels=1))

    DI.build.return_value = load_section
    model = AppModel(_injector=DI)
    model.update_section = Mock()
    model.load_section(filename='data.tiff')

    assert len(model.loaded_sections) == 1

    model.load_section(filename='data2.tiff')

    assert len(model.loaded_sections) == 2
Exemplo n.º 8
0
def app_model():
    app_model = AppModel(_injector=Mock(DependencyInjector))
    return app_model