fabio.GEimage_old

Package fabio :: Module GEimage_old |
[hide private]
[frames] | no frames]

# Source Code for Module fabio.GEimage_old

      1

      2  #!/usr/bin/env python

      3

      4  """

      5  Reads the header from a GE a-Si Angio Detector

      6

      7  Authors: Henning O. Sorensen & Erik Knudsen

      8           Center for Fundamental Research: Metal Structures in Four Dimensions

      9           Risoe National Laboratory

     10           Frederiksborgvej 399

     11           DK-4000 Roskilde

     12           email:erik.knudsen@risoe.dk

     13

     14          + Jon Wright, ESRF

     15

     16          The header information has been taken from the script read_GEaSi_data.py

     17          by

     18          Antonino Miceli

     19          Thu Jan  4 13:46:31 CST 2007

     20

     21  """
     22

     23  import numpy
     24  from fabioimage import fabioimage
     25

     26 -class GEimage(fabioimage):
     27

     28

     29 -    def _readheader(self, infile):
     30

     31          infile.seek(0)
     32

     33          # ADEPT

     34          self.ImageFormat = infile.read(10)
     35

     36          # USHORT --> "=H"

     37          # ULONG  --> "=L"

     38          #   = means byte order is native

     39

     40          self.header['HeaderVersion'] = numpy.fromstring(infile.read(2), numpy.uint16)[0]
     41          self.header['HeaderSizeInBytes'] = int(numpy.fromstring(infile.read(4), numpy.uint32)[0])
     42          self.header['UserHeaderVersion'] = numpy.fromstring(infile.read(2), numpy.uint16)[0]
     43          self.header['UserHeaderSizeInBytes'] = int(numpy.fromstring(infile.read(4), numpy.uint32)[0])
     44

     45          self.header['NumberOfFrames'] = numpy.fromstring(infile.read(2), numpy.uint16)[0]
     46          self.header['NumberOfRowsInFrame'] = numpy.fromstring(infile.read(2), numpy.uint16)[0]
     47          self.header['NumberOfColsInFrame'] = numpy.fromstring(infile.read(2), numpy.uint16)[0]
     48          self.header['BitsPerPixel'] = numpy.fromstring(infile.read(2), numpy.uint16)[0]
     49

     50          self.header['AcquisitionDate'] = infile.read(20)
     51          self.header['AcquisitionTime'] = infile.read(20)
     52

     53          self.DUTID = infile.read(20)
     54

     55          self.header['Operator'] = infile.read(50)
     56

     57          self.header['DetectorSignature'] = infile.read(20)
     58          self.header['TestSystemName'] = infile.read(20)
     59          self.header['TestStationRevision'] = infile.read(20)
     60          self.header['CoreBundleRevision'] = infile.read(20)
     61          self.header['AcquisitionName'] = infile.read(40)
     62          self.header['AcquisitionParameterRevision'] = infile.read(20)
     63

     64  #         self.OriginalNumberOfRows = infile.read(2)

     65  #         self.OriginalNumberOfRows = struct.unpack("=H",self.OriginalNumberOfRows)[0]

     66

     67  #         self.OriginalNumberOfColumns = infile.read(2)

     68  #         self.OriginalNumberOfColumns = struct.unpack("=H",self.OriginalNumberOfColumns)[0]

     69

     70  #         self.RowNumberUpperLeftPointArchiveROI = infile.read(2)

     71  #         self.RowNumberUpperLeftPointArchiveROI = struct.unpack("=H",self.RowNumberUpperLeftPointArchiveROI)[0]

     72

     73  #         self.ColNumberUpperLeftPointArchiveROI = infile.read(2)

     74  #         self.ColNumberUpperLeftPointArchiveROI = struct.unpack("=H",self.ColNumberUpperLeftPointArchiveROI)[0]

     75

     76  #         self.Swapped = infile.read(2)

     77  #         self.Swapped = struct.unpack("=H",self.Swapped)[0]

     78

     79  #         self.Reordered = infile.read(2)

     80  #         self.Reordered = struct.unpack("=H",self.Reordered)[0]

     81

     82  #         self.HorizontalFlipped = infile.read(2)

     83  #         self.HorizontalFlipped = struct.unpack("=H",self.HorizontalFlipped)[0]

     84

     85  #         self.VerticalFlipped = infile.read(2)

     86  #         self.VerticalFlipped = struct.unpack("=H",self.VerticalFlipped)[0]

     87

     88  #         self.WindowValueDesired = infile.read(2)

     89  #         self.WindowValueDesired = struct.unpack("=H",self.WindowValueDesired)[0]

     90

     91  #         self.LevelValueDesired = infile.read(2)

     92  #         self.LevelValueDesired = struct.unpack("=H",self.LevelValueDesired)[0]

     93

     94  #         self.AcquisitionMode = infile.read(2)

     95  #         self.AcquisitionMode = struct.unpack("=H",self.AcquisitionMode)[0]

     96

     97  #         self.AcquisitionType = infile.read(2)

     98  #         self.AcquisitionType = struct.unpack("=H",self.AcquisitionType)[0]

     99

    100  #         self.UserAcquisitionCoffFileName1 = infile.read(100)

    101  #         self.UserAcquisitionCoffFileName2 = infile.read(100)

    102

    103  #         self.FramesBeforeExpose = infile.read(2)

    104  #         self.FramesBeforeExpose = struct.unpack("=H",self.FramesBeforeExpose)[0]

    105

    106  #         self.FramesDuringExpose = infile.read(2)

    107  #         self.FramesDuringExpose = struct.unpack("=H",self.FramesDuringExpose)[0]

    108

    109  #         self.FramesAfterExpose = infile.read(2)

    110  #         self.FramesAfterExpose = struct.unpack("=H",self.FramesAfterExpose)[0]

    111

    112  #         self.IntervalBetweenFrames = infile.read(2)

    113  #         self.IntervalBetweenFrames = struct.unpack("=H",self.IntervalBetweenFrames)[0]

    114

    115  #         self.ExposeTimeDelayInMicrosecs = infile.read(8)

    116  #         self.ExposeTimeDelayInMicrosecs = struct.unpack("=d",self.ExposeTimeDelayInMicrosecs)[0]

    117

    118  #         self.TimeBetweenFramesInMicrosecs = infile.read(8)

    119  #         self.TimeBetweenFramesInMicrosecs = struct.unpack("=d",self.TimeBetweenFramesInMicrosecs)[0]

    120

    121  #         self.FramesToSkipExpose = infile.read(2)

    122  #         self.FramesToSkipExpose = struct.unpack("=H",self.FramesToSkipExpose)[0]

    123

    124  #         # Rad --> ExposureMode = 1

    125  #         self.ExposureMode = infile.read(2)

    126  #         self.ExposureMode = struct.unpack("=H",self.ExposureMode)[0]

    127

    128  #         self.PrepPresetTimeInMicrosecs = infile.read(8)

    129  #         self.PrepPresetTimeInMicrosecs = struct.unpack("=d",self.PrepPresetTimeInMicrosecs)[0]

    130

    131  #         self.ExposePresetTimeInMicrosecs = infile.read(8)

    132  #         self.ExposePresetTimeInMicrosecs = struct.unpack("=d",self.ExposePresetTimeInMicrosecs)[0]

    133

    134  #         self.AcquisitionFrameRateInFps = infile.read(4)

    135  #         self.AcquisitionFrameRateInFps = struct.unpack("=f",self.AcquisitionFrameRateInFps)[0]

    136

    137  #         self.FOVSelect = infile.read(2)

    138  #         self.FOVSelect = struct.unpack("=H",self.FOVSelect)[0]

    139

    140  #         self.ExpertMode = infile.read(2)

    141  #         self.ExpertMode = struct.unpack("=H",self.ExpertMode)[0]

    142

    143  #         self.SetVCommon1 = infile.read(8)

    144  #         self.SetVCommon1 = struct.unpack("=d",self.SetVCommon1)[0]

    145

    146  #         self.SetVCommon2 = infile.read(8)

    147  #         self.SetVCommon2 = struct.unpack("=d",self.SetVCommon2)[0]

    148

    149  #         self.SetAREF = infile.read(8)

    150  #         self.SetAREF = struct.unpack("=d",self.SetAREF)[0]

    151

    152  #         self.SetAREFTrim = infile.read(4)

    153  #         self.SetAREFTrim = struct.unpack("=L",self.SetAREFTrim)[0]

    154

    155  #         self.SetSpareVoltageSource = infile.read(8)

    156  #         self.SetSpareVoltageSource = struct.unpack("=d",self.SetSpareVoltageSource)[0]

    157

    158  #         self.SetCompensationVoltageSource = infile.read(8)

    159  #         self.SetCompensationVoltageSource = struct.unpack("=d",self.SetCompensationVoltageSource)[0]

    160

    161  #         self.SetRowOffVoltage = infile.read(8)

    162  #         self.SetRowOffVoltage = struct.unpack("=d",self.SetRowOffVoltage)[0]

    163

    164  #         self.SetRowOnVoltage = infile.read(8)

    165  #         self.SetRowOnVoltage = struct.unpack("=d",self.SetRowOnVoltage)[0]

    166

    167  #         self.StoreCompensationVoltage = infile.read(4)

    168  #         self.StoreCompensationVoltage = struct.unpack("=L",self.StoreCompensationVoltage)[0]

    169

    170  #         self.RampSelection = infile.read(2)

    171  #         self.RampSelection = struct.unpack("=H",self.RampSelection)[0]

    172

    173  #         self.TimingMode = infile.read(2)

    174  #         self.TimingMode = struct.unpack("=H",self.TimingMode)[0]

    175

    176  #         self.Bandwidth = infile.read(2)

    177  #         self.Bandwidth = struct.unpack("=H",self.Bandwidth)[0]

    178

    179  #         self.ARCIntegrator = infile.read(2)

    180  #         self.ARCIntegrator = struct.unpack("=H",self.ARCIntegrator)[0]

    181

    182  #         self.ARCPostIntegrator = infile.read(2)

    183  #         self.ARCPostIntegrator = struct.unpack("=H",self.ARCPostIntegrator)[0]

    184

    185  #         self.NumberOfRows = infile.read(4)

    186  #         self.NumberOfRows = struct.unpack("=L",self.NumberOfRows)[0]

    187

    188  #         self.RowEnable = infile.read(2)

    189  #         self.RowEnable = struct.unpack("=H",self.RowEnable)[0]

    190

    191  #         self.EnableStretch = infile.read(2)

    192  #         self.EnableStretch = struct.unpack("=H",self.EnableStretch)[0]

    193

    194  #         self.CompEnable = infile.read(2)

    195  #         self.CompEnable = struct.unpack("=H",self.CompEnable)[0]

    196

    197  #         self.CompStretch = infile.read(2)

    198  #         self.CompStretch = struct.unpack("=H",self.CompStretch)[0]

    199

    200  #         self.LeftEvenTristate = infile.read(2)

    201  #         self.LeftEvenTristate = struct.unpack("=H",self.LeftEvenTristate)[0]

    202

    203  #         self.RightOddTristate = infile.read(2)

    204  #         self.RightOddTristate = struct.unpack("=H",self.RightOddTristate)[0]

    205

    206  #         self.TestModeSelect = infile.read(4)

    207  #         self.TestModeSelect = struct.unpack("=L",self.TestModeSelect)[0]

    208

    209  #         self.AnalogTestSource = infile.read(4)

    210  #         self.AnalogTestSource = struct.unpack("=L",self.AnalogTestSource)[0]

    211

    212  #         self.VCommonSelect = infile.read(4)

    213  #         self.VCommonSelect = struct.unpack("=L",self.VCommonSelect)[0]

    214

    215  #         self.DRCColumnSum = infile.read(4)

    216  #         self.DRCColumnSum = struct.unpack("=L",self.DRCColumnSum)[0]

    217

    218  #         self.TestPatternFrameDelta = infile.read(4)

    219  #         self.TestPatternFrameDelta = struct.unpack("=L",self.TestPatternFrameDelta)[0]

    220

    221  #         self.TestPatternRowDelta = infile.read(4)

    222  #         self.TestPatternRowDelta = struct.unpack("=L",self.TestPatternRowDelta)[0]

    223

    224  #         self.TestPatternColumnDelta = infile.read(4)

    225  #         self.TestPatternColumnDelta = struct.unpack("=L",self.TestPatternColumnDelta)[0]

    226

    227  #         self.DetectorHorizontalFlip = infile.read(2)

    228  #         self.DetectorHorizontalFlip = struct.unpack("=H",self.DetectorHorizontalFlip)[0]

    229

    230  #         self.DetectorVerticalFlip = infile.read(2)

    231  #         self.DetectorVerticalFlip = struct.unpack("=H",self.DetectorVerticalFlip)[0]

    232

    233  #         self.DFNAutoScrubOnOff = infile.read(2)

    234  #         self.DFNAutoScrubOnOff = struct.unpack("=H",self.DFNAutoScrubOnOff)[0]

    235

    236  #         self.FiberChannelTimeOutInMicrosecs = infile.read(4)

    237  #         self.FiberChannelTimeOutInMicrosecs = struct.unpack("=L",self.FiberChannelTimeOutInMicrosecs)[0]

    238

    239  #         self.DFNAutoScrubDelayInMicrosecs = infile.read(4)

    240  #         self.DFNAutoScrubDelayInMicrosecs = struct.unpack("=L",self.DFNAutoScrubDelayInMicrosecs)[0]

    241

    242  #         self.StoreAECROI = infile.read(2)

    243  #         self.StoreAECROI = struct.unpack("=H",self.StoreAECROI)[0]

    244

    245  #         self.TestPatternSaturationValue = infile.read(2)

    246  #         self.TestPatternSaturationValue = struct.unpack("=H",self.TestPatternSaturationValue)[0]

    247

    248  #         self.TestPatternSeed = infile.read(4)

    249  #         self.TestPatternSeed = struct.unpack("=L",self.TestPatternSeed)[0]

    250

    251  #         self.ExposureTimeInMillisecs = infile.read(4)

    252  #         self.ExposureTimeInMillisecs = struct.unpack("=f",self.ExposureTimeInMillisecs)[0]

    253

    254  #         self.FrameRateInFps = infile.read(4)

    255  #         self.FrameRateInFps = struct.unpack("=f",self.FrameRateInFps)[0]

    256

    257  #         self.kVp = infile.read(4)

    258  #         self.kVp = struct.unpack("=f",self.kVp)[0]

    259

    260  #         self.mA = infile.read(4)

    261  #         self.mA = struct.unpack("=f",self.mA)[0]

    262

    263  #         self.mAs = infile.read(4)

    264  #         self.mAs = struct.unpack("=f",self.mAs)[0]

    265

    266  #         self.FocalSpotInMM = infile.read(4)

    267  #         self.FocalSpotInMM = struct.unpack("=f",self.FocalSpotInMM)[0]

    268

    269  #         self.GeneratorType = infile.read(20)

    270

    271  #         self.StrobeIntensityInFtL = infile.read(4)

    272  #         self.StrobeIntensityInFtL = struct.unpack("=f",self.StrobeIntensityInFtL)[0]

    273

    274  #         self.NDFilterSelection = infile.read(2)

    275  #         self.NDFilterSelection = struct.unpack("=H",self.NDFilterSelection)[0]

    276

    277  #         self.RefRegTemp1 = infile.read(8)

    278  #         self.RefRegTemp1 = struct.unpack("=d",self.RefRegTemp1)[0]

    279

    280  #         self.RefRegTemp2 = infile.read(8)

    281  #         self.RefRegTemp2 = struct.unpack("=d",self.RefRegTemp2)[0]

    282

    283  #         self.RefRegTemp3 = infile.read(8)

    284  #         self.RefRegTemp3 = struct.unpack("=d",self.RefRegTemp3)[0]

    285

    286  #         self.Humidity1 = infile.read(4)

    287  #         self.Humidity1 = struct.unpack("=f",self.Humidity1)[0]

    288

    289  #         self.Humidity2 = infile.read(4)

    290  #         self.Humidity2 = struct.unpack("=f",self.Humidity2)[0]

    291

    292  #         self.DetectorControlTemp = infile.read(8)

    293  #         self.DetectorControlTemp = struct.unpack("=d",self.DetectorControlTemp)[0]

    294

    295  #         self.DoseValueInmR = infile.read(8)

    296  #         self.DoseValueInmR = struct.unpack("=d",self.DoseValueInmR)[0]

    297

    298  #         self.TargetLevelROIRow0 = infile.read(2)

    299  #         self.TargetLevelROIRow0 = struct.unpack("=H",self.TargetLevelROIRow0)[0]

    300

    301  #         self.TargetLevelROICol0 = infile.read(2)

    302  #         self.TargetLevelROICol0 = struct.unpack("=H",self.TargetLevelROICol0)[0]

    303

    304  #         self.TargetLevelROIRow1 = infile.read(2)

    305  #         self.TargetLevelROIRow1 = struct.unpack("=H",self.TargetLevelROIRow1)[0]

    306

    307  #         self.TargetLevelROICol1 = infile.read(2)

    308  #         self.TargetLevelROICol1 = struct.unpack("=H",self.TargetLevelROICol1)[0]

    309

    310  #         self.FrameNumberForTargetLevelROI = infile.read(2)

    311  #         self.FrameNumberForTargetLevelROI = struct.unpack("=H",self.FrameNumberForTargetLevelROI)[0]

    312

    313  #         self.PercentRangeForTargetLevel = infile.read(2)

    314  #         self.PercentRangeForTargetLevel = struct.unpack("=H",self.PercentRangeForTargetLevel)[0]

    315

    316  #         self.TargetValue = infile.read(2)

    317  #         self.TargetValue = struct.unpack("=H",self.TargetValue)[0]

    318

    319  #         self.ComputedMedianValue = infile.read(2)

    320  #         self.ComputedMedianValue = struct.unpack("=H",self.ComputedMedianValue)[0]

    321

    322  #         self.LoadZero = infile.read(2)

    323  #         self.LoadZero = struct.unpack("=H",self.LoadZero)[0]

    324

    325  #         self.MaxLUTOut = infile.read(2)

    326  #         self.MaxLUTOut = struct.unpack("=H",self.MaxLUTOut)[0]

    327

    328  #         self.MinLUTOut = infile.read(2)

    329  #         self.MinLUTOut = struct.unpack("=H",self.MinLUTOut)[0]

    330

    331  #         self.MaxLinear = infile.read(2)

    332  #         self.MaxLinear = struct.unpack("=H",self.MaxLinear)[0]

    333

    334  #         self.Reserved = infile.read(2)

    335  #         self.Reserved = struct.unpack("=H",self.Reserved)[0]

    336

    337  #         self.ElectronsPerCount = infile.read(2)

    338  #         self.ElectronsPerCount = struct.unpack("=H",self.ElectronsPerCount)[0]

    339

    340  #         self.ModeGain = infile.read(2)

    341  #         self.ModeGain = struct.unpack("=H",self.ModeGain)[0]

    342

    343  #         self.TemperatureInDegC = infile.read(8)

    344  #         self.TemperatureInDegC = struct.unpack("=d",self.TemperatureInDegC)[0]

    345

    346  #         self.LineRepaired = infile.read(2)

    347  #         self.LineRepaired = struct.unpack("=H",self.LineRepaired)[0]

    348

    349  #         self.LineRepairFileName = infile.read(100)

    350

    351  #         self.CurrentLongitudinalInMM = infile.read(4)

    352  #         self.CurrentLongitudinalInMM = struct.unpack("=f",self.CurrentLongitudinalInMM)[0]

    353

    354  #         self.CurrentTransverseInMM = infile.read(4)

    355  #         self.CurrentTransverseInMM = struct.unpack("=f",self.CurrentTransverseInMM)[0]

    356

    357  #         self.CurrentCircularInMM = infile.read(4)

    358  #         self.CurrentCircularInMM = struct.unpack("=f",self.CurrentCircularInMM)[0]

    359

    360  #         self.CurrentFilterSelection = infile.read(4)

    361  #         self.CurrentFilterSelection = struct.unpack("=L",self.CurrentFilterSelection)[0]

    362

    363  #         self.DisableScrubAck = infile.read(2)

    364  #         self.DisableScrubAck = struct.unpack("=H",self.DisableScrubAck)[0]

    365

    366  #         self.ScanModeSelect = infile.read(2)

    367  #         self.ScanModeSelect = struct.unpack("=H",self.ScanModeSelect)[0]

    368

    369  #         self.DetectorAppSwVersion = infile.read(20)

    370

    371  #         self.DetectorNIOSVersion = infile.read(20)

    372

    373  #         self.DetectorPeripheralSetVersion = infile.read(20)

    374

    375  #         self.DetectorPhysicalAddress   = infile.read(20)

    376

    377  #         self.PowerDown = infile.read(2)

    378  #         self.PowerDown = struct.unpack("=H",self.PowerDown)[0]

    379

    380  #         self.InitialVoltageLevel_VCOMMON = infile.read(8)

    381  #         self.InitialVoltageLevel_VCOMMON = struct.unpack("=d",self.InitialVoltageLevel_VCOMMON)[0]

    382

    383  #         self.FinalVoltageLevel_VCOMMON = infile.read(8)

    384  #         self.FinalVoltageLevel_VCOMMON = struct.unpack("=d",self.FinalVoltageLevel_VCOMMON)[0]

    385

    386  #         self.DmrCollimatorSpotSize     = infile.read(10)

    387

    388  #         self.DmrTrack  = infile.read(5)

    389

    390  #         self.DmrFilter         = infile.read(5)

    391

    392  #         self.FilterCarousel = infile.read(2)

    393  #         self.FilterCarousel = struct.unpack("=H",self.FilterCarousel)[0]

    394

    395  #         self.Phantom   = infile.read(20)

    396

    397  #         self.SetEnableHighTime = infile.read(2)

    398  #         self.SetEnableHighTime = struct.unpack("=H",self.SetEnableHighTime)[0]

    399

    400  #         self.SetEnableLowTime = infile.read(2)

    401  #         self.SetEnableLowTime = struct.unpack("=H",self.SetEnableLowTime)[0]

    402

    403  #         self.SetCompHighTime = infile.read(2)

    404  #         self.SetCompHighTime = struct.unpack("=H",self.SetCompHighTime)[0]

    405

    406  #         self.SetCompLowTime = infile.read(2)

    407  #         self.SetCompLowTime = struct.unpack("=H",self.SetCompLowTime)[0]

    408

    409  #         self.SetSyncLowTime = infile.read(2)

    410  #         self.SetSyncLowTime = struct.unpack("=H",self.SetSyncLowTime)[0]

    411

    412  #         self.SetConvertLowTime = infile.read(2)

    413  #         self.SetConvertLowTime = struct.unpack("=H",self.SetConvertLowTime)[0]

    414

    415  #         self.SetSyncHighTime = infile.read(2)

    416  #         self.SetSyncHighTime = struct.unpack("=H",self.SetSyncHighTime)[0]

    417

    418  #         self.SetEOLTime = infile.read(2)

    419  #         self.SetEOLTime = struct.unpack("=H",self.SetEOLTime)[0]

    420

    421  #         self.SetRampOffsetTime = infile.read(2)

    422  #         self.SetRampOffsetTime = struct.unpack("=H",self.SetRampOffsetTime)[0]

    423

    424  #         self.FOVStartingValue = infile.read(2)

    425  #         self.FOVStartingValue = struct.unpack("=H",self.FOVStartingValue)[0]

    426

    427  #         self.ColumnBinning = infile.read(2)

    428  #         self.ColumnBinning = struct.unpack("=H",self.ColumnBinning)[0]

    429

    430  #         self.RowBinning = infile.read(2)

    431  #         self.RowBinning = struct.unpack("=H",self.RowBinning)[0]

    432

    433  #         self.BorderColumns64 = infile.read(2)

    434  #         self.BorderColumns64 = struct.unpack("=H",self.BorderColumns64)[0]

    435

    436  #         self.BorderRows64 = infile.read(2)

    437  #         self.BorderRows64 = struct.unpack("=H",self.BorderRows64)[0]

    438

    439  #         self.FETOffRows64 = infile.read(2)

    440  #         self.FETOffRows64 = struct.unpack("=H",self.FETOffRows64)[0]

    441

    442  #         self.FOVStartColumn128 = infile.read(2)

    443  #         self.FOVStartColumn128 = struct.unpack("=H",self.FOVStartColumn128)[0]

    444

    445  #         self.FOVStartRow128 = infile.read(2)

    446  #         self.FOVStartRow128 = struct.unpack("=H",self.FOVStartRow128)[0]

    447

    448  #         self.NumberOfColumns128 = infile.read(2)

    449  #         self.NumberOfColumns128 = struct.unpack("=H",self.NumberOfColumns128)[0]

    450

    451  #         self.NumberOfRows128 = infile.read(2)

    452  #         self.NumberOfRows128 = struct.unpack("=H",self.NumberOfRows128)[0]

    453

    454  #         self.VFPAquisition     = infile.read(2000)

    455

    456  #         self.Comment   = infile.read(200)

    457

    458

    459

    460 -    def read(self, fname, frame=None):
    461          """

    462          Read in header into self.header and

    463              the data   into self.data

    464          """
    465          self.header = {}
    466          self.resetvals()
    467          infile = self._open(fname, "rb")
    468          self._readheader(infile)
    469          # Compute image size

    470          try:
    471              self.dim1 = int(self.header['NumberOfRowsInFrame'])
    472              self.dim2 = int(self.header['NumberOfColsInFrame'])
    473              self.bpp = int(self.header['BitsPerPixel'])
    474          except:
    475              raise Exception("GE  file", str(fname) + \

    476                                  "is corrupt, cannot read it")
    477

    478          # More than one image can be saved in a GE file

    479          # Will only load the first one

    480

    481

    482          # Go to the beginning of the file

    483          infile.seek(0)
    484          infile.seek(self.header['HeaderSizeInBytes'] + self.header['UserHeaderSizeInBytes'])
    485

    486          ReadBytes = self.dim1 * self.dim2 * (self.bpp / 8)
    487          block = infile.read(ReadBytes)
    488          block = numpy.fromstring(block, numpy.uint16)
    489

    490          infile.close()
    491

    492          try:
    493              self.data = numpy.reshape(block, [self.dim2, self.dim1])
    494          except:
    495              print len(block), self.dim2, self.dim1
    496              raise IOError, \

    497                'Size spec in GE-header does not match size of image data field'
    498

    499          self.bytecode = self.data.dtype.type
    500          self.pilimage = None
    501          return self
    502