]> Creatis software - gdcm.git/commitdiff
Typo
authorjpr <jpr>
Fri, 23 Mar 2007 15:01:47 +0000 (15:01 +0000)
committerjpr <jpr>
Fri, 23 Mar 2007 15:01:47 +0000 (15:01 +0000)
Example/RawToDicom.cxx
Example/ReWriteExtended.cxx
Example/ToMRIregister.cxx
src/gdcmCommandManager.cxx
src/gdcmElementSet.cxx
src/gdcmFile.cxx
src/gdcmGlobal.h

index fa15cff3bd2528bb159f78b302d04aabc1f9b43e..e9fa0f66c386c78f0034dacb5244c5f6d52e9222 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: RawToDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/10/11 15:43:36 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2007/03/23 15:01:47 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -13,7 +13,7 @@
      This software is distributed WITHOUT ANY WARRANTY; without even
      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
      PURPOSE.  See the above copyright notices for more information.
-                                                                                
+                                      
 =========================================================================*/
 
 /**
@@ -38,10 +38,10 @@ void ConvertSwapZone(int pixelSize, void *Raw, size_t RawSize)
    if ( pixelSize == 2 )
    {
       uint16_t *im16 = (uint16_t*)Raw;
-            for( i = 0; i < RawSize / 2; i++ )
-            {
-               im16[i]= (im16[i] >> 8) | (im16[i] << 8 );
-            }     
+      for( i = 0; i < RawSize / 2; i++ )
+      {
+         im16[i]= (im16[i] >> 8) | (im16[i] << 8 );
+      }     
    }
    else if ( pixelSize == 4 )
    {
@@ -50,13 +50,13 @@ void ConvertSwapZone(int pixelSize, void *Raw, size_t RawSize)
       uint16_t low;
       uint32_t *im32 = (uint32_t*)Raw;
 
-            for( i = 0; i < RawSize / 4; i++ )
-            {
-               low     = im32[i] & 0x0000ffff; // 3412
-               high    = im32[i] >> 16;
-               s32     = low;
-               im32[i] = ( s32 << 16 ) | high;
-            }
+      for( i = 0; i < RawSize / 4; i++ )
+      {
+         low     = im32[i] & 0x0000ffff; // 3412
+         high    = im32[i] >> 16;
+         s32     = low;
+         im32[i] = ( s32 << 16 ) | high;
+      }
       
    }
 }
index 8681e4479440c3049235ded47e5d928a31100c09..6cf00218bbbd72b4bc2e56fba93a4fd893ddbf60 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: ReWriteExtended.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/03/17 14:56:29 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2007/03/23 15:01:47 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -42,7 +42,7 @@ int main(int argc, char *argv[])
    "        noshadow : user doesn't want to load Private groups (odd number)",
    "        noseq    : user doesn't want to load Sequences                  ",
    "        rgb      : user wants to transform LUT (if any) to RGB pixels   ",
-   "        debug    : user wants to run the program in 'debug mode'        ",
+   "        debug    : developper wants to run the program in 'debug mode'  ",
    FINISH_USAGE
 
    // ----- Initialize Arguments Manager ------   
@@ -90,6 +90,34 @@ int main(int argc, char *argv[])
    if (am->ArgMgrDefined("debug"))
       gdcm::Debug::DebugOn();
  
+ // ======================================================================= 
+   bool fail = false;
+      
+   int *boundRoiVal;
+   bool roi = false; 
+   if (am->ArgMgrDefined("roi"))
+   {
+      int nbRoiBound;
+      boundRoiVal = am->ArgMgrGetListOfInt("roi", &nbRoiBound);
+
+      if (nbRoiBound !=4)
+      {
+        std::cout << "Illegal number of 'ROI' boundary values (expected : 4, found:" 
+                  << nbRoiBound << "); 'ROI' ignored" << std::endl;
+        fail = true;
+      }
+      else
+        roi = true;   
+   }
+  
+   int beg = am->ArgMgrGetInt("firstFrame",0);
+   int end = am->ArgMgrGetInt("lastFrame",0);
+ // =======================================================================
    // if unused Params we give up
    if ( am->ArgMgrPrintUnusedLabels() )
    { 
@@ -118,29 +146,9 @@ int main(int argc, char *argv[])
        f->Delete();
        return 0;
    }
-   
-   gdcm::FileHelper *fh = gdcm::FileHelper::New(f);
-   void *imageData; 
-   int dataSize;
-  
-   if (rgb)
-   {
-      dataSize  = fh->GetImageDataSize();
-      imageData = fh->GetImageData(); // somewhat important... can't remember
-      fh->SetWriteModeToRGB();
-   }
-   else
-   {
-      dataSize  = fh->GetImageDataRawSize();
-      imageData = fh->GetImageDataRaw();// somewhat important... can't remember
-      fh->SetWriteModeToRaw();
-   }
 
-   if ( imageData == 0 ) // to avoid warning
-   {
-      std::cout << "Was unable to read pixels " << std::endl;
-   }
-   std::cout <<std::endl <<" dataSize " << dataSize << std::endl;
+
+   //std::cout <<std::endl <<" dataSize " << dataSize << std::endl;
    int nX,nY,nZ,sPP,planarConfig;
    std::string pixelType, transferSyntaxName;
    nX=f->GetXSize();
@@ -167,6 +175,87 @@ int main(int argc, char *argv[])
              << std::endl;
 
 
+   
+   gdcm::FileHelper *fh = gdcm::FileHelper::New(f);
+   void *imageData; 
+   int dataSize;
+  // ======================================================================= 
+    int subImDimX = nX;
+    int subImDimY = nY;
+    
+
+    if (roi)
+    {  
+    std::cout << " " << boundRoiVal[0] << " " <<  boundRoiVal[1] << " " << boundRoiVal[2] << " " <<
+     boundRoiVal[3] <<std::endl;
+      if (boundRoiVal[0]<0 || boundRoiVal[0]>=nX)
+      { 
+         std::cout << "xBegin out of bounds; 'roi' ignored" << std::endl;
+         fail = true;      
+      }
+      if (boundRoiVal[1]<0 || boundRoiVal[1]>=nX)
+      { 
+         std::cout << "xEnd out of bounds; 'roi' ignored" << std::endl;
+         fail = true;      
+      }
+      if (boundRoiVal[0] > boundRoiVal[1])
+      { 
+         std::cout << "xBegin greater than xEnd; 'roi' ignored" << std::endl;
+         fail = true;      
+      }
+
+      if (boundRoiVal[2]<0 || boundRoiVal[2]>=nY)
+      { 
+         std::cout << "yBegin out of bounds; 'roi' ignored" << std::endl;
+         fail = true;      
+      }
+      if (boundRoiVal[3]<0 || boundRoiVal[3]>=nY)
+      { 
+         std::cout << "yEnd out of bounds; 'roi' ignored" << std::endl;
+         fail = true;      
+      }
+      if (boundRoiVal[2] > boundRoiVal[3])
+      { 
+         std::cout << "yBegin greater than yEnd; 'roi' ignored" << std::endl;
+         fail = true;      
+      }  
+
+   } 
+   else
+   {
+  
+     boundRoiVal = new int(4);
+     boundRoiVal[0] = 0;
+     boundRoiVal[1] = nX-1;
+     boundRoiVal[2] = 0;
+     boundRoiVal[3] = nY-1;  
+  }
+
+   subImDimX = boundRoiVal[1]-boundRoiVal[0]+1;     
+   subImDimY = boundRoiVal[3]-boundRoiVal[2]+1;  
+    
+   // =======================================================================  
+   if (rgb)
+   {
+      dataSize  = fh->GetImageDataSize();
+      imageData = fh->GetImageData(); // somewhat important... can't remember
+      fh->SetWriteModeToRGB();
+   }
+   else
+   {
+      dataSize  = fh->GetImageDataRawSize();
+      imageData = fh->GetImageDataRaw();// somewhat important... can't remember
+      fh->SetWriteModeToRaw();
+   }
+
+   if ( imageData == 0 ) // to avoid warning
+   {
+      std::cout << "Was unable to read pixels " << std::endl;
+   }
+
+
    // We trust user. (just an example; *never* trust an user !)  
    fh->SetContentType((gdcm::ImageContentType)filecontent);
    
index a49a5ed97cf4bb922fe44cf948034fe87b5813a5..536208b94655718ab3e567ab6d5768c5a6978c62 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: ToMRIregister.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/10/23 15:51:33 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2007/03/23 15:01:48 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -22,6 +22,7 @@
 #include "gdcmDebug.h"
 #include "gdcmDirList.h"
 #include "gdcmUtil.h"
+#include "gdcmDataEntry.h"
 #include "gdcmArgMgr.h"
 #include <iostream>
 #include <sstream>
@@ -210,6 +211,8 @@ int main(int argc, char *argv[])
          
    // For all the Single SerieUID Files Sets of the gdcm::Serie
    gdcm::FileList *l = s->GetFirstSingleSerieUIDFileSet();
+   
+   char numero[5];
    while (l)
    {   
       nbFiles = l->size() ;
@@ -230,7 +233,10 @@ int main(int argc, char *argv[])
          xcm = s->SplitOnPosition(l);
     
          //int sliceNumber = 0; 
-
+         
+         float position =0.0;
+         char charPosition[10];
+         
          for (gdcm::XCoherentFileSetmap::iterator i = xcm.begin();
                                                   i != xcm.end();
                                                 ++i)
@@ -239,7 +245,10 @@ int main(int argc, char *argv[])
              std::cout << "[" << (*i).first << "]" << std::endl;
    
             s->OrderFileList((*i).second);  // sort the current XCoherent Fileset
-
+    
+            position = position + 1.0;
+            sprintf(charPosition, "%f", position);
+            
             //int imageNumber = 0;    
             for ( gdcm::FileList::iterator it =  ((*i).second)->begin();
                                            it != ((*i).second)->end();
@@ -253,6 +262,14 @@ int main(int argc, char *argv[])
                0020 0012 IS 1 Acquisition Number
                0020 0013 IS 1 Instance Number
            */
+
+           /*
+            Sure it needs ACR-NEMA elements : Study ID                20, 10 ?
+                                              Image Number            20, 12 ?
+                                              Location ('atof-able') -> 20, 50 ?    
+           */     
+            (*it)->InsertEntryString(charPosition,0x0020,0x0050, "DS");
+   
            
             (*it)->InsertEntryString("0",0x0008,0x0000, "UL"); // Needs to be present (actual length doesn't matter !)    
 
@@ -260,17 +277,24 @@ int main(int argc, char *argv[])
             str << serieNumber;
             (*it)->InsertEntryString(str.str(),0x0020,0x0011, "IS"); // Series Number
 
+           /*
             str.str("");
             str << imageNumber;
+            (*it)->InsertEntryString(str.str(),0x0020,0x0012, "IS"); // Acquisition Number
             (*it)->InsertEntryString(str.str(),0x0020,0x0013, "IS"); // Instance Number
+           */
    
+   sprintf(numero, "%04d", imageNumber);
+   (*it)->InsertEntryString(numero,0x0020,0x0012, "IS"); // Acquisition Number   
+   (*it)->InsertEntryString(numero,0x0020,0x0013, "IS"); // Instance Number
             // Load the pixels in RAM.    
       
                fh = gdcm::FileHelper::New(*it);     
                uint8_t *imageData = fh->GetImageDataRaw(); // Don't convert (Gray Pixels + LUT) into (RGB pixels) ?!?
                if (!imageData)
                   std::cout << "fail to read [" << (*it)->GetFileName() << std::endl;
-               fh->SetWriteTypeToACR();  
+               fh->SetWriteTypeToAcr();  
                fh->SetContentType(gdcm::UNMODIFIED_PIXELS_IMAGE);
     
                // forge the file name
@@ -282,11 +306,25 @@ int main(int argc, char *argv[])
                sprintf(fullWriteFilename, "%s%c%04d-%04d-%04d.dcm", 
                                       dirOut, gdcm::GDCM_FILESEPARATOR,
                                       serieNumber, sliceNumber, imageNumber);
-               if (verbose)
-                  std::cout << fullFilename << " -> " << fullWriteFilename << std::endl;
 
+               if (verbose)
+               {
+                 // show [sliceLocation 0x0020,1041 (if any)] old name, -> newname
+                 std::string strSliceLocation;
+                 /*  
+                 gdcm::DataEntry e = (*it)->GetDataEntry(0x0020,0x1041);
+                 if (e)
+                    strSliceLocation = e->GetString();
+                 else
+                    strSliceLocation = "";
+                 */ 
+                  strSliceLocation = (*it)->GetDataEntry(0x0020,0x1041)->GetString();   
+                  std::cout <<strSliceLocation << ": " << fullFilename << " -> " << fullWriteFilename << std::endl;
+               }
                // Write it, now
        
+               fh->SetWriteTypeToAcrLibido();
+       
                if (!fh->Write(fullWriteFilename))
                {
                   std::cout << "Fail to write :[" << fullWriteFilename << "]"
index bcd747171566eb72a986210b891ca7a53a581ab9..bb24b00588bd27e510d54eaf7dd0fbd996070e1e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmCommandManager.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/02/13 09:27:35 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2007/03/23 15:05:11 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -46,22 +46,22 @@ CommandManager::~CommandManager ()
 
 //-----------------------------------------------------------------------------
 // Public
-void CommandManager::SetCommand(const Base *object,unsigned int type,Command *command)
+void CommandManager::SetCommand(const Base *object, unsigned int type, Command *command)
 {
-   Instance.InSetCommand(object,type,command);
+   Instance.InSetCommand(object, type, command);
 }
 
-Command *CommandManager::GetCommand(const Base *object,unsigned int type)
+Command *CommandManager::GetCommand(const Base *object, unsigned int type)
 {
-   return(Instance.InGetCommand(object,type));
+   return(Instance.InGetCommand(object, type));
 }
 
-bool CommandManager::ExecuteCommand(Base *object,unsigned int type,std::string text)
+bool CommandManager::ExecuteCommand(Base *object, unsigned int type, std::string text)
 {
-   return(Instance.InExecuteCommand(object,type,text));
+   return(Instance.InExecuteCommand(object, type, text));
 }
 
-bool CommandManager::ExecuteCommandConst(const Base *object,unsigned int type,std::string text)
+bool CommandManager::ExecuteCommandConst(const Base *object, unsigned int type, std::string text)
 {
    return(Instance.InExecuteCommandConst(object,type,text));
 }
@@ -76,16 +76,16 @@ const CommandManager *CommandManager::GetInstance()
 void CommandManager::InClearCommand(void)
 {
    CommandHT::iterator it;
-   for(it=CommandList.begin();it!=CommandList.end();++it)
+   for(it=CommandList.begin(); it != CommandList.end(); ++it)
    {
       if( it->second )
          it->second->Delete();
    }
 }
 
-void CommandManager::InSetCommand(const Base *object,unsigned int type,Command *command)
+void CommandManager::InSetCommand(const Base *object, unsigned int type, Command *command)
 {
-   CommandKey key = CommandKey(object,type);
+   CommandKey key = CommandKey(object, type);
    Command *cmd = CommandList[key];
    if( cmd != command )
    {
@@ -93,7 +93,7 @@ void CommandManager::InSetCommand(const Base *object,unsigned int type,Command *
          cmd->Unregister();
       if( command )
       {
-         CommandList[key]=command;
+         CommandList[key] = command;
          command->Register();
       }
       else
index c4934ece81fd6d87bbb8f1bc19fa965995be9ec9..bf35f1f32e1e4f8e921aea0c63fb35fc45a6f4c5 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/10/23 15:45:19 $
-  Version:   $Revision: 1.74 $
+  Date:      $Date: 2007/03/23 15:05:11 $
+  Version:   $Revision: 1.75 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -71,7 +71,7 @@ void ElementSet::WriteContent(std::ofstream *fp, FileType filetype)
        if ( (i->second)->GetElement() != 0x0000 
            || 
             (  (i->second)->GetGroup() == 0x0002 
-             ||( filetype == ACR  && (i->second)->GetGroup() == 0x0008 ) )
+             ||( (filetype == ACR || filetype == ACR_LIBIDO ) && (i->second)->GetGroup() == 0x0008 ) )
         )
        {
              i->second->WriteContent(fp, filetype);
index 38282e941cd6878af59f49f9deb65174eb1d6e8a..f14f40e7b23230ee959e283cb6ce00d7a02d272f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/11/15 15:54:15 $
-  Version:   $Revision: 1.327 $
+  Date:      $Date: 2007/03/23 15:05:11 $
+  Version:   $Revision: 1.328 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include <stdlib.h> // for atoi
 
 namespace gdcm
-
 {
 
 //-----------------------------------------------------------------------------
index adffda9c4983bcbaebc3e0c687bcad1f2f975a97..262bf0773de8a1d1130f072ab993992e8242ec8f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmGlobal.h,v $
   Language:  C++
-  Date:      $Date: 2006/03/22 13:19:25 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2007/03/23 15:05:10 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -37,7 +37,7 @@ class Dict;
 class GDCM_EXPORT Global
 {
 friend class DictSet; // to allow setting DefaultPubDict without 
-                      // providing any body an accesor !
+                      // providing anybody an accesor !
 public:
    Global();
    ~Global();