Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helmholtz design #85

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8495a28
Open browse window by double click.
KorenMary Feb 25, 2024
f01a6bb
Change welcome window design
KorenMary Feb 25, 2024
68b9587
Change the style of the main_window
KorenMary Feb 26, 2024
e19e6a6
Add image view in main window
KorenMary Feb 26, 2024
439b9ef
Apply HelmholtzAI palette
KorenMary Feb 26, 2024
f5ef1bf
Add tips in welcome window.
KorenMary Mar 3, 2024
382add1
Add tips in welcome window.
KorenMary Mar 3, 2024
1443e47
Customize the header in the QFileSystemModel.
KorenMary Mar 3, 2024
3f7a33f
Visualize the image and masks together in a QTreeView.
KorenMary Mar 4, 2024
d8cdfd5
Merge branch 'frontend-style-tests' into helmholtz_design
KorenMary Mar 7, 2024
1b241cd
Hide masks from the file lists, but they are still clickable
KorenMary Mar 8, 2024
c70365f
add napari window style
KorenMary Mar 8, 2024
38f7be1
Modify the appearance of the masks in the file view.
KorenMary Mar 10, 2024
2d8b3df
Clean up the imports section
KorenMary Mar 11, 2024
358c16c
Change the title in the test.
KorenMary Mar 11, 2024
9b80454
Merge branch 'main' into helmholtz_design
christinab12 Mar 14, 2024
0d7ae1c
Add try catch for napari window.
KorenMary Mar 17, 2024
773df7e
Merge branch 'helmholtz_design' of https://github.com/HelmholtzAI-Con…
KorenMary Mar 17, 2024
9a67bea
Issue #58
KorenMary Mar 17, 2024
37e5aa5
Change the style of the Browse Buttons.
KorenMary Mar 17, 2024
052c481
formatting
Mar 21, 2024
93a436d
Merge branch 'helmholtz_design' of https://github.com/HelmholtzAI-Con…
Mar 21, 2024
8a605e3
moved MyQFileSystemModel and cleaned up
christinab12 Jul 16, 2024
f3a986b
clean structure
christinab12 Jul 16, 2024
9f66d7d
main change is to view masks again using instance channel
christinab12 Jul 17, 2024
4699f0f
Merge branch 'main' into helmholtz_design
christinab12 Jul 17, 2024
3e3c09d
fixed tests
christinab12 Jul 23, 2024
2e6bf9c
Merge branch 'helmholtz_design' of https://github.com/HelmholtzAI-Con…
christinab12 Jul 23, 2024
ffd270a
add nm to server install
christinab12 Jul 23, 2024
021840f
update workflow yml
christinab12 Jul 23, 2024
0d144a6
removed one test from main window
christinab12 Jul 23, 2024
8c82b56
fix error thrown when removing outlier
christinab12 Jul 24, 2024
0ce2ca2
add opencv
francesco-campi Aug 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
powershell gl-ci-helpers/appveyor/install_opengl.ps1

- name: Install dependencies
- name: Install client dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools
Expand All @@ -52,6 +52,8 @@ jobs:

- name: Install server dependencies (for communication tests)
run: |
pip install numpy
pip install wheel
pip install -e ".[dev]"
working-directory: src/server

Expand Down Expand Up @@ -87,7 +89,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
- name: Install server dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
Expand Down
64 changes: 64 additions & 0 deletions src/client/dcp_client/gui/_custom_qt_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from PyQt5.QtWidgets import QFileIconProvider, QStyledItemDelegate
from PyQt5.QtCore import QSize
from PyQt5.QtGui import QPixmap, QIcon

from dcp_client.utils import settings

class IconProvider(QFileIconProvider):
def __init__(self) -> None:
"""Initializes the IconProvider with the default icon size."""
super().__init__()
self.ICON_SIZE = QSize(512, 512)

def icon(self, type: QFileIconProvider.IconType) -> QIcon:
"""Returns the icon for the specified file type.

:param type: The type of the file for which the icon is requested.
:type type: QFileIconProvider.IconType
:return: The icon for the file type.
:rtype: QIcon
"""
try:
fn = type.filePath()
except AttributeError:
return super().icon(type) # TODO handle exception differently?

if fn.endswith(settings.accepted_types):
a = QPixmap(self.ICON_SIZE)
# a = a.scaled(QSize(1024, 1024))
a.load(fn)
return QIcon(a)
else:
return super().icon(type)


class CustomItemDelegate(QStyledItemDelegate):
"""
A custom item delegate for setting a fixed height for items in a view.
This delegate overrides the sizeHint method to set a fixed height for items.
"""
def __init__(self, parent=None):
"""
Initialize the CustomItemDelegate.

:param parent: The parent QObject. Default is None.
:type parent: QObject
"""
super().__init__(parent)

def sizeHint(self, option, index):
"""
Returns the size hint for the item specified by the given index.

:param option: The parameters used to draw the item.
:type option: QStyleOptionViewItem

:param index: The model index of the item.
:type index: QModelIndex

:returns: The size hint for the item.
:rtype: QSize
"""
size = super().sizeHint(option, index)
size.setHeight(100)
return size
112 changes: 112 additions & 0 deletions src/client/dcp_client/gui/_filesystem_wig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import os
import numpy as np
from skimage.io import imread
from skimage.color import label2rgb


from PyQt5.QtWidgets import QFileSystemModel
from PyQt5.QtCore import Qt, QVariant, QDir
from PyQt5.QtGui import QImage

from dcp_client.utils import settings

class MyQFileSystemModel(QFileSystemModel):
def __init__(self, app):
"""
Initializes a custom QFileSystemModel
"""
super().__init__()
self.app = app
self.img_x = 100
self.img_y = 100

def setFilter(self, filters):
"""
Sets filters for the model.

:param filters: The filters to be applied. (QDir.Filters)
"""
filters |= QDir.NoDotAndDotDot | QDir.AllDirs | QDir.Files
super().setFilter(filters)

# Exclude files containing '_seg' in their names
self.addFilter(lambda fileInfo: "_seg" not in fileInfo.fileName())

def addFilter(self, filterFunc):
"""
Adds a custom filter function to the model.

:param filterFunc: The filter function to be added. (function)
"""
self.filterFunc = filterFunc

def headerData(self, section, orientation, role):
"""
Reimplemented method to provide custom header data for the model's headers.

:param section: The section (column) index. (int)
:param orientation: The orientation of the header. (Qt.Orientation)
:param role: The role of the header data. (int)
:rtype: QVariant
"""
if section == 0 and role == Qt.DisplayRole:
return ""
else:
return super().headerData(section, orientation, role)


def data(self, index, role=Qt.DisplayRole):
"""
Reimplemented method to provide custom data for the model's items.

:param index: The index of the item. (QModelIndex)
:param role: The role of the data. (int)
:rtype: QVariant
"""
if not index.isValid():
return QVariant()

if role == Qt.DecorationRole:

filepath_img = self.filePath(index)
# if an image of our dataset
if filepath_img.endswith(settings.accepted_types):

# if a mask make sure it is displayed properly
if "_seg" in filepath_img and os.path.exists(filepath_img):
img = imread(filepath_img)
if img.ndim > 2: img = img[0]
img = label2rgb(img)
img = (255 * img.copy()).astype(
np.uint8
)#np.transpose(img, (1, 0, 2))
height, width = img.shape[0], img.shape[1]
img = QImage(img,
width,
height,
3 * width,
QImage.Format_RGB888
)
#img = img.scaled(self.img_x, (width*self.img_x)//height, Qt.KeepAspectRatio)
img = img.scaled(self.img_x, self.img_y, Qt.KeepAspectRatio) # yields the same
else:
img = QImage(filepath_img).scaled(self.img_x, self.img_y, Qt.KeepAspectRatio)
'''
# It would be cool if instead of the mask and the image we could show them both merged
# together with label2rgb if the mask exists - would need to remove _seg files from list
filepath_mask = '.'.join(filepath_img.split('.')[:-1])+'_seg.tiff'
if os.path.exists(filepath_mask):
mask = imread(filepath_mask)
if mask.ndim>2: mask = mask[0]
img = imread(filepath_img, as_gray=True)
img = label2rgb(mask, img)
img = QImage(img,
img.shape[1],
img.shape[0],
QImage.Format_RGB888
).scaled(self.img_x, self.img_y, Qt.KeepAspectRatio)
'''
return img

return super().data(index, role)

Loading
Loading