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 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 __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 __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)
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