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

ENH: Add vmin and vmax to viewer #724

Merged
merged 1 commit into from
Dec 21, 2023
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
2 changes: 2 additions & 0 deletions itkwidgets/_initialization_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def init_params_dict(itk_viewer):
'blend_mode': itk_viewer.setImageBlendMode,
'cmap': itk_viewer.setImageColorMap,
'color_range': itk_viewer.setImageColorRange,
'vmin': itk_viewer.setImageColorRangeMin,
'vmax': itk_viewer.setImageColorRangeMax,
'color_bounds': itk_viewer.setImageColorRangeBounds,
'component_visible': itk_viewer.setImageComponentVisibility,
'gradient_opacity': itk_viewer.setImageGradientOpacity,
Expand Down
27 changes: 27 additions & 0 deletions itkwidgets/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,27 @@ def set_image_color_range(self, range: List[float]):
async def get_image_color_range(self):
return await self.viewer_rpc.itk_viewer.getImageColorRange()

@property
@fetch_value
async def vmin(self):
range = await self.get_image_color_range()
return range[0]
@vmin.setter
@fetch_value
async def vmin(self, vmin: float):
self.queue_request('setImageColorRangeMin', vmin)

@property
@fetch_value
async def vmax(self):
range = await self.get_image_color_range()
return range[1]
@vmax.setter
@fetch_value
async def vmax(self, vmax: float):
self.queue_request('setImageColorRangeMax', vmax)


@fetch_value
def set_image_color_range_bounds(self, range: List[float]):
self.queue_request('setImageColorRangeBounds', range)
Expand Down Expand Up @@ -744,6 +765,12 @@ def view(data=None, **kwargs):
:param color_range: The [min, max] range of the data values mapped to colors for the given image component identified by name.
:type color_range: list, default: The [min, max] range of the data values

:param vmin: Data values below vmin take the bottom color of the color map.
:type vmin: float

:param vmax: Data values above vmax take the top color of the color map.
:type vmax: float

:param color_bounds: The [min, max] range of the data values for color maps that provide a bounds for user inputs.
:type color_bounds: list, default: The [min, max] range of the data values

Expand Down
2 changes: 1 addition & 1 deletion itkwidgets/viewer_config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ITK_VIEWER_SRC = (
"https://bafybeiaceucriosbgkyrnknz3f6je6diihyldqwrxx7l5dkrc5hqgg3kum.on.fleek.co/"
"https://bafybeigczshobl7lpiyj26r6mr2zsibwoiq7ueqmqdfmynqbznvxmfiddq.on.fleek.co/"
)
PYDATA_SPHINX_HREF = "https://cdn.jsdelivr.net/npm/[email protected]/dist/bootstrapUIMachineOptions.js.es.js"
MUI_HREF = "https://cdn.jsdelivr.net/npm/[email protected]/dist/materialUIMachineOptions.js.es.js"