Skip to content

Commit

Permalink
Merge pull request #72 from PiMaV/v1.2.2
Browse files Browse the repository at this point in the history
Version 1.3.0
  • Loading branch information
irkri authored Jan 7, 2025
2 parents ca34eb9 + 8a60d94 commit bcf2feb
Show file tree
Hide file tree
Showing 14 changed files with 1,469 additions and 942 deletions.
14 changes: 7 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ __pycache__/
# C extensions
*.so

# BLITZ related stuff:
_cache.ini

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
poetry.lock

# Distribution / packaging
Expand Down Expand Up @@ -97,13 +104,6 @@ ipython_config.py
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
Expand Down
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,39 @@
- [Quick Start Guide](docs/walkthrough.md)
- [Core Functionalities](docs/Tabs_explained.md)



## Development

To compile and develop locally:

1. Clone the repository:
```bash
git clone https://github.com/CodeSchmiedeHGW/BLITZ.git
cd BLITZ
```

$ git clone https://github.com/CodeSchmiedeHGW/BLITZ.git
$ cd BLITZ

2. Set up a virtual environment and install dependencies:
```bash
pip install poetry
poetry install
poetry run python -m blitz

$ pip install poetry
$ poetry install
$ poetry run python -m blitz

Sometimes the installation with poetry might fail due to package restrictions with ``PyQt5``.
For a quick fix, comment out the following three lines in [pyproject.toml](pyproject.toml).
```
3. To create a binary executable:
```bash
pyinstaller --onefile --noconsole --icon=./resources/icon/blitz.ico blitz_main.py
# PyQt5 = "^5.15.11"
# pyqtgraph = "^0.13.7"
# QDarkStyle = "^3.2.3"
```
Afterwards, just install these packages via ``pip`` inside the newly created virtual
environment:
$ poetry shell
$ python -m pip install PyQt5==5.15.11
$ python -m pip install pyqtgraph==0.13.7
$ python -m pip install QDarkStyle==3.2.3
3. To create a binary executable:
$ pyinstaller --onefile --noconsole --icon=./resources/icon/blitz.ico blitz_main.py
## Additional Resources
Expand Down
2 changes: 1 addition & 1 deletion blitz/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "1.2.1"
__version__ = "1.3.0"

from . import data, layout
55 changes: 29 additions & 26 deletions blitz/data/image.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Any, Literal, Optional
from typing import Literal, Optional

import numpy as np
import pyqtgraph as pg
Expand Down Expand Up @@ -28,6 +28,11 @@ class VideoMetaData(MetaData):
codec: str


@dataclass(kw_only=True)
class DicomMetaData(MetaData):
sequence_number: int


class ImageData:

def __init__(
Expand All @@ -41,6 +46,7 @@ def __init__(
self._mask: tuple[slice, slice, slice] | None = None
self._image_mask: np.ndarray | None = None
self._cropped: tuple[int, int] | None = None
self._save_cropped: tuple[int, int] | None = None
self._transposed = False
self._flipped_x = False
self._flipped_y = False
Expand Down Expand Up @@ -101,6 +107,7 @@ def crop(self, left: int, right: int, keep: bool = False) -> None:
else:
self._cropped = None
self._image = self._image[left:right+1]
self._save_cropped = (left, right)

def undo_crop(self) -> bool:
if self._cropped is None:
Expand Down Expand Up @@ -187,11 +194,11 @@ def normalize(
def unravel(self) -> None:
self._redop = None

def mask(self, roi: pg.ROI) -> None:
def mask(self, roi: pg.ROI) -> bool:
if self._transposed or self._flipped_x or self._flipped_y:
log("Masking not available while data is flipped or transposed",
color="red")
return
return False
pos = roi.pos()
size = roi.size()
x_start = max(0, int(pos[0]))
Expand All @@ -209,6 +216,7 @@ def mask(self, roi: pg.ROI) -> None:
self._mask = (
slice(None, None), slice(x_start, x_stop), slice(y_start, y_stop),
)
return True

def mask_range(self, range_: tuple[int, int, int, int]) -> None:
self._mask = (
Expand All @@ -225,9 +233,12 @@ def image_mask(self, mask: "ImageData") -> None:
else:
self._image_mask = mask.image[0].astype(bool)

def reset_mask(self) -> None:
self._mask = None
self._image_mask = None
def reset_mask(self) -> bool:
if self._mask is not None:
self._mask = None
self._image_mask = None
return True
return False

def transpose(self) -> None:
self._transposed = not self._transposed
Expand All @@ -238,23 +249,15 @@ def flip_x(self) -> None:
def flip_y(self) -> None:
self._flipped_y = not self._flipped_y

def save_options(self) -> None:
settings.set("data/flipped_x", self._flipped_x)
settings.set("data/flipped_x", self._flipped_x)
settings.set("data/transposed", self._transposed)
if self._mask is not None:
settings.set("data/mask", self._mask)
if self._cropped is not None:
settings.set("data/cropped", self._cropped)

def load_options(self) -> None:
if settings.get("data/flipped_x"):
self.flip_x()
if settings.get("data/flipped_x"):
self.flip_y()
if settings.get("data/transposed"):
self.transpose()
if mask := settings.get("data/mask"):
self._mask = mask
if cropped := settings.get("data/cropped"):
self._cropped = cropped
def get_mask(self) -> tuple[slice, slice, slice] | None:
return self._mask

def set_mask(self, mask: tuple[slice, slice, slice] | None):
self._mask = mask

def get_crop(self) -> tuple[int, int] | None:
return self._save_cropped

def set_crop(self, crop: tuple[int, int] | None):
self._save_cropped = crop
self._cropped = crop
Loading

0 comments on commit bcf2feb

Please sign in to comment.