final private void createActiveLayer()
   {
      // DeferredByteArray3D statemap = fm.getStateMap();
	  int px_zero = 0, px_inside = 0, px_outside = 0; 
	  int grey_zero = 0, grey_inside = 0;
	  
      final DeferredObjectArray3D<StateContainer.States> statemap = init_state.getForSparseField();
      for (int x = 0; x < statemap.getXLength(); x++)
      {
         for (int y = 0; y < statemap.getYLength(); y++)
         {
            for (int z = 0; z < statemap.getZLength(); z++)
            {
               if (statemap.get(x, y, z) == StateContainer.States.ZERO )
               {
                  state[x][y][z] = STATE_ZERO;
                  phi.set(x, y, z, 0);
                  final BandElement element = new BandElement(x, y, z, 0);
                  layers[ZERO_LAYER].add(element);
                  elementLUT.set(x, y, z, element);
                  px_zero++;
                  grey_zero += source.getPixel(x, y, z);
               }
               else if ( statemap.get(x, y, z) == StateContainer.States.INSIDE )
               {
                  state[x][y][z] = INSIDE_FAR;
                  px_inside++;
                  grey_inside += source.getPixel(x, y, z);
               }
               else
               {
                  state[x][y][z] = OUTSIDE_FAR;
                  px_outside++;
               }
            }
         }
      }
      IJ.log("Initiated boundary pixels: " +px_zero+" ZERO, " +px_inside + " INSIDE, "+px_outside + " OUTSIDE");
      if ( px_inside == 0 && px_zero == 0 ) {
       	  invalid = true;
       	  throw new IllegalArgumentException("Level Sets didn't get any starting shape - Aborting");
       }
      
      // TODO median would be better
      if ( this.seed_greyvalue < 0 ) {
    	  if (this.seed_grey_zero) {
    		  this.seed_greyvalue = grey_zero / px_zero;
    	  } else {
    		  this.seed_greyvalue = grey_inside / px_zero;
    	  }
    	  IJ.log("Grey seed not set - setting to mean of ROI boundary = " + this.seed_greyvalue);
      }
   }