Program: gdcm
Module: $RCSfile: Dense2007ToDicom.cxx,v $
Language: C++
- Date: $Date: 2007/10/15 13:55:35 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2007/10/24 08:03:10 $
+ 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
std::cout << "Max X,Y,Z " << maxX << " " << maxY << " " << maxZ << std::endl;
std::cout << "Size X,Y,Z " << maxX-minX << " " << maxY-minY << " " << maxZ-minZ << std::endl;
- uint16_t *img = new uint16_t[int(maxX)*int(maxY)];
+// uint16_t *img = new uint16_t[int(maxX+0.5)*int(maxY+0.5)];
+ uint16_t *img = new uint16_t[int(maxX*4.)*int(maxY*4.)];
// Set whole image to 0
- for(int i3=0;i3<int(maxX)*int(maxY);i3++)
+ for(int i3=0;i3<int(maxX*4.)*int(maxY*4.);i3++)
+// for(int i3=0;i3<int(maxX+0.5)*int(maxY+0.5);i3++)
img[i3] = 0;
-
+
for(int i2=0; i2<NP; i2++) {
- img[ int(maxX) -int(X[i2]-1) + (int(maxY) -int(Y[i2]))* int(maxX) ] = int(tabVal[i2]*100);
+
+ int ordX = int(X[i2]*4.-30);
+ int ordY = int(maxY*4.) - int(Y[i2]*4.)+30;
+// img[ /*int(maxX) -*/ int(X[i2]+0.5-1) + (int(maxY+0.5) - int(Y[i2]+0.5)) * int(maxX+0.5) ] = int(tabVal[i2]*100);
+
+// img[ /*int(maxX) -*/ int(X[i2]*4.-30) + (int(maxY*4.) - int(Y[i2]*4.)+30) * int(maxX*4.) ] = int(tabVal[i2]*100);
+ img[ /*int(maxX) -*/ ordX + ordY * int(maxX*4.) ] = int(tabVal[i2]*100);
+
+ // Try to round up, just to see.
+ for(int iii=ordY-3; iii<ordY+4; iii++) for(int jjj=ordX-3; jjj<ordX+4; jjj++)
+ img[ jjj + iii * int(maxX*4.) ] = int(tabVal[i2]*100);
+ std::cout << int(X[i2]*4.) << " " << int(Y[i2]*4.) << " = " << int(tabVal[i2]*100) << std::endl;
}
// GDCM_NAME_SPACE::Debug::DebugOn();
// Set the image size
str.str("");
- str << (int)(maxX);
+ str << (int)(maxX*4.);
file->InsertEntryString(str.str(),0x0028,0x0011,"US"); // Columns
str.str("");
- str << (int)(maxY);
+ str << (int)(maxY*4.);
file->InsertEntryString(str.str(),0x0028,0x0010,"US"); // Rows
// Set the pixel type
fileH = GDCM_NAME_SPACE::FileHelper::New(file);
// cast is just to avoid warnings (*no* conversion)
//fileH->SetImageData((uint8_t *)img,int(maxX*maxY)*sizeof(uint16_t)); // troubles when maxX, mayY are *actually* float!
- fileH->SetImageData((uint8_t *)img,int(maxX)*int(maxY)*sizeof(uint16_t));
+ fileH->SetImageData((uint8_t *)img,int(maxX*4.)*int(maxY*4.)*sizeof(uint16_t));
fileH->SetWriteModeToRaw();
fileH->SetWriteTypeToDcmExplVR();
Program: gdcm
Module: $RCSfile: SplitIntoXCoherentDirectories.cxx,v $
Language: C++
- Date: $Date: 2007/10/19 11:53:42 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2007/10/24 08:03:10 $
+ 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
"usage: exXCoherentFileSet {dirin=inputDirectoryName} ",
" dirout=outputDirectoryName ",
" { tag=group-elem | pos | ori } [sort] ",
- " [{ write | copy }] [studyUID = ] ",
+ " [{ write | copy }] [studyUID = ] ",
" [ { [noshadowseq] | [noshadow][noseq] } ] [debug] ",
" ",
" dirin : user wants to analyze *all* the files ",
" within the directory ",
" copy : user wants to copy the files into a directories tree ",
" write : user wants to rewrite the files into a directories tree ",
- " each directory with the same 'Series Instance UID' ",
+ " each directory with the same 'Series Instance UID' ",
" dirout : will be created if doesn't exist ",
" pos : user wants to split each Single SerieUID Fileset on the ",
" 'Image Position ' ",
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 write = ( 0 != am->ArgMgrDefined("write") );
bool verbose = ( 0 != am->ArgMgrDefined("verbose") );
bool tag = ( 0 != am->ArgMgrDefined("tag") );
delete am; // ------ we don't need Arguments Manager any longer ------
-
-
+
GDCM_NAME_SPACE::SerieHelper *s;
s = GDCM_NAME_SPACE::SerieHelper::New();
{
if (verbose)
std::cout << *it << std::endl;
-
+
if (write) {
loadMode = GDCM_NAME_SPACE::LD_ALL; // load any DataElement
maxSize = 0x7fff; // load any length
} else {
loadMode = GDCM_NAME_SPACE::LD_NOSEQ | GDCM_NAME_SPACE::LD_NOSHADOW ;
- maxSize = 0x0100;
+ maxSize = 0x0100;
}
f = GDCM_NAME_SPACE::File::New();
f->SetLoadMode(loadMode);
- f->SetMaxSizeLoadEntry(maxSize);
+ f->SetMaxSizeLoadEntry(maxSize);
f->SetFileName( *it );
f->Load();
- l->push_back(f);
+ l->push_back(f);
}
std::string systemCommand;
std::string filenameout;
- if (write || copy) {
+ if (write || copy) {
if (verbose)
std::cout << "Check for output directory :[" << dirNameout << "]."
<<std::endl;
<< "] already exists; Used as is."
<< std::endl;
}
- }
+ }
// --> End of checking supposed-to-be-directory names
int nbFiles;
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
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)
// 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()
// --- 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) );
+ fh = GDCM_NAME_SPACE::FileHelper::New( (*it2) );
fh->SetKeepOverlays( true );
fh->InsertEntryString(strSerieUID,0x0020,0x000e,"UI");
unsigned int dataSize = fh->GetImageDataRawSize();
<< std::endl;
}
fh->Delete();
- }
+ }
else if (copy)
{
systemCommand = "cp " + fileName + " " + filenameout;
system( systemCommand.c_str());
- }
+ }
if (verbose)
std::cout << "3 " << systemCommand << std::endl;
- }
-
+ }
std::cout << std::endl;
}
}
if ( controlCount == 0 )
std::cout << "No suitable file was found!" << std::endl;
-
+
s->Delete();
return 0;
}
Program: gdcm
Module: $RCSfile: ToInTag.cxx,v $
Language: C++
- Date: $Date: 2007/09/28 14:09:20 $
- Version: $Revision: 1.19 $
+ Date: $Date: 2007/10/24 08:03:10 $
+ Version: $Revision: 1.20 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
+ GDCM_NAME_SPACE::GDCM_FILESEPARATOR
+ currentPhaseEncodingDirection;
systemCommand = "mkdir " + currentPhaseEncodingDirectionWriteDir;
- system (systemCommand.c_str());
+ system (systemCommand.c_str());
}
previousPhaseEncodingDirection = currentPhaseEncodingDirection;
Program: gdcm
Module: $RCSfile: exXCoherentFileSet.cxx,v $
Language: C++
- Date: $Date: 2007/10/19 15:15:16 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2007/10/24 08:03:10 $
+ Version: $Revision: 1.14 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include <iostream>
#include "gdcmDirList.h"
#include "gdcmUtil.h"
-
#include "gdcmArgMgr.h"
-
-
int main(int argc, char *argv[])
-{
+{
START_USAGE(usage)
"\n exXCoherentFileSet :\n ",
" noshadowseq: user doesn't want to load Private Sequences ",
" noshadow : user doesn't want to load Private groups (odd number) ",
" noseq : user doesn't want to load Sequences ",
- " verbose : user wants to run the program in 'verbose mode' ",
+ " verbose : user wants to run the program in 'verbose mode' ",
" debug : developper wants to run the program in 'debug mode' ",
FINISH_USAGE
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;
s = GDCM_NAME_SPACE::SerieHelper::New();
s->SetLoadMode(GDCM_NAME_SPACE::LD_ALL); // Load everything for each File
- //GDCM_NAME_SPACE::TagKey t(0x0020,0x0013);
+ //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'
// (a 'Single SerieUID Files Set' per SerieUID)
// In some cases, it's not enough, since, in some cases
// we can find scout view with the same SerieUID
-
+
/*
std::cout << " ---------------------------------------- "
<< "'Single UID' Filesets found in :["
*/
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;
std::string fileName;
-
+
// For all the Single SerieUID Files Sets of the GDCM_NAME_SPACE::Serie
GDCM_NAME_SPACE::FileList *l = s->GetFirstSingleSerieUIDFileSet();
-
GDCM_NAME_SPACE::XCoherentFileSetmap xcm;
-
+
std::string serieUID;
std::string currentSerieWriteDir = "";
- std::string xCoherentWriteDir = "";
- std::string xCoherentName = "";
+ std::string xCoherentWriteDir = "";
+ std::string xCoherentName = "";
std::string serieDirectory;
std::string lastFilename;
- std::string rep("_");
+ std::string rep("_");
int controlCount = 0;
while (l) // for each 'Single SerieUID FileSet'
i != xcm.end();
++i)
{
- xCoherentName = (*i).first;
+ xCoherentName = (*i).first;
if (verbose)
std::cout << "xCoherentName = " << xCoherentName << std::endl;
GDCM_NAME_SPACE::Util::ReplaceSpecChar(serieUID, rep);
// OrderFileList() causes trouble, since some files
// (eg:MIP views) don't have 'Position', now considered as mandatory
// Commented out for the moment.
-
+
if (sort) {
s->OrderFileList((*i).second); // sort the XCoherent Fileset
std::cout << "ZSpacing for the file set " << s->GetZSpacing()
if (write)
{
lastFilename = GDCM_NAME_SPACE::Util::GetName( fileName );
- filenameout = xCoherentWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename;
+ filenameout = xCoherentWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename;
systemCommand = "cp " + fileName + " " + filenameout;
system( systemCommand.c_str());
if (verbose)
std::cout << "3 " << systemCommand << std::endl;
- }
+ }
// --- end for write
- }
+ }
std::cout << std::endl;
}
}
if ( controlCount == 0 )
std::cout << "No suitable file was found!" << std::endl;
-
+
s->Delete();
return 0;