Exemple #1
0
    def __init__(self, image_file, **kwargs):
        """Initialise the image structure from the given file, including a
        proper model of the experiment."""

        assert self.understand(image_file)

        FormatTIFF.__init__(self, image_file, **kwargs)
  def __init__(self, image_file):
    '''Initialise the image structure from the given file, including a
    proper model of the experiment.'''

    assert(self.understand(image_file))

    width, height, depth, order, bytes = FormatTIFF.get_tiff_header(
        image_file)

    # comment block - where the detector serial number may (or may not) be stored
    # comments = bytes[1024+1440:1024+1440+512]

    self._header_size = 4096

    if order == FormatTIFF.LITTLE_ENDIAN:
      self._I = '<I'
      self._i = '<i'
      self._ii = '<ii'
    else:
      self._I = '>I'
      self._i = '>i'
      self._ii = '>ii'

    FormatTIFF.__init__(self, image_file)

    return
  def __init__(self, image_file, **kwargs):
    '''Initialise the image structure from the given file, including a
    proper model of the experiment.'''

    from dxtbx import IncorrectFormatError
    if not self.understand(image_file):
      raise IncorrectFormatError(self, image_file)

    width, height, depth, order, bytes = FormatTIFF.get_tiff_header(
        image_file)

    # comment block - where the detector serial number may (or may not) be stored
    # comments = bytes[1024+1440:1024+1440+512]

    self._header_size = 4096

    if order == FormatTIFF.LITTLE_ENDIAN:
      self._I = '<I'
      self._i = '<i'
      self._ii = '<ii'
    else:
      self._I = '>I'
      self._i = '>i'
      self._ii = '>ii'

    FormatTIFF.__init__(self, image_file, **kwargs)

    return
  def understand(image_file):
    '''Check to see if this looks like an Rayonix TIFF format image,
    i.e. we can make sense of it. This simply checks that records which
    describe the size of the image match with the TIFF records which do
    the same.'''

    width, height, depth, order, bytes = FormatTIFF.get_tiff_header(
        image_file)

    assert(len(bytes) == 4096)

    if order == FormatTIFF.LITTLE_ENDIAN:
      endian = '<'
    else:
      endian = '>'

    _I = endian + 'I'
    _i = endian + 'i'

    _width = struct.unpack(_I, bytes[1024 + 80:1024 + 84])[0]
    _height = struct.unpack(_I, bytes[1024 + 84:1024 + 88])[0]
    _depth = struct.unpack(_I, bytes[1024 + 88:1024 + 92])[0]

    if width != _width or height != _height or depth != _depth:
      return False

    nimages = struct.unpack(_I, bytes[1024 + 112:1024 + 116])[0]
    origin = struct.unpack(_I, bytes[1024 + 116:1024 + 120])[0]
    orientation = struct.unpack(_I, bytes[1024 + 120:1024 + 124])[0]
    view = struct.unpack(_I, bytes[1024 + 124:1024 + 128])[0]

    if nimages != 1 or origin != 0 or orientation != 0 or view != 0:
      return False

    return True
    def understand(image_file):
        '''Check to see if this looks like an Rayonix TIFF format image,
    i.e. we can make sense of it. This simply checks that records which
    describe the size of the image match with the TIFF records which do
    the same.'''

        width, height, depth, order, bytes = FormatTIFF.get_tiff_header(
            image_file)

        assert (len(bytes) == 4096)

        if order == FormatTIFF.LITTLE_ENDIAN:
            endian = '<'
        else:
            endian = '>'

        _I = endian + 'I'
        _i = endian + 'i'

        _width = struct.unpack(_I, bytes[1024 + 80:1024 + 84])[0]
        _height = struct.unpack(_I, bytes[1024 + 84:1024 + 88])[0]
        _depth = struct.unpack(_I, bytes[1024 + 88:1024 + 92])[0]

        if width != _width or height != _height or depth != _depth:
            return False

        nimages = struct.unpack(_I, bytes[1024 + 112:1024 + 116])[0]
        origin = struct.unpack(_I, bytes[1024 + 116:1024 + 120])[0]
        orientation = struct.unpack(_I, bytes[1024 + 120:1024 + 124])[0]
        view = struct.unpack(_I, bytes[1024 + 124:1024 + 128])[0]

        if nimages != 1 or origin != 0 or orientation != 0 or view != 0:
            return False

        return True
Exemple #6
0
    def get_raw_data(self):
        """Get the pixel intensities (i.e. read the image and return as a
        flex array of integers.)"""

        # currently have no non-little-endian machines...

        assert self._tiff_byte_order == FormatTIFF.LITTLE_ENDIAN

        bias = int(round(self._get_bruker_bias()))

        assert len(self.get_detector()) == 1
        size = self.get_detector()[0].get_image_size()
        f = FormatTIFF.open_file(self._image_file)
        f.read(self._header_size)
        raw_data = read_uint16(streambuf(f), int(size[0] * size[1])) - bias
        image_size = self.get_detector()[0].get_image_size()
        raw_data.reshape(flex.grid(image_size[1], image_size[0]))

        return raw_data
Exemple #7
0
    def __init__(self, image_file, **kwargs):
        """Initialise the image structure from the given file, including a
        proper model of the experiment."""

        width, height, depth, order, bytes = FormatTIFF.get_tiff_header(image_file)

        # comment block - where the detector serial number may (or may not) be stored
        # comments = bytes[1024+1440:1024+1440+512]

        self._header_size = 4096

        if order == FormatTIFF.LITTLE_ENDIAN:
            self._I = "<I"
            self._i = "<i"
            self._ii = "<ii"
        else:
            self._I = ">I"
            self._i = ">i"
            self._ii = ">ii"

        super(FormatTIFFRayonix, self).__init__(image_file, **kwargs)
Exemple #8
0
    def understand(image_file):
        """Check to see if this looks like an Rayonix TIFF format image,
        i.e. we can make sense of it. This simply checks that records which
        describe the size of the image match with the TIFF records which do
        the same."""

        width, height, depth, order, bytes = FormatTIFF.get_tiff_header(
            image_file)

        if len(bytes) != 4096:
            return False

        if order == FormatTIFF.LITTLE_ENDIAN:
            endian = "<"
        else:
            endian = ">"

        _I = endian + "I"
        _i = endian + "i"

        _width = struct.unpack(_I, bytes[1024 + 80:1024 + 84])[0]
        _height = struct.unpack(_I, bytes[1024 + 84:1024 + 88])[0]
        _depth = struct.unpack(_I, bytes[1024 + 88:1024 + 92])[0]

        if width != _width or height != _height or depth != _depth:
            return False

        # pretty sure all MARCCD / Rayonix detectors are square...
        if width != height:
            return False

        nimages = struct.unpack(_I, bytes[1024 + 112:1024 + 116])[0]
        origin = struct.unpack(_I, bytes[1024 + 116:1024 + 120])[0]
        orientation = struct.unpack(_I, bytes[1024 + 120:1024 + 124])[0]
        view = struct.unpack(_I, bytes[1024 + 124:1024 + 128])[0]

        if nimages != 1 or origin != 0 or orientation != 0 or view != 0:
            return False

        return True
  def get_raw_data(self):
    '''Get the pixel intensities (i.e. read the image and return as a
       flex array of integers.)'''

    # currently have no non-little-endian machines...

    assert(self._tiff_byte_order == FormatTIFF.LITTLE_ENDIAN)

    bias = int(round(self._get_rayonix_bias()))

    from boost.python import streambuf
    from dxtbx import read_uint16
    from scitbx.array_family import flex
    assert(len(self.get_detector()) == 1)
    size = self.get_detector()[0].get_image_size()
    f = FormatTIFF.open_file(self._image_file)
    f.read(self._header_size)
    raw_data = read_uint16(streambuf(f), int(size[0] * size[1])) - bias
    image_size = self.get_detector()[0].get_image_size()
    raw_data.reshape(flex.grid(image_size[1], image_size[0]))

    return raw_data
  def get_raw_data(self):
    '''Get the pixel intensities (i.e. read the image and return as a
       flex array of integers.)'''

    # currently have no non-little-endian machines...

    assert(self._tiff_byte_order == FormatTIFF.LITTLE_ENDIAN)

    bias = int(round(self._get_bruker_bias()))

    from boost.python import streambuf
    from dxtbx import read_uint16
    from scitbx.array_family import flex
    assert(len(self.get_detector()) == 1)
    size = self.get_detector()[0].get_image_size()
    f = FormatTIFF.open_file(self._image_file)
    f.read(self._header_size)
    raw_data = read_uint16(streambuf(f), int(size[0] * size[1])) - bias
    image_size = self.get_detector()[0].get_image_size()
    raw_data.reshape(flex.grid(image_size[1], image_size[0]))

    return raw_data
  def _start(self):

    FormatTIFF._start(self)
  def _start(self):

    FormatTIFF._start(self)
  def _start(self):

    FormatTIFF._start(self)
    from iotbx.detectors.mar import MARImage
    self.detectorbase = MARImage(self._image_file)
    self.detectorbase.readHeader()