From 8cc5832cf333a9bfd128824d5864399d4a4313b7 Mon Sep 17 00:00:00 2001 From: jpr Date: Fri, 23 Mar 2007 15:01:47 +0000 Subject: [PATCH] Typo --- Example/RawToDicom.cxx | 28 ++++---- Example/ReWriteExtended.cxx | 139 +++++++++++++++++++++++++++++------- Example/ToMRIregister.cxx | 52 ++++++++++++-- src/gdcmCommandManager.cxx | 26 +++---- src/gdcmElementSet.cxx | 6 +- src/gdcmFile.cxx | 5 +- src/gdcmGlobal.h | 6 +- 7 files changed, 194 insertions(+), 68 deletions(-) diff --git a/Example/RawToDicom.cxx b/Example/RawToDicom.cxx index fa15cff3..e9fa0f66 100755 --- a/Example/RawToDicom.cxx +++ b/Example/RawToDicom.cxx @@ -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; + } } } diff --git a/Example/ReWriteExtended.cxx b/Example/ReWriteExtended.cxx index 8681e447..6cf00218 100755 --- a/Example/ReWriteExtended.cxx +++ b/Example/ReWriteExtended.cxx @@ -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 <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] <=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); diff --git a/Example/ToMRIregister.cxx b/Example/ToMRIregister.cxx index a49a5ed9..536208b9 100755 --- a/Example/ToMRIregister.cxx +++ b/Example/ToMRIregister.cxx @@ -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 #include @@ -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 < " << fullWriteFilename << std::endl; + } // Write it, now + fh->SetWriteTypeToAcrLibido(); + if (!fh->Write(fullWriteFilename)) { std::cout << "Fail to write :[" << fullWriteFilename << "]" diff --git a/src/gdcmCommandManager.cxx b/src/gdcmCommandManager.cxx index bcd74717..bb24b005 100644 --- a/src/gdcmCommandManager.cxx +++ b/src/gdcmCommandManager.cxx @@ -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 diff --git a/src/gdcmElementSet.cxx b/src/gdcmElementSet.cxx index c4934ece..bf35f1f3 100644 --- a/src/gdcmElementSet.cxx +++ b/src/gdcmElementSet.cxx @@ -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); diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 38282e94..f14f40e7 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -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 @@ -102,7 +102,6 @@ #include // for atoi namespace gdcm - { //----------------------------------------------------------------------------- diff --git a/src/gdcmGlobal.h b/src/gdcmGlobal.h index adffda9c..262bf077 100644 --- a/src/gdcmGlobal.h +++ b/src/gdcmGlobal.h @@ -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(); -- 2.48.1