<span style="color:rgb(80,0,80)">On Wed, Nov 21, 2012 at 2:10 PM, Padfield, Dirk R (GE Global Research)</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)"><</span><a href="mailto:padfield@research.ge.com">padfield@research.ge.com</a><span style="color:rgb(80,0,80)">> wrote:</span><br style="color:rgb(80,0,80)">
<span style="color:rgb(80,0,80)">> </span><span style="color:rgb(80,0,80)">Before the “MET_StringToWordArray”</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">> parsed words based only on spaces, but now if it sees a double quote it</span><br style="color:rgb(80,0,80)">
<span style="color:rgb(80,0,80)">> ignores spaces until it sees the next double quote. Surrounding the</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">> filename with quotes is consistent with how executables handle file names</span><br style="color:rgb(80,0,80)">
<span style="color:rgb(80,0,80)">> with spaces.</span><div><br></div><div>I would point out that this would cause problems if anybody ever needed to handle filenames containing quote characters (which is perfectly legal on most systems).</div>
<div><br></div><div>I am just an occasional user of MetaIO and I don't know if the core developers feel that such a level of generality is necessary, but (short of implementing a complicated lexer for a C-like or shell-like quoted string syntax) one simple and general solution would be to use backslash as an escape character ("\ " = non-delimiting space, "\\" = single backslash, "\x" = "x" for any character x, all without the double quotes). This would also be consistent with one way in which file names with spaces and other special characters are handled on the (Unix) command line. The problem does remain of what to do if a backslash is encountered at the end of the (already split out) line.</div>
<div><br></div><div>But then again, it might be considered weird that "\%" would behave just like "%"; there would still be no generally applicable way to handle filenames containing a "%" (a quick look at the code (metaImage.cxx) suggests that "50%dose.dat" would behave unexpectedly, as would "50%%dose.dat" and "50%%section.dat", while "50%section.dat" would result in a segfault). There may or may not be a (sufficiently) backward-compatible way to fix all of these issues.</div>
<div><br></div><div>Mark<br><div class="gmail_extra"><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Nov 21, 2012 at 11:57 AM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Dirk,<br>
<br>
If you do submit a patch, beware that you will not be able to merge it<br>
since it is in the ThirdParty metaio tree. This is not a problem for<br>
reviewers, just that someone from Kitware who has the permission to do<br>
so will have to merge it. This is because meta io is used in several<br>
packages other than ITK.<br>
<br>
Looks like a good idea. You should probbaly add Stephen Aylward as a reviewer.<br>
<br>
Bill<br>
<div><div class="h5"><br>
On Wed, Nov 21, 2012 at 2:10 PM, Padfield, Dirk R (GE Global Research)<br>
<<a href="mailto:padfield@research.ge.com">padfield@research.ge.com</a>> wrote:<br>
> Hi ITK Developers,<br>
><br>
><br>
><br>
> I want to gather your thoughts before submitting a patch. I frequently read<br>
> lists of 2D images into ITK as a volume, and I use metaImage .mhd files to<br>
> specify the header information. Unfortunately, my code needs to handle<br>
> images that have spaces in the names, and this doesn’t currently work with<br>
> the regular expression functionality in metaImage. I end up having to use<br>
> “LIST” instead, but this becomes cumbersome. So I modified the code of<br>
> Modules\ThirdParty\MetaIO\src\MetaIO\metaUtils.cxx slightly to handle file<br>
> names surrounded by double quotes. Before the “MET_StringToWordArray”<br>
> parsed words based only on spaces, but now if it sees a double quote it<br>
> ignores spaces until it sees the next double quote. Surrounding the<br>
> filename with quotes is consistent with how executables handle file names<br>
> with spaces.<br>
><br>
><br>
><br>
> For example, to read the first 90 slices of a series, I can now do this:<br>
><br>
> ElementDataFile = "B - 2(fld 1 z %02d).tif" 1 90 1<br>
><br>
><br>
><br>
> My question is: does anyone see any problem with making such a change? I<br>
> just wanted to gather some feedback before submitting the patch.<br>
><br>
><br>
><br>
> Also, if anyone wants me to add them as a reviewer to the patch, please let<br>
> me know.<br>
><br>
><br>
><br>
> Thanks,<br>
><br>
> Dirk<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://kitware.com/products/protraining.php" target="_blank">http://kitware.com/products/protraining.php</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-developers" target="_blank">http://www.itk.org/mailman/listinfo/insight-developers</a><br>
><br>
<br>
<br>
<br>
--<br>
Unpaid intern in BillsBasement at noware dot com<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://kitware.com/products/protraining.php" target="_blank">http://kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-developers" target="_blank">http://www.itk.org/mailman/listinfo/insight-developers</a><br>
</blockquote></div><br></div></div>