[Insight-developers] Raw image IO factory?

Stephen R. Aylward aylward@unc.edu
Mon, 03 Feb 2003 14:21:33 -0500


The changes were only made to the writer.   The rules are

1) If the user specifies an ElementDataFileName (other than LOCAL), then 
the filename extension is changed to .mhd.   The ElementDataFileName can 
have any extension.

2) If no ElementDataFileName is specified (or is set to LOCAL) and the 
user specifies a filename extension other than .mha, then the filename 
is forced to have a .mhd extension and the ElementDataFileName is set 
equal to the filename with .mhd changed to .raw

3) Otherwise, no changes need to be made to what the user specified.

So if you pass a filename ending in .mhd, it automatically writes that 
file and a .raw datafile.   If you pass a filename ending in .mha, 
everything is written to that one file.   If you bother specifying an 
elementdatafilename, then the filename is forced to have a .mhd extension.

I generally don't like having software account for user IQ errors - 
generally I assume that if the user wants to save a file called 
myimage.blah, we should let them.   If you go against this rule, the 
exact users this rule is meant to help will end up having trouble - they 
won't be able to read in the myimage.blah file that they just wrote, and 
they won't be able to figure out why...   The difficulty is resolving 
such an issue with the IO factories, so...the above seems like an 
exception to my philosophy.

Stephen



Joshua Cates wrote:
> Hi Stephen,
> 
> When just reading a file, will the MetaImageIO still recognize the
> ElementDataFile tag even if named with extension .mha, or must all .mha's
> with this tag be renamed to .mhd?
> 
> Josh.
> 
> ______________________________
>  Josh Cates			
>  School of Computer Science	
>  University of Utah
>  Email: cates@sci.utah.edu
>  Phone: (801) 587-7697
>  URL:   http://www.sci.utah.edu/~cates
> 
> 
> On Mon, 3 Feb 2003, Stephen R. Aylward wrote:
> 
> 
>>I've made the changes, but will not check-in until after the first tag.
>>
>>About the extensions...they seemed like a good idea at the time and I 
>>hesitate to change them, but I am open to adding other aliases :)
>>
>>s
>>
>>Miller, James V (Research) wrote:
>>
>>>Boy, it going to take me a while to engrain these extensions
>>>into my subconscious.  My internal parse table maps "mhd" to
>>>mean "meta header and data in one file" and "mha" to mean 
>>>something like "meta header alias" (or meta header in one file 
>>>with an external file for data). The latter is a bit of a stretch.
>>>
>>>But this is the opposite of what they mean.
>>>
>>>I probably would have used the extensions:
>>>
>>>"mh" - meta header that indicates the path to a file for the raw data
>>>"mhd" - meta header and data in one file
>>>
>>>
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>From: Stephen R. Aylward [mailto:aylward@unc.edu]
>>>>Sent: Friday, January 31, 2003 2:17 PM
>>>>To: Miller, James V (Research)
>>>>Cc: 'Luis Ibanez'; Insight-developers (E-mail)
>>>>Subject: Re: [Insight-developers] Raw image IO factory?
>>>>
>>>>
>>>>Hi,
>>>>
>>>>Sorry that I couldn't make the tcon...busy selling my soul for 
>>>>additional funding...the bid is up to $2....
>>>>
>>>>Anyway, '.mhd' was originally intended to indicate a metaHeader file 
>>>>that only contained the name of the data file while '.mha' 
>>>>was intended 
>>>>to indicate a file containing header and data ('all').  But, 
>>>>we stopped 
>>>>using that when we thought ITK wasn't going to use the postfix to 
>>>>distinguish files...perhaps now we should return to that....
>>>>
>>>>Stephen
>>>>
>>>>Miller, James V (Research) wrote:
>>>>
>>>>
>>>>>Luis,
>>>>>
>>>>>Using the meta image format as an output factory worked 
>>>>>for me.  So I'll use that.
>>>>>
>>>>>What extension should I use?  It seems to respond to both
>>>>>"mha" and "mhd".
>>>>>
>>>>>Jim
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>-----Original Message-----
>>>>>>From: Miller, James V (Research) 
>>>>>>Sent: Friday, January 31, 2003 2:03 PM
>>>>>>To: 'Luis Ibanez'
>>>>>>Cc: Insight-developers (E-mail)
>>>>>>Subject: RE: [Insight-developers] Raw image IO factory?
>>>>>>
>>>>>>
>>>>>>I guess what I what is to be able to write 
>>>>>>out a raw image using a factory.  I want a command
>>>>>>line program that does
>>>>>>
>>>>>>./MyProgram input.png output.raw
>>>>>>
>>>>>>and have it write out a raw image.  And if I do
>>>>>>
>>>>>>./MyProgram input.png output.png
>>>>>>
>>>>>>it would write a png file.
>>>>>>
>>>>>>I agree that you loose the spacing and size, etc. But I am 
>>>>>>trying to do a quick and dirty integration of an ITK algorithm
>>>>>>to a legacy system and want to just rig up an IPC process.  So
>>>>>>my existing app tells my ITK app to run on a particular input
>>>>>>file and output a particular output file which it will then 
>>>>>>read (since they app already knows the size and spacing, it can 
>>>>>>just do a bulk read).
>>>>>>
>>>>>>Can I use the Meta image as an output factory?  If so, that will
>>>>>>do what I want.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>-----Original Message-----
>>>>>>>From: Luis Ibanez [mailto:luis.ibanez@kitware.com]
>>>>>>>Sent: Friday, January 31, 2003 1:53 PM
>>>>>>>To: Miller, James V (Research)
>>>>>>>Cc: Insight-developers (E-mail)
>>>>>>>Subject: Re: [Insight-developers] Raw image IO factory?
>>>>>>>
>>>>>>>
>>>>>>>Hi Jim,
>>>>>>>
>>>>>>>The problem with Raw is that even if we set a factory
>>>>>>>that figures out the correct ImageIO from the file
>>>>>>>extension, there is no easy way to arrange for the
>>>>>>>additional image information to be passed to the
>>>>>>>ImageIO.
>>>>>>>
>>>>>>>In the current mode for raw, the user has to instantiate
>>>>>>>the RawImageIO object, pass the spacing, size and origin
>>>>>>>of the image, and then trigger the execution of the reader.
>>>>>>>
>>>>>>>I personaly think that being so easy to create a MetaImage
>>>>>>>header or a VTK header for a raw file, we should rather
>>>>>>>encourage users to use those mechanism as a way of 'wrapping'
>>>>>>>a raw file.
>>>>>>>
>>>>>>>At the end of the day, a 'raw' image is an incomplete
>>>>>>>file and there is no way to figure out the content
>>>>>>>without the additional information.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Luis
>>>>>>>
>>>>>>>
>>>>>>>-----------------------------------------
>>>>>>>
>>>>>>>Miller, James V (Research) wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>Should there be a raw image IO factory for raw images?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>There is no RawImageIOFactory in the system.  Currently the 
>>>>>>>
>>>>>>>RawImageIO 
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>object says it can write a file as long as there is a 
>>>>>>>
>>>>>>>filename.  So I 
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>imagine this is why there is not a corresponding 
>>>>>>>
>>>>>>RawImageIOFactory 
>>>>>>
>>>>>>
>>>>>>
>>>>>>>>(since it would respond yes to everything). 
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>But when running in factory mode, could a RawImageIOFactory 
>>>>>>>
>>>>>>>respond to 
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>being able to read/write files if the extension is ".raw"?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>*Jim Miller*
>>>>>>>>*/_____________________________________/*
>>>>>>>>/Visualization & Computer Vision//
>>>>>>>>/GE Research/
>>>>>>>>/Bldg. KW, Room C218B/
>>>>>>>>/P.O. Box 8, Schenectady NY 12301/
>>>>>>>>
>>>>>>>>//_millerjv@research.ge.com <mailto:millerjv@research.ge.com>_/
>>>>>>>>
>>>>>>>>/_james.miller@research.ge.com_/
>>>>>>>>/(518) 387-4005, Dial Comm: 8*833-4005, /
>>>>>>>>/Cell: (518) 505-7065, Fax: (518) 387-6981/
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>_______________________________________________
>>>>>>Insight-developers mailing list
>>>>>>Insight-developers@public.kitware.com
>>>>>>http://public.kitware.com/mailman/listinfo/insight-developers
>>>>>>
>>>>>
>>>>>_______________________________________________
>>>>>Insight-developers mailing list
>>>>>Insight-developers@public.kitware.com
>>>>>http://public.kitware.com/mailman/listinfo/insight-developers
>>>>
>>>>
>>>>-- 
>>>>===============================================
>>>>Dr. Stephen R. Aylward
>>>>Assistant Professor of Radiology
>>>>Adjunct Assistant Professor of Computer Science
>>>>http://caddlab.rad.unc.edu
>>>>aylward@unc.edu
>>>>(919) 966-9695
>>>>
>>>
>>>_______________________________________________
>>>Insight-developers mailing list
>>>Insight-developers@public.kitware.com
>>>http://public.kitware.com/mailman/listinfo/insight-developers
>>
>>
>>-- 
>>===============================================
>>Dr. Stephen R. Aylward
>>Assistant Professor of Radiology
>>Adjunct Assistant Professor of Computer Science
>>http://caddlab.rad.unc.edu
>>aylward@unc.edu
>>(919) 966-9695
>>
>>_______________________________________________
>>Insight-developers mailing list
>>Insight-developers@public.kitware.com
>>http://public.kitware.com/mailman/listinfo/insight-developers
>>
> 
> 


-- 
===============================================
Dr. Stephen R. Aylward
Assistant Professor of Radiology
Adjunct Assistant Professor of Computer Science
http://caddlab.rad.unc.edu
aylward@unc.edu
(919) 966-9695