[Insight-users] MetaImage: absolute path in ElementDataFile not working

Florian Pierron F.Pierron at exeter.ac.uk
Tue May 13 06:24:38 EDT 2008


Hi Luis,

Thanks for your quick reply.

I am using VC2005 to compile the code. I don't see anything obviously 
wrong with the path, it is:
ElementDataFile = C:\Program Files\Data\MyData.raw

I have attached the .mha file and the .raw image. Let me know if you can 
load it.

Regards,
Florian

***********************
ObjectType = Image
NDims = 2
DimSize = 50 50
ElementByteOrderMSB = False
ElementNumberOfChannels = 1
ElementType = MET_UCHAR
ElementDataFile = C:\Program Files\Data\MyData.raw
***********************


On 12/05/2008 14:50, Luis Ibanez wrote:
>
> Hi Florian,
>
> Could you please post the *exact* absolute path that you were using
> when you encounter this problem ?
>
> We are able to read files with absolute path without any problem.
> It is therefore likely that there is something special about the
> path that you were using.
>
> Also, please let us know what platform are you using.
>
>
>    Thanks
>
>
>       Luis
>
>
> ---------------------
> Florian Pierron wrote:
>> Dear ITK developer team,
>>
>> I noticed that having an absolute path in the ElementDataFile is not 
>> supported in ITK 3.4.0. I don't know if there is a good reason for 
>> that or if it's just by mistake but it seems that there is an easy 
>> fix to that (if I am not wrong...). I have changed the following 
>> lines in \Utilities\MetaIO\metaImage.cxx:
>>
>> - usePath = MET_GetFilePath(_headerName, pathName)
>>
>> by
>>
>> +  usePath = !MET_GetFilePath(elementDataFileName.c_str(), pathName) &&
>> +                 MET_GetFilePath(_headerName, pathName);
>>
>> So that usePath (which determines in fact if the path to the header / 
>> meta file should be append to the elementDataFileName) is used only 
>> if the elementDataFileName is not an absolute path and if there is a 
>> path for the header / meta file.
>>
>> Find attached the patch file.
>>
>> Regards,
>> Florian
>>
>>
>> ------------------------------------------------------------------------
>>
>> ### Eclipse Workspace Patch 1.0
>> #P ITK_3_4_0
>> Index: Utilities/MetaIO/metaImage.cxx
>> ===================================================================
>> RCS file: /cvsroot/Insight/Insight/Utilities/MetaIO/metaImage.cxx,v
>> retrieving revision 1.76
>> diff -u -r1.76 metaImage.cxx
>> --- Utilities/MetaIO/metaImage.cxx    12 Sep 2007 11:46:05 -0000    1.76
>> +++ Utilities/MetaIO/metaImage.cxx    12 May 2008 10:53:09 -0000
>> @@ -3,7 +3,7 @@
>>    Program:   MetaIO
>>    Module:    $RCSfile: metaImage.cxx,v $
>>    Language:  C++
>> -  Date:      $Date: 2007-09-12 11:46:05 $
>> +  Date:      $Date: 2007/09/12 11:46:05 $
>>    Version:   $Revision: 1.76 $
>>  
>>    Copyright (c) Insight Software Consortium. All rights reserved.
>> @@ -1118,10 +1118,6 @@
>>      return false;
>>      }
>>  
>> -  bool usePath;
>> -  char pathName[255];
>> -  usePath = MET_GetFilePath(_headerName, pathName);
>> -
>>    char* buf = new char[8001];
>>    inputStream.read(buf,8000);
>>    unsigned long fileSize = inputStream.gcount();
>> @@ -1139,6 +1135,10 @@
>>  
>>    std::string elementDataFileName = 
>> M_GetTagValue(header,"ElementDataFile");
>>  
>> +  char pathName[255];
>> +  bool usePath = !MET_GetFilePath(elementDataFileName.c_str(), 
>> pathName) && +                 MET_GetFilePath(_headerName, pathName);
>> +
>>    char* fName = new char[512];
>>  
>>    if(!strcmp("Local", elementDataFileName.c_str()) || @@ -1375,10 
>> +1375,10 @@
>>        }
>>  
>>      int i, j;
>> -    bool usePath;
>>      char pathName[255];
>>      char fName[255];
>> -    usePath = MET_GetFilePath(m_FileName, pathName);
>> +    bool usePath = !MET_GetFilePath(m_ElementDataFileName, pathName) 
>> && +                   MET_GetFilePath(m_FileName, pathName);
>>  
>>      if(!strcmp("Local", m_ElementDataFileName) ||         
>> !strcmp("LOCAL", m_ElementDataFileName) ||
>> @@ -1620,7 +1620,8 @@
>>      }
>>  
>>    char pathName[255];
>> -  bool usePath = MET_GetFilePath(m_FileName, pathName);
>> +  bool usePath = !MET_GetFilePath(m_ElementDataFileName, pathName) 
>> && +                 MET_GetFilePath(m_FileName, pathName);
>>    if(usePath)
>>      {
>>      char elementPathName[255];
>> @@ -2240,7 +2241,8 @@
>>      {
>>      char dataFileName[255];
>>      char pathName[255];
>> -    bool usePath = MET_GetFilePath(m_FileName, pathName);
>> +    bool usePath = !MET_GetFilePath(m_ElementDataFileName, pathName) 
>> && +                   MET_GetFilePath(m_FileName, pathName);
>>      if(usePath)
>>        {
>>        sprintf(dataFileName, "%s%s", pathName, m_ElementDataFileName);
>> @@ -2471,10 +2473,10 @@
>>        m_Quantity *= (_indexMax[i] - _indexMin[i] + 1);
>>        }
>>  
>> -    bool usePath;
>>      char pathName[255];
>>      char fName[255];
>> -    usePath = MET_GetFilePath(m_FileName, pathName);
>> +    bool usePath = !MET_GetFilePath(m_ElementDataFileName, pathName) 
>> && +                   MET_GetFilePath(m_FileName, pathName);
>>  
>>      if(!strcmp("Local", m_ElementDataFileName) ||         
>> !strcmp("LOCAL", m_ElementDataFileName) ||
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: MyData.mha
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080513/264ae281/attachment.asc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MyData.raw
Type: application/octet-stream
Size: 2500 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080513/264ae281/attachment.obj>


More information about the Insight-users mailing list