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
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.
-
+
=========================================================================*/
/**
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 )
{
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;
+ }
}
}
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
" 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 ------
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() )
{
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();
<< 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);
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
#include "gdcmDebug.h"
#include "gdcmDirList.h"
#include "gdcmUtil.h"
+#include "gdcmDataEntry.h"
#include "gdcmArgMgr.h"
#include <iostream>
#include <sstream>
// For all the Single SerieUID Files Sets of the gdcm::Serie
gdcm::FileList *l = s->GetFirstSingleSerieUIDFileSet();
+
+ char numero[5];
while (l)
{
nbFiles = l->size() ;
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)
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();
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 !)
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
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 << "]"
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
//-----------------------------------------------------------------------------
// 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));
}
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 )
{
cmd->Unregister();
if( command )
{
- CommandList[key]=command;
+ CommandList[key] = command;
command->Register();
}
else
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
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);
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
-
{
//-----------------------------------------------------------------------------
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
class GDCM_EXPORT Global
{
friend class DictSet; // to allow setting DefaultPubDict without
- // providing any body an accesor !
+ // providing anybody an accesor !
public:
Global();
~Global();