Program: gdcm
Module: $RCSfile: SplitIntoDirectories.cxx,v $
Language: C++
- Date: $Date: 2011/04/20 11:14:48 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2011/04/22 13:50:09 $
+ 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
// or the field may be empty!
s->AddSeriesDetail(0x0020, 0x000d, false); // Study Instance UID (false : no convert)
-
// You may prefer 0020 0011 Series Number
// use :
// s->AddSeriesDetail(0x0020, 0x0011, true);
s->AddSeriesDetail(0x0008, 0x103e, false); // Serie Description
s->AddSeriesDetail(0x0020, 0x0011, false); // Serie Number (more than 1 serie may have the same Ser.Nbr don't 'convert!)
-
// Feel free to add more fields, if they can help a suitable (for you)
// image sorting
///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 (verbose)
+ std::cout << "name :[" << name << "]\n";
if (hasSkel)
{
tokens[IND_SerieDescription] + token +
tokens[IND_SerieNumber] + token +
tokens[IND_FileName];
-
if (verbose)
std::cout << "[" << userFileIdentifier << "] : " << *it << std::endl;
previousSerieInstanceUID = "";
GDCM_NAME_SPACE::File *currentFile;
-
+ std::string replaceChar("_");
for (it2 = sf.begin() ; it2 != sf.end(); ++it2)
{
currentFile = it2->second;
GDCM_NAME_SPACE::Util::Tokenize (it2->first, tokens, token);
currentPatientName = tokens[IND_PatientName];
- currentStudyInstanceUID = tokens[IND_StudyInstanceUID];
+ currentStudyInstanceUID = tokens[IND_StudyInstanceUID];
currentSerieInstanceUID = tokens[IND_SerieInstanceUID];
currentSerieDescription = tokens[IND_SerieDescription];
currentSerieNumber = tokens[IND_SerieNumber];
-
+
if (previousPatientName != currentPatientName)
{
previousPatientName = currentPatientName;
if (verbose)
std::cout << "==== new Patient [" << currentPatientName << "]" << std::endl;
-
+
previousPatientName = currentPatientName;
previousStudyInstanceUID = "";
previousSerieInstanceUID = "";
currentStudyWriteDir = currentPatientWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR
+ currentStudyInstanceUID;
systemCommand = "mkdir \"" + currentStudyWriteDir + "\"";
-
+
+ if (verbose)
+ std::cout << "Directory [" << currentStudyWriteDir << "] created" << std::endl;
+
if (listonly)
- std::cout << "[" << systemCommand << "]" << std::endl;
+ std::cout << "[" << systemCommand << "]" << std::endl;
else
system (systemCommand.c_str());
-
}
-
+
if (previousSerieInstanceUID != currentSerieInstanceUID)
{
previousSerieInstanceUID = currentSerieInstanceUID;
if (seriedescr) // more human readable!
currentSerieWriteDir = currentStudyWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR
+ currentSerieDescription + "_" + currentSerieNumber
- + "_" + currentSerieInstanceUID;
+ /*+ "_" + currentSerieInstanceUID */
+ ;
+
else
currentSerieWriteDir = currentStudyWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR
+ currentSerieInstanceUID;
-
+
systemCommand = "mkdir \"" + currentSerieWriteDir + "\"";
if (listonly)
std::cout << "[" << systemCommand << "]" << std::endl;
else
system (systemCommand.c_str());
+
+ if (verbose)
+ std::cout << "Directory [" << currentSerieWriteDir << "] created" << std::endl;
}
if ( GDCM_NAME_SPACE::Debug::GetDebugFlag())
<< GDCM_NAME_SPACE::Util::GetName( fullFilename ) << std::endl;
// If you want to create file names of your own, here is the place!
- // Just replace 'lastFilename' by anything that's better for you.
+ // Just replace 'lastFilename' by anything that's better for you.
+ GDCM_NAME_SPACE:: Util::ReplaceSpecChar(lastFilename, replaceChar);
+
fullWriteFilename = currentSerieWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR
+ lastFilename;
- systemCommand = "cp \"" + fullFilename + "\"" + " \"" + fullWriteFilename + " \"";
+ systemCommand = "cp \"" + fullFilename + "\" \"" + fullWriteFilename + "\"";
if (listonly)
std::cout << "[" << systemCommand << "]" << std::endl;
}
return 0;
}
-