#Txt2Mat
#exDicomRTStructSetFile
#exExtractCSA
+ exPresentationState
exReadPapyrus
exReadWriteFile
Program: gdcm
Module: $RCSfile: PrintFile.cxx,v $
Language: C++
- Date: $Date: 2009/03/04 08:57:40 $
- Version: $Revision: 1.92 $
+ Date: $Date: 2009/05/28 15:44:34 $
+ Version: $Revision: 1.93 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
std::cout << " SwapCode= " << f->GetSwapCode() << std::endl;
std::cout << " ------" << std::endl;
+
std::cout << "\n\n" << std::endl;
std::cout << "X spacing " << f->GetXSpacing() << std::endl;
std::cout << "Y spacing " << f->GetYSpacing() << std::endl;
std::cout << "Z spacing " << f->GetZSpacing() << std::endl;
-
+
//------------------------------
+
+
+
+
// Let's get and print some usefull fields about 'Orientation'
// ------------------------------------------------------------
<< strImagePositionPatientRET << "]" << std::endl;
float iop[6];
- /*bool riop = */f->GetImageOrientationPatient(iop);
+ //bool riop =
+ f->GetImageOrientationPatient(iop);
float ipp[3];
- /*bool ripp = */f->GetImagePositionPatient(ipp);
+ //bool ripp =
+ f->GetImagePositionPatient(ipp);
std::cout << "Image Position (0x0020,0x0032|0x0030) : "
<< ipp[0] << " , " << ipp[1] << " , "<< ipp[2]
Program: gdcm
Module: $RCSfile: SplitIntoDirectories.cxx,v $
Language: C++
- Date: $Date: 2007/10/30 11:37:16 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2009/05/28 15:44:34 $
+ Version: $Revision: 1.5 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include <iostream>
/**
- * \brief
+ * \brief
* - explores recursively the given directory
* - keeps the requested series
* - orders the gdcm-readable found Files
* according to their Patient/Study/Serie/Image characteristics
- */
+ */
typedef std::map<std::string, GDCM_NAME_SPACE::File*> SortedFiles;
-int main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
START_USAGE(usage)
" \n SplitIntoDirectories :\n ",
" - keeps the requested series / drops the unrequested series ",
" - orders the gdcm-readable found Files according to their ",
" (0x0010, 0x0010) Patient's Name ",
- " (0x0020, 0x000d) Study Instance UID ",
+ " (0x0020, 0x000d) Study Instance UID ",
" (0x0020, 0x000e) Series Instance UID ",
" - fills a tree-like structure of directories as : ",
" - Patient ",
std::cout << "... inside " << argv[0] << std::endl;
// ----- Initialize Arguments Manager ------
-
+
GDCM_NAME_SPACE::ArgMgr *am = new GDCM_NAME_SPACE::ArgMgr(argc, argv);
if (argc == 1 || am->ArgMgrDefined("usage"))
return 0;
}
- const char *dirNamein;
- dirNamein = am->ArgMgrGetString("dirin",".");
+ const char *dirNamein;
+ dirNamein = am->ArgMgrGetString("dirin",".");
const char *dirNameout;
- dirNameout = am->ArgMgrGetString("dirout",".");
+ dirNameout = am->ArgMgrGetString("dirout",".");
int loadMode = GDCM_NAME_SPACE::LD_ALL;
if ( am->ArgMgrDefined("noshadowseq") )
loadMode |= GDCM_NAME_SPACE::LD_NOSHADOWSEQ;
- else
+ else
{
if ( am->ArgMgrDefined("noshadow") )
loadMode |= GDCM_NAME_SPACE::LD_NOSHADOW;
bool verbose = ( 0 != am->ArgMgrDefined("verbose") );
bool listonly = ( 0 != am->ArgMgrDefined("listonly") );
bool seriedescr = ( 0 != am->ArgMgrDefined("seriedescr") );
-
+
int nbSeriesToKeep;
int *seriesToKeep = am->ArgMgrGetListOfInt("keep", &nbSeriesToKeep);
int nbSeriesToDrop;
int *seriesToDrop = am->ArgMgrGetListOfInt("drop", &nbSeriesToDrop);
-
+
if ( nbSeriesToKeep!=0 && nbSeriesToDrop!=0)
{
std::cout << "KEEP and DROP are mutually exclusive !" << std::endl;
delete am;
- return 0;
+ return 0;
}
- bool hasSkel = ( 0 != am->ArgMgrDefined("hasSkel") );
+ bool hasSkel = ( 0 != am->ArgMgrDefined("hasSkel") );
const char *skel;
if (hasSkel)
- skel = am->ArgMgrGetString("skel");
-
-
+ skel = am->ArgMgrGetString("skel");
+
+
const char *input = am->ArgMgrGetString("input","DCM");
// if unused Param we give up
if ( am->ArgMgrPrintUnusedLabels() )
- {
+ {
am->ArgMgrUsage(usage);
delete am;
return 0;
}
std::string systemCommand;
-
+
std::cout << "Check for output directory :[" << dirNameout << "]."
<<std::endl;
if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(dirNameout) ) // dirout not found
system (systemCommand.c_str());
if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(dirNameout) ) // be sure it worked
{
- std::cout << "KO : not a dir : [" << dirNameout << "] (creation failure ?)"
+ std::cout << "KO : not a dir : [" << dirNameout << "] (creation failure ?)"
<< std::endl;
- return 0;
-
+ return 0;
}
else
{
if (verbose)
std::cout << "Try[" << *it << "]\n";
f->Load();
- if (!f->IsReadable())
+ if (!f->Document::IsReadable())
{
if (verbose)
std::cout << "File : [" << *it << "] not gdcm-readable -> skipped !" << std::endl;
- continue;
+ continue;
}
if (verbose)
std::cout << "Loaded!\n";
// drop all unrequested Series
bool drop = false;
if (nbSeriesToDrop != 0)
- {
+ {
strSeriesNumber = f->GetEntryString(0x0020, 0x0011 );
seriesNumber = atoi( strSeriesNumber.c_str() );
for (j=0;j<nbSeriesToDrop; j++)
{
if(seriesNumber == seriesToDrop[j])
- {
+ {
drop = true;
break;
}
GDCM_NAME_SPACE::Util::Tokenize (userFileIdentifier, tokens, token);
char newName[1024];
-
+
///this is a trick to build up a lexicographical compliant name :
/// eg : fich001.ima vs fich100.ima as opposed to fich1.ima vs fich100.ima
std::string name = GDCM_NAME_SPACE::Util::GetName( *it );
-
+
std::cout << "name :[" << name << "]\n";
-
+
if (hasSkel)
{
int imageNum; // Within FileName
{
tokens[IND_FileName] = name;
}
-
+
// Patient's Name
- // Study Instance UID
+ // Study Instance UID
// Series Instance UID
// SerieDescription
// Serie Number
// file Name
-
+
userFileIdentifier = tokens[IND_PatientName] + token +
tokens[IND_StudyInstanceUID] + token +
tokens[IND_SerieInstanceUID] + token +
tokens[IND_SerieDescription] + token +
tokens[IND_SerieNumber] + token +
tokens[IND_FileName];
-
+
if (verbose)
std::cout << "[" << userFileIdentifier << "] : " << *it << std::endl;
-
- // storing in a map ensures automatic sorting !
+
+ // storing in a map ensures automatic sorting !
sf[userFileIdentifier] = f;
}
previousPatientName = currentPatientName;
previousStudyInstanceUID = "";
previousSerieInstanceUID = "";
-
+
currentPatientWriteDir = writeDir + currentPatientName;
systemCommand = "mkdir " + currentPatientWriteDir;
if (verbose || listonly)
std::cout << "[" << systemCommand << "]" << std::endl;
- if (!listonly)
+ if (!listonly)
system ( systemCommand.c_str() );
}
-
+
if (previousStudyInstanceUID != currentStudyInstanceUID)
- {
+ {
previousStudyInstanceUID = currentStudyInstanceUID;
- if (verbose)
+ if (verbose)
std::cout << "==== === new Study [" << currentStudyInstanceUID << "]"
- << std::endl;
+ << std::endl;
currentStudyWriteDir = currentPatientWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR
+ currentStudyInstanceUID;
if (seriedescr) // more human readable!
currentSerieWriteDir = currentStudyWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR
- + currentSerieDescription + "_" + currentSerieNumber;
+ + currentSerieDescription + "_" + currentSerieNumber
+ + "_" + currentSerieInstanceUID;
else
currentSerieWriteDir = currentStudyWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR
+ currentSerieInstanceUID;
-
+
systemCommand = "mkdir " + currentSerieWriteDir;
if (listonly)
Program: gdcm
Module: $RCSfile: SplitIntoXCoherentDirectories.cxx,v $
Language: C++
- Date: $Date: 2007/10/24 08:03:10 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2009/05/28 15:44:34 $
+ 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
START_USAGE(usage)
"\n exXCoherentFileSet :\n ",
"Shows the various 'XCoherent' Filesets within a directory ",
- "Optionaly copis the images in a Directories tree ",
+ "Optionaly copies the images in a Directories tree ",
"usage: exXCoherentFileSet {dirin=inputDirectoryName} ",
" dirout=outputDirectoryName ",
" { tag=group-elem | pos | ori } [sort] ",
int loadMode;
int maxSize;
-
+
const char *dirName = am->ArgMgrGetString("dirin");
if (dirName == 0)
{
bool write = ( 0 != am->ArgMgrDefined("write") );
bool verbose = ( 0 != am->ArgMgrDefined("verbose") );
bool tag = ( 0 != am->ArgMgrDefined("tag") );
-
+
if( copy && write )
{
std::cout << "COPY and WRITE are mutually exclusive" << std::endl;
delete am;
- return 0;
- }
+ return 0;
+ }
if( (tag && (pos || ori)) || (pos && (tag || ori)) || (ori && (tag || pos)) )
{
delete am; // ------ we don't need Arguments Manager any longer ------
-
+
GDCM_NAME_SPACE::SerieHelper *s;
s = GDCM_NAME_SPACE::SerieHelper::New();
-
+
+ s->SetLoadMode(GDCM_NAME_SPACE::LD_ALL); // Load everything for each File
+ s->SetDirectory(dirName, true); // true : recursive exploration
+
GDCM_NAME_SPACE::File *f;
GDCM_NAME_SPACE::DirList dirlist(dirName, true); // recursive exploration
if (write) {
loadMode = GDCM_NAME_SPACE::LD_ALL; // load any DataElement
- maxSize = 0x7fff; // load any length
+ maxSize = 0x7fff; // load any length
} else {
loadMode = GDCM_NAME_SPACE::LD_NOSEQ | GDCM_NAME_SPACE::LD_NOSHADOW ;
maxSize = 0x0100;
// For all the Single SerieUID Files Sets of the GDCM_NAME_SPACE::Serie
- //GDCM_NAME_SPACE::FileList *l = s->GetFirstSingleSerieUIDFileSet();//===> Ignore 'Serie UID"
+ // GDCM_NAME_SPACE::FileList *l = s->GetFirstSingleSerieUIDFileSet();
+
+ l = s->GetFirstSingleSerieUIDFileSet();
+ if (l == NULL) {
+ std::cout << "No Serie found ?!?" << std::endl;
+ exit (0);
+ }
GDCM_NAME_SPACE::XCoherentFileSetmap xcm;
std::string lastFilename;
std::string rep("_");
int controlCount = 0;
-
+
// 'Study Instance UID'
// The user is allowed to create his own Study,
// keeping the same 'Study Instance UID' for various images
strStudyUID = studyUID;
}
-// while (l) // for each 'Single SerieUID FileSet' //===> Ignore 'Serie UID"
-// {
+ while (l) // for each 'Single SerieUID FileSet' //===> Ignore 'Serie UID"
+ {
+ currentSerieWriteDir = "";
nbFiles = l->size() ;
if ( l->size() > 2 ) // ignore a Directory with less than 2 images.
// Why not ? Just an example, for testing!
{
// Just not to make too many modif in the code
- serieUID = "SingleSerie"; //s->GetCurrentSerieUIDFileSetUID();
+ //serieUID = "SingleSerie"; // s->GetCurrentSerieUIDFileSetUID();
+ serieUID = s->GetCurrentSerieUIDFileSetUID();
+
GDCM_NAME_SPACE::Util::ReplaceSpecChar(serieUID, rep);
-
+
// --- for write
if (write || copy)
{
<< serieUID
<< "] " << nbFiles << " long" << std::endl;
std::cout << "-----------------------------------" << std::endl;
-
-GDCM_NAME_SPACE::Debug::DebugOn();
-
if (ori)
xcm = s->SplitOnOrientation(l);
else if (pos)
xcm = s->SplitOnPosition(l);
else if (groupelem != 0) {
-
- std:: cout << GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(groupelem[0],groupelem[1])->GetName() << std::endl;
+ // Crashes if DataElement not found
+ //std:: cout << GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(groupelem[0],groupelem[1])->GetName() << std::endl;
xcm = s->SplitOnTagValue(l, groupelem[0],groupelem[1] );
}
{
xCoherentName = (*i).first;
if (verbose)
- std::cout << "xCoherentName = " << xCoherentName << std::endl;
+ std::cout << "==========================================xCoherentName = " << xCoherentName << std::endl;
GDCM_NAME_SPACE::Util::ReplaceSpecChar(xCoherentName, rep);
// --- for write
if (write || copy)
// (eg:MIP views) don't have 'Position', now considered as mandatory
// --> Activated on user demand.
- if (sort) {
+ if (sort) {
s->OrderFileList((*i).second); // sort the XCoherent Fileset
std::cout << "ZSpacing for the file set " << s->GetZSpacing()
<< std::endl;
- }
+ }
std::string strSerieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
{
controlCount ++;
fileName = (*it2)->GetFileName();
- std::cout << " " << fileName << std::endl;
-
// --- for write
lastFilename = GDCM_NAME_SPACE::Util::GetName( fileName );
- filenameout = xCoherentWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename;
+ filenameout = xCoherentWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename;
if (write)
{
fh = GDCM_NAME_SPACE::FileHelper::New( (*it2) );
unsigned int dataSize = fh->GetImageDataRawSize();
uint8_t *imageData = fh->GetImageDataRaw();// somewhat important : Loads the Pixels in memory !
if (!imageData)
- std::cout << "fail to read [" << (*it2)->GetFileName() << std::endl;
+ std::cout << "fail to read [" << (*it2)->GetFileName() << std::endl;
fh->SetWriteTypeToDcmExplVR();
fh->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE);
if (!fh->Write(filenameout))
if (verbose)
std::cout << "3 " << systemCommand << std::endl;
}
- std::cout << std::endl;
}
+ std::cout << std::endl;
}
- // l = s->GetNextSingleSerieUIDFileSet(); //===> Ignore 'Serie UID"
+ l = s->GetNextSingleSerieUIDFileSet();
+ }
if ( controlCount == 0 )
std::cout << "No suitable file was found!" << std::endl;
Program: gdcm
Module: $RCSfile: SplitIntoXCoherentDirectoriesIgnoreSerieUID.cxx,v $
Language: C++
- Date: $Date: 2007/10/01 09:56:42 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2009/05/28 15:44:34 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
"usage: SplitIntoCoherentFileSetIgnoreSerieUID{dirin=inputDirectoryName} ",
" dirout=outputDirectoryName ",
" { tag=group-elem | pos | ori } [sort] ",
- " [{ write | copy }] ",
+ " [{ write | copy }] ",
" [ { [noshadowseq] | [noshadow][noseq] } ] [debug] ",
" [studyUID = ] ",
" dirin : user wants to analyze *all* the files ",
bool pos = ( 0 != am->ArgMgrDefined("pos") );
bool ori = ( 0 != am->ArgMgrDefined("ori") );
bool sort = ( 0 != am->ArgMgrDefined("sort") );
+ bool copy = ( 0 != am->ArgMgrDefined("copy") );
bool write = ( 0 != am->ArgMgrDefined("write") );
bool verbose = ( 0 != am->ArgMgrDefined("verbose") );
bool tag = ( 0 != am->ArgMgrDefined("tag") );
+ if( copy && write )
+ {
+ std::cout << "COPY and WRITE are mutually exclusive" << std::endl;
+ delete am;
+ return 0;
+ }
+
if( (tag && (pos || ori)) || (pos && (tag || ori)) || (ori && (tag || pos)) )
{
std::cout << " POS, ORI and TAG are mutually exclusive" << std::endl;
delete am; // ------ we don't need Arguments Manager any longer ------
-
GDCM_NAME_SPACE::SerieHelper *s;
s = GDCM_NAME_SPACE::SerieHelper::New();
f->SetMaxSizeLoadEntry(0x7fff); // load any length
f->SetFileName( *it );
f->Load();
- l->push_back(f);
+ l->push_back(f);
}
/* ===========================================================================================*/
std::string systemCommand;
- std::string filenameout;
- if (write) {
+ std::string filenameout;
+ if (write) {
if (verbose)
std::cout << "Check for output directory :[" << dirNameout << "]."
<<std::endl;
else
{
if (verbose)
- std::cout << "Output Directory [" << dirNameout
+ std::cout << "Output Directory [" << dirNameout
<< "] already exists; Used as is."
<< std::endl;
- }
+ }
}
-
// --> End of checking supposed-to-be-directory names
int nbFiles;
// For all the Single SerieUID Files Sets of the GDCM_NAME_SPACE::Serie
- //GDCM_NAME_SPACE::FileList *l = s->GetFirstSingleSerieUIDFileSet();//===> Ignore 'Serie UID"
+ // GDCM_NAME_SPACE::FileList *l = s->GetFirstSingleSerieUIDFileSet();//===> Ignore 'Serie UID"
GDCM_NAME_SPACE::XCoherentFileSetmap xcm;
std::string serieUID;
std::string currentSerieWriteDir = "";
std::string xCoherentWriteDir = "";
- std::string xCoherentName = "";
+ std::string xCoherentName = "";
std::string serieDirectory;
std::string lastFilename;
std::string rep("_");
int controlCount = 0;
-
+
// 'Study Instance UID'
// The user is allowed to create his own Study,
// keeping the same 'Study Instance UID' for various images
// The user may add images to a 'Manufacturer Study',
// adding new Series to an already existing Study
std::string strStudyUID;
- if ( !userDefinedStudy)
+ if ( !userDefinedStudy )
strStudyUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
else
strStudyUID = studyUID;
// Why not ? Just an example, for testing!
{
// Just not to make too many modif in the code
- serieUID = "aaaa"; //s->GetCurrentSerieUIDFileSetUID();
+ //serieUID = "SingleSerie"; // s->GetCurrentSerieUIDFileSetUID();
+ serieUID = s->GetCurrentSerieUIDFileSetUID();
GDCM_NAME_SPACE::Util::ReplaceSpecChar(serieUID, rep);
-
+
// --- for write
if (write)
{
else if (pos)
xcm = s->SplitOnPosition(l);
else if (groupelem != 0) {
-
+
std:: cout << GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(groupelem[0],groupelem[1])->GetName() << std::endl;
xcm = s->SplitOnTagValue(l, groupelem[0],groupelem[1] );
}
-
+
GDCM_NAME_SPACE::FileHelper *fh;
-
+
for (GDCM_NAME_SPACE::XCoherentFileSetmap::iterator i = xcm.begin();
i != xcm.end();
++i)
{
- xCoherentName = (*i).first;
+ xCoherentName = (*i).first;
if (verbose)
std::cout << "xCoherentName = " << xCoherentName << std::endl;
GDCM_NAME_SPACE::Util::ReplaceSpecChar(xCoherentName, rep);
// OrderFileList() causes trouble, since some files
// (eg:MIP views) don't have 'Position', now considered as mandatory
// --> Activated on user demand.
-
+
if (sort) {
s->OrderFileList((*i).second); // sort the XCoherent Fileset
std::cout << "ZSpacing for the file set " << s->GetZSpacing()
}
std::string strSerieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
-
+
for (GDCM_NAME_SPACE::FileList::iterator it2 = ((*i).second)->begin();
it2 != ((*i).second)->end();
++it2)
// --- for write
if (write)
{
- fh = GDCM_NAME_SPACE::FileHelper::New( (*it2) );
+ fh = GDCM_NAME_SPACE::FileHelper::New( (*it2) );
fh->SetKeepOverlays( true );
fh->InsertEntryString(strSerieUID,0x0020,0x000e,"UI");
unsigned int dataSize = fh->GetImageDataRawSize();
uint8_t *imageData = fh->GetImageDataRaw();// somewhat important : Loads the Pixels in memory !
if (!imageData)
- std::cout << "fail to read [" << (*it2)->GetFileName() << std::endl;
+ std::cout << "fail to read [" << (*it2)->GetFileName() << std::endl;
lastFilename = GDCM_NAME_SPACE::Util::GetName( fileName );
filenameout = xCoherentWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename;
//systemCommand = "cp " + fileName + " " + filenameout;
//system( systemCommand.c_str());
-
+
fh->SetWriteTypeToDcmExplVR();
fh->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE);
if (!fh->Write(filenameout))
{
std::cout << "Fail to write :[" << filenameout << "]"
<< std::endl;
- }
+ }
if (verbose)
std::cout << "3 " << systemCommand << std::endl;
fh->Delete();
- }
- // --- end for write
+ }
+ // --- end for write
}
- std::cout << std::endl;
+ std::cout << std::endl;
}
}
// l = s->GetNextSingleSerieUIDFileSet(); //===> Ignore 'Serie UID"
if ( controlCount == 0 )
std::cout << "No suitable file was found!" << std::endl;
-
+
s->Delete();
/*===============================================================================================*/
return 0;
Program: gdcm
Module: $RCSfile: exExtractOverlaysDCM.cxx,v $
Language: C++
- Date: $Date: 2007/10/30 09:15:58 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2009/05/28 15:44:34 $
+ Version: $Revision: 1.6 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
} // end on loop on 60xx
- if (f)
+ if (fh)
fh->Delete();
if (fileToBuild)
fileToBuild->Delete();
Program: gdcm
Module: $RCSfile: exPresentationState.cxx,v $
Language: C++
- Date: $Date: 2009/05/25 14:29:16 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2009/05/28 15:44:34 $
+ 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
" noseq : user doesn't want to load Sequences ",
" verbose : developper wants to run the program in 'verbose mode' ",
" debug : developper wants to run the program in 'debug mode' ",
+ " ",
+ " you can use it as : ",
+ " for i in `ls PS*`; do exPresentationState PSFile=$i; done ",
+ " just to see ... ",
FINISH_USAGE
// ----- Initialize Arguments Manager ------
//displaySeekResult(se, 0x0070, 0x0001);
if (!se)
{
- std::cout << "Hopeless : " << std::hex << 0x0070 << "|" << 0x0001 << std::dec << " doesn't exist..." <<std::endl;
+ std::cout << "[" << PSName << "] : Hopeless (" << std::hex << 0x0070 << "|" << 0x0001 << std::dec << " doesn't exist...)" <<std::endl;
exit (0);
}
-
+ std::cout << "\n\n =========================================================================================" <<std::endl;
std::cout << "[" << PSName << "] is a gdcm-readable PresentationState file, "
- << "that (probabely?) holds one or more 'ROI' within [0070|0001] (Graphic Annotation Sequence)\n" <<std::endl;
+ << "that (probabely?) holds one or more 'ROI' within [0070|0001] (Graphic Annotation Sequence)" <<std::endl;
+ std::cout << " =========================================================================================\n\n" <<std::endl;
GDCM_NAME_SPACE::SQItem* currentItem = se->GetFirstSQItem(); // Get the first 'ROI'
+ if (currentItem == NULL)
+ {
+ std::cout << "======== Deal With NOTHING! (Sequence 0070|0001 [Graphic Annotation Sequence] has NO item ?!?)" << std::endl;
+ }
int i =0;
while (currentItem != NULL)
{
f->Delete();
fPS->Delete();
+
+ std::cout << "\n\n" <<std::endl;
return 0;
}
for(int i=0; tabElement[i]!=0x0000; i++)
{
se = CheckIfSequenceExists(currentItem, 0x0070, tabElement[i]);
- displaySeekResult(se, 0x0070, tabElement[i]);
+ //displaySeekResult(se, 0x0070, tabElement[i]);
if (se != 0)
{
res = true;
Program: gdcm
Module: $RCSfile: exSerieHelper.cxx,v $
Language: C++
- Date: $Date: 2007/10/30 14:55:20 $
- Version: $Revision: 1.17 $
+ Date: $Date: 2009/05/28 15:44:34 $
+ Version: $Revision: 1.18 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
++it2)
{
// Just to show : GetZSpacing from a GDCM_NAME_SPACE::File may be different
- std::cout << (*it2)->GetFileName() << " --> GetZSpacing() from GDCM_NAME_SPACE::File : "
+ std::cout << (*it2)->GetFileName() << " --> Get{X/Y/Z}Spacing() from GDCM_NAME_SPACE::File : "
+ << (*it2)->GetXSpacing() << " "
+ << (*it2)->GetYSpacing() << " "
<< (*it2)->GetZSpacing() << std::endl;
fileCount++;
}
/*=========================================================================
-
+
Program: gdcm
Module: $RCSfile: exXCoherentFileSet.cxx,v $
Language: C++
- Date: $Date: 2007/10/30 14:55:20 $
- Version: $Revision: 1.15 $
+ Date: $Date: 2009/05/28 15:44:34 $
+ Version: $Revision: 1.16 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
-
+
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.
#include "gdcmArgMgr.h"
int main(int argc, char *argv[])
{
-
START_USAGE(usage)
"\n exXCoherentFileSet :\n ",
"Shows the various 'XCoherent' Filesets within a directory ",
FINISH_USAGE
// ----- Initialize Arguments Manager ------
-
+
GDCM_NAME_SPACE::ArgMgr *am = new GDCM_NAME_SPACE::ArgMgr(argc, argv);
if (am->ArgMgrDefined("usage") || argc == 1)
if (am->ArgMgrDefined("debug"))
GDCM_NAME_SPACE::Debug::DebugOn();
-
+
int loadMode = GDCM_NAME_SPACE::LD_ALL;
if ( am->ArgMgrDefined("noshadowseq") )
loadMode |= GDCM_NAME_SPACE::LD_NOSHADOWSEQ;
std::cout <<std::endl
<< "'dirin=' must be present;"
<< std::endl;
- am->ArgMgrUsage(usage); // Display 'usage'
+ am->ArgMgrUsage(usage); // Display 'usage'
delete am;
return 0;
}
- const char *dirNameout;
+ const char *dirNameout;
dirNameout = am->ArgMgrGetString("dirout",".");
- bool pos = ( 0 != am->ArgMgrDefined("pos") );
- bool ori = ( 0 != am->ArgMgrDefined("ori") );
+ bool pos = ( 0 != am->ArgMgrDefined("pos") );
+ bool ori = ( 0 != am->ArgMgrDefined("ori") );
bool sort = ( 0 != am->ArgMgrDefined("sort") );
bool write = ( 0 != am->ArgMgrDefined("write") );
bool verbose = ( 0 != am->ArgMgrDefined("verbose") );
{
std::cout << " POS, ORI and TAG are mutually exclusive" << std::endl;
delete am;
- return 0;
+ return 0;
}
if( (!tag && !pos && !ori))
{
std::cout << " One of POS, ORI and TAG is mandatory!" << std::endl;
delete am;
- return 0;
- }
+ return 0;
+ }
int nb;
uint16_t *groupelem;
if (tag)
delete am;
return 0;
}
- }
-
+ }
+
/* if unused Param we give up */
if ( am->ArgMgrPrintUnusedLabels() )
{
am->ArgMgrUsage(usage);
delete am;
return 0;
- }
-
+ }
+
delete am; // ------ we don't need Arguments Manager any longer ------
GDCM_NAME_SPACE::SerieHelper *s;
//GDCM_NAME_SPACE::TagKey t(0x0020,0x0013);
//s->AddRestriction(t, "340", GDCM_NAME_SPACE::GDCM_LESS); // Keep only files where
// restriction is true
-
+
s->SetDirectory(dirName, true); // true : recursive exploration
// The Dicom file set is splitted into several 'Single SerieUID Files Sets'
std::string lastFilename;
std::string rep("_");
int controlCount = 0;
-
+
while (l) // for each 'Single SerieUID FileSet'
{
nbFiles = l->size() ;
{
serieUID = s->GetCurrentSerieUIDFileSetUID();
GDCM_NAME_SPACE::Util::ReplaceSpecChar(serieUID, rep);
-
+
// --- for write
if (write)
{
unsigned int lg = strlen(dirNameout)-1;
if ( dirNameout[lg] != '/' && dirNameout[lg] != '\\')
currentSerieWriteDir = currentSerieWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR;
-
+
currentSerieWriteDir = currentSerieWriteDir + serieUID;
if (verbose)
std::cout << "[" << currentSerieWriteDir<< "]" << std::endl;
// if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(currentSerieWriteDir) )
- {
+ {
systemCommand = "mkdir " + currentSerieWriteDir;
system( systemCommand.c_str());
if (verbose)
std::cout << "1 " <<systemCommand << std::endl;
- }
+ }
}
// --- end for write
-
+
std::cout << "Split the 'Single SerieUID' FileSet :["
<< serieUID
<< "] " << nbFiles << " long" << std::endl;
std::cout << "-----------------------------------" << std::endl;
-
+
if (ori)
xcm = s->SplitOnOrientation(l);
else if (pos)
GDCM_NAME_SPACE::Util::ReplaceSpecChar(serieUID, rep);
// --- for write
if (write)
- {
+ {
xCoherentWriteDir = currentSerieWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ xCoherentName;
// if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(xCoherentWriteDir) )
- {
+ {
systemCommand = "mkdir " + xCoherentWriteDir;
system( systemCommand.c_str());
if (verbose)
- std::cout << systemCommand << std::endl;
+ std::cout << systemCommand << std::endl;
}
}
// --- end for write
-
+
if (ori)
std::cout << "Orientation : ";
else if (pos)
std::cout << "Tag (" << std::hex << groupelem[0]
<< "|" << groupelem[1] << ") value : ";
std::cout << "[" << (*i).first << "]" << std::endl;
-
+
if (verbose)
std::cout << "xCoherentName [" << xCoherentName << "]" << std::endl;
-
+
// Within a 'just to see' program,
// OrderFileList() causes trouble, since some files
// (eg:MIP views) don't have 'Position', now considered as mandatory
s->OrderFileList((*i).second); // sort the XCoherent Fileset
std::cout << "ZSpacing for the file set " << s->GetZSpacing()
<< std::endl;
- }
+ }
for (GDCM_NAME_SPACE::FileList::iterator it = ((*i).second)->begin();
it != ((*i).second)->end();
controlCount ++;
fileName = (*it)->GetFileName();
std::cout << " " << fileName << std::endl;
-
+
// --- for write
if (write)
{
if (verbose)
std::cout << "3 " << systemCommand << std::endl;
}
- // --- end for write
+ // --- end for write
}
- std::cout << std::endl;
+ std::cout << std::endl;
}
}
l = s->GetNextSingleSerieUIDFileSet();