Skip to content
Kai Karius edited this page Sep 6, 2012 · 4 revisions

#Iterator# ##Basic Principle##

The following graphic illustrates the basic principle:

picture alt

  1. Segmentation: In our example the horizontal axis corresponds to a spatial dimension, the vertical axis corresponds to the channel dimension. As one can see, for each channel in the source array exist three channels in the target array. The roi is segmented into three parts according to which source channel they can be obtained from.

  2. Map To Source: Let us focus on segment 1. It gets mapped to the third source channel, additionally there might be a halo in the spatial dimension (to extend the kernel of the filter).

  3. Mask: It might be the case that the filter oder more generally spoken the function we use does not return the specified segment, but all three channels plus the halo. We have to "cut out" the parts we want, this is done by the mask. Each mask segment is congruent to its target segment.

##Implementation##

In the OpBaseVigraFilter the iterator is called like this:

        nIt = newIterator(origRoi,srcGrid,trgtGrid,timeIndex=timeIndex,channelIndex = channelIndex,halo = sigma,style = 'lazyflow')
        for src,trgt,mask in nIt:
            result[trgt] = self.vigraFilter(source = source[src])[mask]

The parameters have the following meaning:

  • origRoi: The original roi, its coordinate System being the target coordinates (in a lazyflow operator the roi refers to the inputshape)

  • srcGrid: The segmentation grid of the source array. In our example it would be something like (20,1), when the spatial dimension is 20. Meaning: begin every 20 spatial units and at each channel a new segment.

  • trgtGrid: The segmentation grid of the target array. In our example it would be (20,3).

  • timeIndex: The index of the time dimension in the roi. If not present, its set to None. This is important, because vigra filters dont filter multiple time slices, one has to hand each timeSlice individually. This feature can be applied for every axis, its set in the self.hardBind variable.

	So a slicing in a txyc array for example would not look like this:
	[slice(0,1,None),slice(0,20,None),slice(0,20,None),slice(0,3,None)]
	[slice(1,2,None),slice(0,20,None),slice(0,20,None),slice(0,3,None)]
	.
	.
	.


	But like this:

	[0,slice(0,20,None),slice(0,20,None),slice(0,3,None)]
	[1,slice(0,20,None),slice(0,20,None),slice(0,3,None)]
	.
	.
	.
  • channelIndex: Index of the channelAxis. Its used to determined spatial features of the array

  • halo: The spatial halo of the array, momentarily a feature tightly knit into the operator logic. The relationship between srcGrid, trgtGrid and halo is fixed. Carefull with this.

  • style: A specific way of handling the input. The iterator is capable of spatial segmentations, which are not used in lazyflow. The only style options right now are 'lazyflow' and None.

Clone this wiki locally