def execute(self, namespace): from PYME.IO.image import ImageBounds inp = namespace[self.inputLocalizations] if not isinstance(inp, tabular.ColourFilter): cf = tabular.ColourFilter(inp, None) print('Created colour filter with chans: %s' % cf.getColourChans()) cf.mdh = inp.mdh else: cf = inp #default to taking min and max localizations as image bounds imb = ImageBounds.estimateFromSource(inp) if self.zBoundsMode == 'min-max': self.zBounds[0], self.zBounds[1] = float(imb.z0), float(imb.z1) if (self.xyBoundsMode == 'inherit' ) and not (getattr(inp, 'imageBounds', None) is None): imb = inp.imageBounds elif self.xyBoundsMode == 'metadata': imb = ImageBounds.extractFromMetadata(inp.mdh) elif self.xyBoundsMode == 'manual': imb.x0, imb.y0, imb.x1, imb.y1 = self.manualXYBounds cf.imageBounds = imb renderer = renderers.RENDERERS[str(self.renderingModule)](None, cf) namespace[self.outputImage] = renderer.Generate(self.trait_get())
def execute(self, namespace): inp = namespace[self.inputName] map = tabular.ColourFilter(inp, currentColour=self.channel) if 'mdh' in dir(inp): map.mdh = inp.mdh namespace[self.outputName] = map
def RegenFilter(self): if not self.selectedDataSource is None: self.filter = inpFilt.ResultsFilter(self.selectedDataSource, **self.filterKeys) if self.mapping: self.mapping.resultsSource = self.filter else: self.mapping = inpFilt.MappingFilter(self.filter) if not self.colourFilter: self.colourFilter = inpFilt.ColourFilter(self.mapping, self) self.edb = None self.objects = None self.GeneratedMeasures = {}
def Rebuild(self, **kwargs): """ Rebuild the pipeline. Called when the selected data source is changed/modified and/or the filter is changed. """ for s in self.dataSources.values(): if 'setMapping' in dir(s): #keep raw measurements available s.setMapping('x_raw', 'x') s.setMapping('y_raw', 'y') if 'z' in s.keys(): s.setMapping('z_raw', 'z') if not self.selectedDataSource is None: if not self.mapping is None: # copy any mapping we might have made across to the new mapping filter (should fix drift correction) # TODO - make drift correction a recipe module so that we don't need this code. Long term we should be # ditching the mapping filter here. old_mapping = self.mapping self.mapping = tabular.MappingFilter(self.selectedDataSource) self.mapping.mappings.update(old_mapping.mappings) else: self.mapping = tabular.MappingFilter(self.selectedDataSource) #the filter, however needs to be re-generated with new keys and or data source self.filter = tabular.ResultsFilter(self.mapping, **self.filterKeys) #we can also recycle the colour filter if self.colourFilter is None: self.colourFilter = tabular.ColourFilter(self.filter) else: self.colourFilter.resultsSource = self.filter #self._process_colour() self.ready = True self.ClearGenerated()