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

fix(plotting): remove dilation if images are large #914

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 0 additions & 17 deletions tests/test_plottingfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def test_load_mplstyle(style: str, axes_titlesize: int, font_size: float, image_
def test_dilate_binary_image(binary_image: np.ndarray, dilation_iterations: int, expected: np.ndarray) -> None:
"""Test the dilate binary images function of plottingfuncs.py."""
result = dilate_binary_image(binary_image=binary_image, dilation_iterations=dilation_iterations)

np.testing.assert_array_equal(result, expected)


Expand Down Expand Up @@ -277,22 +276,6 @@ def test_high_dpi(minicircle_grain_gaussian_filter: Grains, plotting_config: dic
return fig


@pytest.mark.mpl_image_compare(baseline_dir="resources/img/")
def test_mask_dilation(plotting_config: dict, tmp_path: Path) -> None:
"""Test the plotting of a mask with a different colourmap (blu)."""
plotting_config["mask_cmap"] = "blue"
mask = np.zeros((1024, 1024))
mask[500, :] = 1
fig, _ = Images(
data=RNG.random((1024, 1024)),
output_dir=tmp_path,
filename="mask_dilation",
masked_array=mask,
**plotting_config,
).plot_and_save()
return fig


@pytest.mark.parametrize(
("n", "expected"),
[
Expand Down
2 changes: 1 addition & 1 deletion topostats/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ plotting:
savefig_dpi: 600 # Options : null (defaults to the value in topostats/plotting_dictionary.yaml), see https://afm-spm.github.io/TopoStats/main/configuration.html#further-customisation and https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.savefig.html
pixel_interpolation: null # Options : https://matplotlib.org/stable/gallery/images_contours_and_fields/interpolation_methods.html
image_set: core # Options : all, core
zrange: [-2, 6] # low and high height range for core images (can take [null, null]). low <= high
zrange: [null, null] # low and high height range for core images (can take [null, null]). low <= high
colorbar: true # Options : true, false
axes: true # Options : true, false (due to off being a bool when parsed)
num_ticks: [null, null] # Number of ticks to have along the x and y axes. Options : null (auto) or integer > 1
Expand Down
8 changes: 0 additions & 8 deletions topostats/plottingfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,6 @@ def save_figure(self):
vmax=self.zrange[1],
)
if isinstance(self.masked_array, np.ndarray):
# self.masked_array[self.masked_array != 0] = 1
# If the image is too large for singles to be resolved in the mask, then dilate the mask proportionally
# to image size to enable clear viewing.
# if np.max(self.masked_array.shape) > 500:
# dilation_strength = int(np.max(self.masked_array.shape) / 256)
# self.masked_array = dilate_binary_image(
# binary_image=self.masked_array, dilation_iterations=dilation_strength
# )
mask = np.ma.masked_where(self.masked_array == 0, self.masked_array)
ax.imshow(
mask,
Expand Down
Loading