GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
vtkLSMReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: BioImageXD
4  Module: $RCSfile: vtkLSMReader.h,v $
5  Language: C++
6  Date: $Date: 2003/08/22 14:46:02 $
7  Version: $Revision: 1.39 $
8 
9  This is an open-source copyright as follows:
10  Copyright (c) 2004-2008 BioImageXD Development Team
11 
12  All rights reserved.
13 
14  Redistribution and use in source and binary forms, with or without
15  modification, are permitted provided that the following conditions are met:
16 
17  * Redistributions of source code must retain the above copyright notice,
18  this list of conditions and the following disclaimer.
19 
20  * Redistributions in binary form must reproduce the above copyright notice,
21  this list of conditions and the following disclaimer in the documentation
22  and/or other materials provided with the distribution.
23 
24  * Modified source versions must be plainly marked as such, and must not be
25  misrepresented as being the original software.
26 
27  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
28  IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
29  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
31  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  POSSIBILITY OF SUCH DAMAGE.
38 
39 =========================================================================*/
40 
41 /*=========================================================================
42  Modifications were made by the GoFigure Dev. Team.
43  while at Megason Lab, Systems biology, Harvard Medical school, 2009-11
44 
45  Copyright (c) 2009-11, President and Fellows of Harvard College.
46  All rights reserved.
47 
48  Redistribution and use in source and binary forms, with or without
49  modification, are permitted provided that the following conditions are met:
50 
51  Redistributions of source code must retain the above copyright notice,
52  this list of conditions and the following disclaimer.
53  Redistributions in binary form must reproduce the above copyright notice,
54  this list of conditions and the following disclaimer in the documentation
55  and/or other materials provided with the distribution.
56  Neither the name of the President and Fellows of Harvard College
57  nor the names of its contributors may be used to endorse or promote
58  products derived from this software without specific prior written
59  permission.
60 
61  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
62  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
63  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
64  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
65  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
66  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
67  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
68  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
69  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
70  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
71  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
72 
73  =========================================================================*/
74 
75 #define TIF_NEWSUBFILETYPE 254
76 #define TIF_IMAGEWIDTH 256
77 #define TIF_IMAGELENGTH 257
78 #define TIF_BITSPERSAMPLE 258
79 #define TIF_COMPRESSION 259
80 #define TIF_PHOTOMETRICINTERPRETATION 262
81 #define TIF_STRIPOFFSETS 273
82 #define TIF_SAMPLESPERPIXEL 277
83 #define TIF_STRIPBYTECOUNTS 279
84 #define TIF_PLANARCONFIGURATION 284
85 #define TIF_PREDICTOR 317
86 #define TIF_COLORMAP 320
87 #define TIF_CZ_LSMINFO 34412
88 
89 #define SUBBLOCK_END 0x0FFFFFFFF
90 #define SUBBLOCK_RECORDING 0x010000000
91 #define SUBBLOCK_LASERS 0x030000000
92 #define SUBBLOCK_LASER 0x050000000
93 #define SUBBLOCK_TRACKS 0x020000000
94 #define SUBBLOCK_TRACK 0x040000000
95 #define SUBBLOCK_DETECTION_CHANNELS 0x060000000
96 #define SUBBLOCK_DETECTION_CHANNEL 0x070000000
97 #define SUBBLOCK_ILLUMINATION_CHANNELS 0x080000000
98 #define SUBBLOCK_ILLUMINATION_CHANNEL 0x090000000
99 #define SUBBLOCK_BEAM_SPLITTERS 0x0A0000000
100 #define SUBBLOCK_BEAM_SPLITTER 0x0B0000000
101 #define SUBBLOCK_DATA_CHANNELS 0x0C0000000
102 #define SUBBLOCK_DATA_CHANNEL 0x0D0000000
103 #define SUBBLOCK_TIMERS 0x011000000
104 #define SUBBLOCK_TIMER 0x012000000
105 #define SUBBLOCK_MARKERS 0x013000000
106 #define SUBBLOCK_MARKER 0x014000000
107 #define SUBBLOCK_END 0x0FFFFFFFF
108 
109 #define RECORDING_ENTRY_NAME 0x010000001
110 #define RECORDING_ENTRY_DESCRIPTION 0x010000002
111 #define RECORDING_ENTRY_NOTES 0x010000003
112 #define RECORDING_ENTRY_OBJETIVE 0x010000004
113 #define RECORDING_ENTRY_PROCESSING_SUMMARY 0x010000005
114 #define RECORDING_ENTRY_SPECIAL_SCAN_MODE 0x010000006
115 #define RECORDING_ENTRY_SCAN_TYPE 0x010000007
116 #define OLEDB_RECORDING_ENTRY_SCAN_MODE 0x010000008
117 #define RECORDING_ENTRY_NUMBER_OF_STACKS 0x010000009
118 #define RECORDING_ENTRY_LINES_PER_PLANE 0x01000000A
119 #define RECORDING_ENTRY_SAMPLES_PER_LINE 0x01000000B
120 #define RECORDING_ENTRY_PLANES_PER_VOLUME 0x01000000C
121 #define RECORDING_ENTRY_IMAGES_WIDTH 0x01000000D
122 #define RECORDING_ENTRY_IMAGES_HEIGHT 0x01000000E
123 #define RECORDING_ENTRY_IMAGES_NUMBER_PLANES 0x01000000F
124 #define RECORDING_ENTRY_IMAGES_NUMBER_STACKS 0x010000010
125 #define RECORDING_ENTRY_IMAGES_NUMBER_CHANNELS 0x010000011
126 #define RECORDING_ENTRY_LINSCAN_XY_SIZE 0x010000012
127 #define RECORDING_ENTRY_SCAN_DIRECTION 0x010000013
128 #define RECORDING_ENTRY_TIME_SERIES 0x010000014
129 #define RECORDING_ENTRY_ORIGINAL_SCAN_DATA 0x010000015
130 #define RECORDING_ENTRY_ZOOM_X 0x010000016
131 #define RECORDING_ENTRY_ZOOM_Y 0x010000017
132 #define RECORDING_ENTRY_ZOOM_Z 0x010000018
133 #define RECORDING_ENTRY_SAMPLE_0X 0x010000019
134 #define RECORDING_ENTRY_SAMPLE_0Y 0x01000001A
135 #define RECORDING_ENTRY_SAMPLE_0Z 0x01000001B
136 #define RECORDING_ENTRY_SAMPLE_SPACING 0x01000001C
137 #define RECORDING_ENTRY_LINE_SPACING 0x01000001D
138 #define RECORDING_ENTRY_PLANE_SPACING 0x01000001E
139 #define RECORDING_ENTRY_PLANE_WIDTH 0x01000001F
140 #define RECORDING_ENTRY_PLANE_HEIGHT 0x010000020
141 #define RECORDING_ENTRY_VOLUME_DEPTH 0x010000021
142 #define RECORDING_ENTRY_ROTATION 0x010000034
143 #define RECORDING_ENTRY_NUTATION 0x010000023
144 #define RECORDING_ENTRY_PRECESSION 0x010000035
145 #define RECORDING_ENTRY_SAMPLE_0TIME 0x010000036
146 
147 #define LASER_ENTRY_NAME 0x050000001
148 #define LASER_ENTRY_ACQUIRE 0x050000002
149 #define LASER_ENTRY_POWER 0x050000003
150 
151 #define DETCHANNEL_ENTRY_DETECTOR_GAIN_FIRST 0x070000003
152 #define DETCHANNEL_ENTRY_DETECTOR_GAIN_LAST 0x070000004
153 #define DETCHANNEL_ENTRY_INTEGRATION_MODE 0x070000001
154 #define DETCHANNEL_ENTRY_ACQUIRE 0x07000000B
155 #define DETCHANNEL_DETECTION_CHANNEL_NAME 0x070000014
156 
157 #define RECORDING_ENTRY_DESCRIPTION 0x010000002
158 
159 #define ILLUMCHANNEL_ENTRY_WAVELENGTH 0x090000003
160 #define ILLUMCHANNEL_ENTRY_AQUIRE 0x090000004
161 #define ILLUMCHANNEL_DETCHANNEL_NAME 0x090000005
162 
163 #define TRACK_ENTRY_ACQUIRE 0x040000006
164 #define TRACK_ENTRY_NAME 0x04000000C
165 #define TYPE_SUBBLOCK 0
166 #define TYPE_LONG 4
167 #define TYPE_RATIONAL 5
168 #define TYPE_ASCII 2
169 // .NAME vtkLSMReader - read LSM files
170 // .SECTION Description
171 // vtkLSMReader is a source object that reads LSM files.
172 // It should be able to read most any LSM file
173 //
174 // .SECTION Thanks
175 // This class was developed as a part of the BioImageXD Project.
176 // The BioImageXD project includes the following people:
177 //
178 // Dan White <dan@chalkie.org.uk>
179 // Kalle Pahajoki <kalpaha@st.jyu.fi>
180 // Pasi Kankaanp�� <ppkank@bytl.jyu.fi>
181 //
182 
183 #ifndef __vtkLSMReader_h
184 #define __vtkLSMReader_h
185 
186 #include "vtkImageSource.h"
187 #include "vtkImageAlgorithm.h"
188 #include "vtkIntArray.h"
189 #include "vtkUnsignedIntArray.h"
190 #include "vtkUnsignedLongArray.h"
191 #include "vtkDoubleArray.h"
192 #include "vtkUnsignedShortArray.h"
193 #include "vtkUnsignedCharArray.h"
194 #include "vtkStringArray.h"
195 
196 #define TIFF_BYTE 1
197 #define TIFF_ASCII 2
198 #define TIFF_SHORT 3
199 #define TIFF_LONG 4
200 #define TIFF_RATIONAL 5
201 
202 #define LSM_MAGIC_NUMBER 42
203 
204 #define LSM_COMPRESSED 5
205 
206 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
207 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
208 
209 #include "vtkLSMConfigure.h"
210 
211 class VTKLSM_EXPORT vtkLSMReader:public vtkImageAlgorithm
212 {
213 public:
214 
215  static vtkLSMReader * New();
216 
217  vtkTypeMacro(vtkLSMReader, vtkImageAlgorithm);
218  virtual void PrintSelf(ostream & os, vtkIndent indent);
219 
220  // Description:
221  // Get the file extensions for this format.
222  // Returns a string with a space separated list of extensions in
223  // the format .extension
224  const char * GetFileExtensions()
225  {
226  return ".lsm .LSM";
227  }
228 
229  int GetHeaderIdentifier();
230 
231  bool IsValidLSMFile();
232 
233  bool IsCompressed();
234 
235  int GetNumberOfTimePoints();
236 
237  int GetNumberOfChannels();
238 
239  int OpenFile();
240 
241  int GetChannelColorComponent(int, int);
242 
243  char * GetChannelName(int);
244 
245  void SetFileName(const char *);
246 
247  //void ExecuteInformation();
248  int RequestInformation (
249  vtkInformation * vtkNotUsed(request),
250  vtkInformationVector * *vtkNotUsed(inputVector),
251  vtkInformationVector * outputVector);
252  void SetUpdateTimePoint(int);
253 
254  void SetUpdateChannel(int);
255 
256  void SetDataByteOrderToBigEndian();
257 
258  void SetDataByteOrderToLittleEndian();
259 
260  void SetDataByteOrder(int);
261 
262  int GetDataByteOrder();
263 
264  const char * GetDataByteOrderAsString();
265 
266  // Description:
267  // Set/Get the byte swapping to explicitly swap the bytes of a file.
268  vtkSetMacro(SwapBytes, int);
269  virtual int GetSwapBytes() { return this->SwapBytes; }
270  vtkBooleanMacro(SwapBytes, int);
271 
272  int GetDataTypeForChannel(unsigned int channel);
273 
274  vtkGetStringMacro(Objective);
275  vtkGetStringMacro(Description);
276 
277  vtkGetStringMacro(FileName);
278  vtkGetVector3Macro(VoxelSizes, double);
279  vtkGetVectorMacro(Dimensions, int, 5);
280  vtkGetVectorMacro(NumberOfIntensityValues, int, 4);
281  vtkGetVectorMacro(DataSpacing, double, 3);
282  vtkGetMacro(Identifier, unsigned short);
283  vtkGetMacro(NewSubFileType, unsigned int);
284  vtkGetMacro(Compression, unsigned int);
285  vtkGetMacro(SamplesPerPixel, unsigned int);
286  vtkGetMacro(ScanType, unsigned short);
287  vtkGetMacro(DataType, int);
288  vtkGetMacro(TimeInterval, double);
289  vtkGetObjectMacro(TimeStampInformation, vtkDoubleArray);
290  vtkGetObjectMacro(ChannelColors, vtkIntArray);
291  vtkGetObjectMacro(TrackWavelengths, vtkDoubleArray);
292  unsigned int GetUpdateChannel();
293 
294  vtkImageData * GetTimePointOutput(int, int);
295 
296 protected:
297 
298  vtkLSMReader();
299  ~vtkLSMReader();
300 
301  int TIFF_BYTES(unsigned short);
302 
303  int BYTES_BY_DATA_TYPE(int);
304 
305  void ClearFileName();
306 
307  void Clean();
308 
309  unsigned long ReadImageDirectory(ifstream *, unsigned long);
310 
311  int AllocateChannelNames(int);
312 
313  int SetChannelName(const char *, int);
314 
315  int ClearChannelNames();
316 
317  int FindChannelNameStart(const char *, int);
318 
319  int ReadChannelName(const char *, int, char *);
320 
321  int ReadChannelDataTypes(ifstream *, unsigned long);
322 
323  int ReadChannelColorsAndNames(ifstream *, unsigned long);
324 
325  int ReadTimeStampInformation(ifstream *, unsigned long);
326 
327  int ReadLSMSpecificInfo(ifstream *, unsigned long);
328 
329  int AnalyzeTag(ifstream *, unsigned long);
330 
331  int ReadScanInformation(ifstream *, unsigned long);
332 
333  int NeedToReadHeaderInformation();
334 
335  void NeedToReadHeaderInformationOn();
336 
337  void NeedToReadHeaderInformationOff();
338 
339  unsigned long SeekFile(unsigned long);
340 
341  unsigned long GetOffsetToImage(int, int);
342 
343  ifstream * GetFile();
344 
345  int RequestUpdateExtent(
346  vtkInformation *request,
347  vtkInformationVector **inputVector,
348  vtkInformationVector *outputVector);
349 
350  int RequestData(
351  vtkInformation *vtkNotUsed(request),
352  vtkInformationVector **vtkNotUsed(inputVector),
353  vtkInformationVector *outputVector);
354 
355  //void ExecuteData(vtkDataObject *out);
356  void CalculateExtentAndSpacing(int extent[6], double spacing[3]);
357  void DecodeHorizontalDifferencing(unsigned char *, int);
358 
359  void DecodeHorizontalDifferencingUnsignedShort(unsigned short *, int);
360 
361  void DecodeLZWCompression(unsigned char *, int);
362 
363  void ConstructSliceOffsets();
364 
365  unsigned long GetStripByteCount(unsigned int timepoint, unsigned int slice);
366 
367  unsigned long GetSliceOffset(unsigned int timepoint, unsigned int slice);
368 
369  vtkStringArray *LaserNames;
370 
371  vtkDoubleArray *TrackWavelengths;
372  vtkDoubleArray *DetectorOffsetFirstImage;
373  vtkDoubleArray *DetectorOffsetLastImage;
374 
375  vtkUnsignedLongArray *ImageOffsets;
376  vtkUnsignedLongArray *ReadSizes;
377  vtkUnsignedIntArray *StripOffset;
378  vtkUnsignedIntArray *ChannelDataTypes;
379  vtkUnsignedIntArray *StripByteCount;
380 
381  vtkUnsignedShortArray *BitsPerSample;
382 
383  double VoxelSizes[3];
384 
386  unsigned long ColorMapOffset;
387  unsigned long ChannelInfoOffset;
388  unsigned long ChannelDataTypesOffset;
390 
391  unsigned int SamplesPerPixel;
392  unsigned int LSMSpecificInfoOffset;
393  unsigned int NewSubFileType;
394  unsigned int Compression;
395 
396  int Dimensions[5]; // x,y,z,time,channels
397  int NumberOfIntensityValues[4];
399  int IntUpdateExtent[6];
402 
404  unsigned short Identifier;
405  unsigned short PlanarConfiguration;
406  unsigned short Predictor;
407  unsigned short ScanType;
408 
409  ifstream *File;
410  char *FileName;
411 
412  double DataSpacing[3];
413  int DataExtent[6];
415  int DataType;
416 
417  vtkIntArray *ChannelColors;
418  char **ChannelNames;
419  vtkDoubleArray *TimeStampInformation;
420  char *Objective;
421  char *Description;
422  double TimeInterval;
423 
424  unsigned char CharPointerToUnsignedChar(char *);
425 
426  int CharPointerToInt(char *);
427 
428  unsigned int CharPointerToUnsignedInt(char *);
429 
430  short CharPointerToShort(char *);
431 
432  unsigned short CharPointerToUnsignedShort(char *);
433 
434  double CharPointerToDouble(char *);
435 
436  int ReadInt(ifstream *, unsigned long &);
437 
438  unsigned int ReadUnsignedInt(ifstream *, unsigned long &);
439 
440  short ReadShort(ifstream *, unsigned long &);
441 
442  unsigned short ReadUnsignedShort(ifstream *, unsigned long &);
443 
444  double ReadDouble(ifstream *, unsigned long &);
445 
446  std::streamsize ReadFile(ifstream *, unsigned long &, unsigned int, char *, bool swap = false);
447 
448  std::streamsize ReadData(ifstream *, unsigned long &, unsigned int, char *);
449 
450 private:
451  vtkLSMReader(const vtkLSMReader &); // Not implemented.
452  void operator=(const vtkLSMReader &); // Not implemented.
453 };
454 #endif
unsigned short Identifier
Definition: vtkLSMReader.h:404
vtkUnsignedIntArray * StripOffset
Definition: vtkLSMReader.h:377
vtkDoubleArray * DetectorOffsetLastImage
Definition: vtkLSMReader.h:373
vtkUnsignedIntArray * ChannelDataTypes
Definition: vtkLSMReader.h:378
vtkIntArray * ChannelColors
Definition: vtkLSMReader.h:417
virtual int GetSwapBytes()
Definition: vtkLSMReader.h:269
unsigned short PlanarConfiguration
Definition: vtkLSMReader.h:405
char * Description
Definition: vtkLSMReader.h:421
vtkDoubleArray * DetectorOffsetFirstImage
Definition: vtkLSMReader.h:372
vtkUnsignedIntArray * StripByteCount
Definition: vtkLSMReader.h:379
vtkDoubleArray * TimeStampInformation
Definition: vtkLSMReader.h:419
unsigned int Compression
Definition: vtkLSMReader.h:394
char ** ChannelNames
Definition: vtkLSMReader.h:418
unsigned long ChannelDataTypesOffset
Definition: vtkLSMReader.h:388
vtkStringArray * LaserNames
Definition: vtkLSMReader.h:369
unsigned long NumberOfLastAccessedImage
Definition: vtkLSMReader.h:389
unsigned short Predictor
Definition: vtkLSMReader.h:406
char * Objective
Definition: vtkLSMReader.h:420
unsigned short PhotometricInterpretation
Definition: vtkLSMReader.h:403
vtkDoubleArray * TrackWavelengths
Definition: vtkLSMReader.h:371
vtkUnsignedLongArray * ImageOffsets
Definition: vtkLSMReader.h:375
unsigned long ChannelInfoOffset
Definition: vtkLSMReader.h:387
vtkUnsignedLongArray * ReadSizes
Definition: vtkLSMReader.h:376
unsigned long ColorMapOffset
Definition: vtkLSMReader.h:386
ifstream * File
Definition: vtkLSMReader.h:409
unsigned int NewSubFileType
Definition: vtkLSMReader.h:393
double TimeInterval
Definition: vtkLSMReader.h:422
vtkUnsignedShortArray * BitsPerSample
Definition: vtkLSMReader.h:381
char * FileName
Definition: vtkLSMReader.h:410
unsigned int LSMSpecificInfoOffset
Definition: vtkLSMReader.h:392
int NumberOfScalarComponents
Definition: vtkLSMReader.h:414
unsigned int SamplesPerPixel
Definition: vtkLSMReader.h:391
unsigned short ScanType
Definition: vtkLSMReader.h:407
const char * GetFileExtensions()
Definition: vtkLSMReader.h:224
unsigned long OffsetToLastAccessedImage
Definition: vtkLSMReader.h:385