Skip to content

Commit

Permalink
Merge pull request InsightSoftwareConsortium#724 from PaulHax/vmin-vmax
Browse files Browse the repository at this point in the history
ENH: Add vmin and vmax to viewer
  • Loading branch information
thewtex authored Dec 21, 2023
2 parents a6a38cf + 3b6e2ba commit d20b17b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
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"

0 comments on commit d20b17b

Please sign in to comment.