docs: def getRegion(self,size=3e4,min_nSNPs=1,chrom_i=None,pos_min=None,pos_max=None):
          """
          Sample a region from the piece of genotype X, chrom, pos
          minSNPnum:  minimum number of SNPs contained in the region
          Ichrom:  restrict X to chromosome Ichrom before taking the region
          cis:        bool vector that marks the sorted region
          region:  vector that contains chrom and init and final position of the region
          """
          if (self.chrom is None) or (self.pos is None):
              bim = plink_reader.readBIM(self.bfile,usecols=(0,1,2,3))
              chrom = SP.array(bim[:,0],dtype=int)
              pos   = SP.array(bim[:,3],dtype=int)
          else:
              chrom = self.chrom
              pos   = self.pos
  
          if chrom_i is None:
              n_chroms = chrom.max()
              chrom_i  = int(SP.ceil(SP.rand()*n_chroms))
  
          pos   = pos[chrom==chrom_i]
          chrom = chrom[chrom==chrom_i]
  
          ipos = SP.ones(len(pos),dtype=bool)
          if pos_min is not None:
              ipos = SP.logical_and(ipos,pos_min<pos)
  
          if pos_max is not None:
              ipos = SP.logical_and(ipos,pos<pos_max)
  
          pos = pos[ipos]
          chrom = chrom[ipos]
  
          if size==1:
              # select single SNP
              idx = int(SP.ceil(pos.shape[0]*SP.rand()))
              cis  = SP.arange(pos.shape[0])==idx
              region = SP.array([chrom_i,pos[idx],pos[idx]])
          else:
              while 1:
                  idx = int(SP.floor(pos.shape[0]*SP.rand()))
                  posT1 = pos[idx]
                  posT2 = pos[idx]+size
                  if posT2<=pos.max():
                      cis = chrom==chrom_i
                      cis*= (pos>posT1)*(pos<posT2)
                      if cis.sum()>min_nSNPs: break
              region = SP.array([chrom_i,posT1,posT2])
  
          start = SP.nonzero(cis)[0].min()
          nSNPs  = cis.sum()
  
          if self.X is None:
              rv = plink_reader.readBED(self.bfile,useMAFencoding=True,start = start, nSNPs = nSNPs,bim=bim)
              Xr = rv['snps']
          else:
              Xr = self.X[:,start:start+nSnps]
  
          return Xr, region