Skip to content

Commit c671881

Browse files
committed
changing colormap
1 parent 7353557 commit c671881

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/cardiotensor/analysis/gui_analysis_tool.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
QWidget,
3838
)
3939
from skimage.measure import block_reduce
40+
from matplotlib.colors import Colormap
4041

4142
from cardiotensor.analysis.analysis_functions import (
4243
calculate_intensities,
@@ -45,6 +46,7 @@
4546
save_intensity,
4647
)
4748
from cardiotensor.utils.DataReader import DataReader
49+
from cardiotensor.colormaps.helix_angle import helix_angle_cmap
4850

4951

5052
def np2pixmap(np_img: np.ndarray) -> QPixmap:
@@ -63,6 +65,7 @@ def __init__(
6365
N_line: int = 5,
6466
angle_range: float = 20,
6567
image_mode: str = "HA",
68+
cmap: Colormap | str | None = None,
6669
) -> None:
6770
super().__init__()
6871

@@ -114,6 +117,18 @@ def __init__(
114117
sys.exit(
115118
f"Invalid output mode: {self.image_mode}. Must be 'HA', 'IA', or 'FA'."
116119
)
120+
121+
# choose a default by mode
122+
if cmap is None:
123+
if image_mode in ("HA", "IA"):
124+
self.cmap = helix_angle_cmap # custom HA colormap (callable)
125+
else: # FA
126+
self.cmap = plt.get_cmap("inferno")
127+
elif isinstance(cmap, str):
128+
self.cmap = plt.get_cmap(cmap)
129+
else:
130+
self.cmap = cmap
131+
117132

118133
if self.N_slice > self.data_reader.shape[0]:
119134
raise IndexError(
@@ -396,8 +411,8 @@ def load_image_to_gui(self, current_img: np.ndarray) -> None:
396411
current_img_bin = (current_img_bin + np.abs(minimum)) * (
397412
1 / (maximum - minimum)
398413
)
399-
cmap = plt.get_cmap("hsv")
400-
current_img_rgb = cmap(current_img_bin)
414+
415+
current_img_rgb = self.cmap(current_img_bin)
401416
current_img_rgb = (current_img_rgb[:, :, :3] * 255).astype(np.uint8)
402417

403418
gray_color = [128, 128, 128]

src/cardiotensor/orientation/orientation_computation_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from cardiotensor.utils.utils import convert_to_8bit
1616

1717

18+
1819
def interpolate_points(
1920
points: list[tuple[float, float, float]], N_img: int
2021
) -> np.ndarray:

0 commit comments

Comments
 (0)