[Insight-users] How do I read files with an "extended file name syntax"?

Douglas Alan douglas_alan at harvard.edu
Tue Oct 31 19:17:04 EST 2006


BACKGROUND:

FITS is the standard file format for astronomical data.  The most
popular library for reading and writing FITS files is CFITSIO.  When
you tell CFITSIO what file you would like it to read, the filename
doesn't have to name a real file.  The "filename" can, for instance,
be a URL.  In this case, CFITSIO will automagically download the file
for you into a temporary location and then read from the temporary
file.  CFITSIO also supports via its "extended file name syntax" a
wide variety of different image manipulation functions such as slicing
and transform filters.  For instance, if I tell CFITSIO to open the
file

   http://foo.com/myfile.fits[1:512:2, 2:512:2][pix sqrt(X)]

it will fetch the file "myfile.fits" from foo.com, open a 256x256
subimage consisting of the odd numbered columns and the even numbered
rows of the image, and then it will replace each pixel value with its
square root.

WHAT I WANT TO DO:

Ideally, I'd like to make an ITK ImageIO class that can understand the
CFITSIO extended filename syntax and have it just "do the right
thing".  I think that the only thing preventing this from just working
at the moment, is that

   ImageFileReader::TestFileExistanceAndReadability()

is being called before my ReadImageInformation() method is being
called.  If this check could be turned off, then I think that I'd be
all set.

Is there really any good reason for this test?  After all, I have to
handle in ReadImageInformation() the situation where CFITSIO can't
open the file anyway, so it seems that this test is (1) redundant and
(2) gets in the way.

Is there a way of deactivating this test?  If not, might the ability
to deactivate this test be added in the future as a runtime option?

AN ALTERNATIVE?

Alternatively, I might bypass the ImageIOFactory system altogether and
just read FITS files in my application directly.  If so, I still need
to be able to make an ITK Image from the FITS file.  I was thinking
that I could subclass ImageSource, pasting in the source code from
RandomImageSource and then modifying it to read FITS files rather than
generate random data.  Does that make sense?  Is there a better
alternative?

|>oug


More information about the Insight-users mailing list