Creates a VoxelSpace instance from the image instances belonging
 to this image series.

 @return [VoxelSpace] the created VoxelSpace instance
356354
def to_voxel_space
      raise "This image series has no associated images. Unable to create a VoxelSpace." unless @images.length > 0
      img = @images.first
      # Create the voxel space:
      vs = VoxelSpace.create(img.columns, img.rows, @images.length, img.col_spacing, img.row_spacing, slice_spacing, Coordinate.new(img.pos_x, img.pos_y, img.pos_slice))
      # Fill it with pixel values:
      @images.each_with_index do |image, i|
        vs[true, true, i] = image.narray
      end
      vs
    end
835649
def _create_affine(x_axis, y_axis, z_axis, image_pos, voxel_sizes):
    

    # Create affine matrix (http://nipy.sourceforge.net/nibabel/dicom/dicom_orientation.html#dicom-slice-affine)

    affine = numpy.array(
        [[x_axis[0] * voxel_sizes[0], y_axis[0] * voxel_sizes[1], z_axis[0] * voxel_sizes[2], image_pos[0]],
         [x_axis[1] * voxel_sizes[0], y_axis[1] * voxel_sizes[1], z_axis[1] * voxel_sizes[2], image_pos[1]],
         [x_axis[2] * voxel_sizes[0], y_axis[2] * voxel_sizes[1], z_axis[2] * voxel_sizes[2], image_pos[2]],
         [0, 0, 0, 1]])
    return affine
421261
def create(cls):
        
        if cls not in cls._instances:
            cls._instances[cls] = cls()

        return cls._instances[cls]
504395
def rebuild( self ):
        
        scene       = self.scene()
        if not scene:
            return
        
        self._subpaths = []
        
        grid        = scene.gridRect()
        typ         = self.chartType()
        
        hruler      = scene.horizontalRuler()
        vruler      = scene.verticalRuler()
        
        path        = QPainterPath()
        area        = QPainterPath()
        
        self._buildData.clear()
        self._buildData['path_area'] = area
        
        self.setPos(0, 0)
        
        # draw a line item
        if typ == XChartScene.Type.Line:
            first = True
            pos   = None
            home  = None
            self._ellipses = []
            
            points = self.points()
            if ( self.orientation() == Qt.Horizontal ):
                points.sort(hruler.compareValues, key = lambda x: x[0])
            else:
                points.sort(vruler.compareValues, key = lambda y: y[1])
                points.reverse()
            
            for x, y in self.points():
                pos = scene.mapFromChart(x, y)
                if first:
                    home = QPointF(pos.x(), grid.bottom())
                    area.moveTo(home)
                    area.lineTo(pos)
                    path.moveTo(pos)
                    
                    self._ellipses.append(pos)
                    
                    first = False
                else:
                    path.lineTo(pos)
                    area.lineTo(pos)
                    
                    self._ellipses.append(pos)
            
            if pos and home:
                area.lineTo(pos.x(), grid.bottom())
                area.lineTo(home)
        
        # draw a bar item
        elif typ == XChartScene.Type.Bar:
            barsize = self.barSize()
            horiz   = self.orientation() == Qt.Horizontal
            
            for x, y in self.points():
                pos = scene.mapFromChart(x, y)
                subpath = QPainterPath()
                if horiz:
                    r = min(grid.bottom() - pos.y(), 8)
                    
                    subpath.moveTo(pos.x() - barsize / 2.0, grid.bottom())
                    subpath.lineTo(pos.x() - barsize / 2.0, pos.y() + r)
                    subpath.quadTo(pos.x() - barsize / 2.0, pos.y(),
                                   pos.x() - barsize / 2.0 + r, pos.y())
                    
                    subpath.lineTo(pos.x() + barsize / 2.0 - r, pos.y())
                    subpath.quadTo(pos.x() + barsize / 2.0, pos.y(),
                                   pos.x() + barsize / 2.0, pos.y() + r)
                    
                    subpath.lineTo(pos.x() + barsize / 2.0, grid.bottom())
                    subpath.lineTo(pos.x() - barsize / 2.0, grid.bottom())
                else:
                    subpath.moveTo(grid.left(), pos.y() - barsize / 2.0)
                    subpath.lineTo(pos.x(),     pos.y() - barsize / 2.0)
                    subpath.lineTo(pos.x(),     pos.y() + barsize / 2.0)
                    subpath.lineTo(grid.left(), pos.y() + barsize / 2.0)
                    subpath.lineTo(grid.left(), pos.y() - barsize / 2.0)
                
                path.addPath(subpath)
                self._subpaths.append((x, y, subpath))
        
        # draw a pie chart
        elif typ == XChartScene.Type.Pie:
            if self.orientation() == Qt.Horizontal:
                key_index   = 0
                value_index = 1
                value_ruler = self.verticalRuler()
            else:
                key_index   = 1
                value_index = 0
                value_ruler = self.horizontalRuler()
        
            pie_values = {}
            
            for point in self.points():
                key     = point[key_index]
                value   = point[value_index]
                
                pie_values.setdefault(key, [])
                pie_values[key].append(value)
        
            for key, values in pie_values.items():
                pie_values[key] = value_ruler.calcTotal(values)
            
            total = max(1, value_ruler.calcTotal(pie_values.values()))
            
            # calculate drawing parameters
            center   = self.pieCenter()
            radius   = self.radius()
            diameter = radius * 2
            angle    = 0
            bound    = QRectF(-radius, -radius, diameter, diameter)
            
            for key, value in sorted(pie_values.items(), key = lambda x: x[1]):
                # calculate the percentage
                perc  = float(value) / total
                
                # calculate the angle as the perc * 360
                item_angle = perc * 360
                self.setPos(center)
                
                sub_path = QPainterPath()
                sub_path.arcTo(bound, angle, item_angle)
                sub_path.lineTo(0, 0)
                
                path.addPath(sub_path)
                self._subpaths.append((key, value, sub_path))
                
                angle += item_angle
                
        self.setPath(path)
        self._dirty = False
37619
public NDArray<T> cloneArray() {
        NDArray<T> copy = new NDArray<>(dimensions.clone());
        copy.values = values.clone();
        return copy;
    }
149896
def __realized_bbox(self, requested_bbox):
    
    realized_bbox = requested_bbox.expand_to_chunk_size(self.underlying, offset=self.voxel_offset)
    return Bbox.clamp(realized_bbox, self.bounds)
605527
def get_domain(self):
        
        if self.polyhedra != []:
            polyhedras_domain = np.vstack([poly.get_domain() 
                                          for poly in self.polyhedra])
        else:
            polyhedras_domain = np.ones((0, 3))
        points = np.vstack((self.surface.get_domain(), 
                            polyhedras_domain, 
                            self.set_of_points))
        return np.array([points.min(axis=0), points.max(axis=0)])
262337
def create_actor_hexahedron(grid, color, **kwargs):
    
    # Keyword arguments
    array_name = kwargs.get('name', "")
    array_index = kwargs.get('index', 0)

    # Create hexahedron elements
    points = vtk.vtkPoints()
    hexarray = vtk.vtkCellArray()
    for j, pt in enumerate(grid):
        tmp = vtk.vtkHexahedron()
        fb = pt[0]
        for i, v in enumerate(fb):
            points.InsertNextPoint(v)
            tmp.GetPointIds().SetId(i, i + (j * 8))
        ft = pt[-1]
        for i, v in enumerate(ft):
            points.InsertNextPoint(v)
            tmp.GetPointIds().SetId(i + 4, i + 4 + (j * 8))
        hexarray.InsertNextCell(tmp)

    # Create an unstructured grid object and add points & hexahedron elements
    ugrid = vtk.vtkUnstructuredGrid()
    ugrid.SetPoints(points)
    ugrid.SetCells(tmp.GetCellType(), hexarray)
    # ugrid.InsertNextCell(tmp.GetCellType(), tmp.GetPointIds())

    # Map unstructured grid to the graphics primitives
    mapper = vtk.vtkDataSetMapper()
    mapper.SetInputDataObject(ugrid)
    mapper.SetArrayName(array_name)
    mapper.SetArrayId(array_index)

    # Create an actor and set its properties
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    actor.GetProperty().SetColor(*color)

    # Return the actor
    return actor
974385
def instances(descendants = true)
      inst = ObjectSpace.each_object(self).to_a
      descendants ? inst : inst.select { |i| i.class == self }
    end
1118589
function() {
        this.blocks = [];

        //since all positions contain the same number of blocks, we can 
        // just pick the first position and use its blocks array to create
        // our blocks array
        var firstPosition = null;
        for(var key in this.positionBlocks) {
            firstPosition = key;
            break;
        }
        
        var position = this.positionBlocks[firstPosition];
        for (var i = 0; i < position.blocks.length; i++) {

            var block = {};
            this.blocks.push(block);

            var divId = this.id + '_FrameDecorationDiv_' + i;
            block.div = OpenLayers.Util.createDiv(divId, 
                null, null, null, "absolute", null, "hidden", null
            );

            var imgId = this.id + '_FrameDecorationImg_' + i;
            var imageCreator = 
                (this.isAlphaImage) ? OpenLayers.Util.createAlphaImageDiv
                                    : OpenLayers.Util.createImage;

            block.image = imageCreator(imgId, 
                null, this.imageSize, this.imageSrc, 
                "absolute", null, null, null
            );

            block.div.appendChild(block.image);
            this.groupDiv.appendChild(block.div);
        }
    }
366659
def create(cls, h:int, w:int, bboxes:Collection[Collection[int]], labels:Collection=None, classes:dict=None,
               pad_idx:int=0, scale:bool=True)->'ImageBBox':
        ""
        if isinstance(bboxes, np.ndarray) and bboxes.dtype == np.object: bboxes = np.array([bb for bb in bboxes])
        bboxes = tensor(bboxes).float()
        tr_corners = torch.cat([bboxes[:,0][:,None], bboxes[:,3][:,None]], 1)
        bl_corners = bboxes[:,1:3].flip(1)
        bboxes = torch.cat([bboxes[:,:2], tr_corners, bl_corners, bboxes[:,2:]], 1)
        flow = FlowField((h,w), bboxes.view(-1,2))
        return cls(flow, labels=labels, classes=classes, pad_idx=pad_idx, y_first=True, scale=scale)
146283
public Matrix getWorldToViewScaling() {
		if (viewState.getScale() > 0) {
			return new Matrix(viewState.getScale(), 0, 0, -viewState.getScale(), 0, 0);
		}
		return new Matrix(1, 0, 0, 1, 0, 0);
	}
49864
def from_chunks(cls, chunks):
		
		im = cls()
		im.chunks = chunks
		im.init()
		return im
967903
def to_point_cloud(self):
        
        return PointCloud(
            data=self._data.reshape(
                self.height *
                self.width,
                3).T,
            frame=self._frame)
394733
def copy(self):
        
        return RigidTransform(np.copy(self.rotation), np.copy(self.translation), self.from_frame, self.to_frame)
68642
def clone(self):
        
        obj = self.__class__()
        obj.libs = deepcopy(self.libs)
        return obj
563746
def create(blocks, mode='basic', inplanes=64, cardinality=4, image_features=64, divisor=4, num_classes=1000):
    
    block_dict = {
        # 'basic': BasicBlock,
        'bottleneck': ResNeXtBottleneck
    }

    def instantiate(**_):
        return ResNeXt(block_dict[mode], blocks, inplanes=inplanes, image_features=image_features, cardinality=cardinality, divisor=divisor, num_classes=num_classes)

    return ModelFactory.generic(instantiate)