Skip to content

Commit

Permalink
create labels with an extra dimension for 1 channel and set colormaps…
Browse files Browse the repository at this point in the history
… in sample data
  • Loading branch information
volker-baecker committed Nov 26, 2024
1 parent 1113fb7 commit 446345f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
21 changes: 14 additions & 7 deletions src/segment_embryo/_sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,33 @@ def make_sample_data():
# Check the documentation for more information about the
# add_image_kwargs
# https://napari.org/stable/api/napari.Viewer.html#napari.Viewer.add_image
scale = (1000, 76.0005, 76.0005 )
scale = (1, 1000, 76.0005, 76.0005)
units = ('pixel', 'nm', 'nm', 'nm')
nucleiData = io.imread('https://dev.mri.cnrs.fr/attachments/download/3597/C1-240628_DAPI_MEMBRITE-546_EPHA-488_TBXT-594_OTX-647_SLOWFADE_2.tif')
nuclei = numpy.array(nucleiData)
nuclei = numpy.array([numpy.array(nucleiData)])
spotsData = io.imread('https://dev.mri.cnrs.fr/attachments/download/3595/C4-240628_DAPI_MEMBRITE-546_EPHA-488_TBXT-594_OTX-647_SLOWFADE_2.tif')
spots = numpy.array(spotsData)
spots = numpy.array([numpy.array(spotsData)])
membranesData = io.imread('https://dev.mri.cnrs.fr/attachments/download/3596/C5-240628_DAPI_MEMBRITE-546_EPHA-488_TBXT-594_OTX-647_SLOWFADE_2.tif')
membranes = numpy.array(membranesData)
membranes = numpy.array([numpy.array(membranesData)])

return [(nuclei,
{'scale': scale,
'units': ('nm', 'nm', 'nm'),
'units': units,
'colormap': 'bop blue',
'blending': "additive",
'name': 'nuclei (segment-embryo example image)'}),
(spots,
{'scale': scale,
'units': ('nm', 'nm', 'nm'),
'units': units,
'colormap': 'red',
'blending': "additive",
'name': 'spots (segment-embryo example image)'},
),
(membranes,
{'scale': scale,
'units': ('nm', 'nm', 'nm'),
'units': units,
'colormap': 'bop orange',
'blending': "additive",
'name': 'membranes (segment-embryo example image)'},
)
]
9 changes: 6 additions & 3 deletions src/segment_embryo/_widget.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import time
from typing import TYPE_CHECKING

import numpy as np
from PyQt5.QtWidgets import QGroupBox, QFormLayout, QVBoxLayout
from qtpy.QtWidgets import QHBoxLayout, QPushButton, QWidget
from segment_embryo.napari_util import NapariUtil
Expand Down Expand Up @@ -91,10 +93,11 @@ def updateLayerSelectionComboBoxes(self):
def _new_segmentation(self, mask):
membranesLayerName = self.membranesLayerCombo.currentText()
name = "Labels of " + membranesLayerName
self.viewer.add_labels(mask, name=name)
self.viewer.layers[name].scale = self.viewer.layers[membranesLayerName].scale[-3: ]
maskImage = np.array([mask])
self.viewer.add_labels(maskImage, name=name)
self.viewer.layers[name].scale = self.viewer.layers[membranesLayerName].scale[-4: ]
self.viewer.layers[name].translate = self.viewer.layers[membranesLayerName].translate[-3: ]
self.viewer.layers[name].units = self.viewer.layers[membranesLayerName].units[-3: ]
self.viewer.layers[name].units = self.viewer.layers[membranesLayerName].units[-4: ]
self.progressThread.stop()


Expand Down

0 comments on commit 446345f

Please sign in to comment.