bool Bruker2Dicom::Execute()
{
- // ----- Check input values -----
+ // ----- Check input directory name -----
bool bigEndian = GDCM_NAME_SPACE::Util::IsCurrentProcessorBigEndian();
std::cout << "OK : [" << InputDirName << "] is a Directory." << std::endl;
}
+ // ----- Check output directory name -----
+
std::string strDirNameOut(OutputDirName);
bool res=CreateDirectory(strDirNameOut);
if (!res) {
// get info for 'Study Description'
- BrukerFieldData b_name=br_subject.GetFieldData("SUBJECT_name_string");
- std::string subject_name = b_name.GetStringValue()[0];
- strPatientName = subject_name;
- cleanString(subject_name);
-
- BrukerFieldData b_entry=br_subject.GetFieldData("SUBJECT_entry");
- std::string subject_entry = b_entry.GetStringValue()[0];
- //cleanString(subject_entry);
- subject_entry = subject_entry.substr(11, subject_entry.size()-11);
+ BrukerFieldData b_name=br_subject.GetFieldData("SUBJECT_name_string");
+ std::string subject_name = b_name.GetStringValue()[0];
+ strPatientName = subject_name;
+ cleanString(subject_name);
+
+ // creation directory : 'nom du patient'
+ std::string tempStringPatDir(OutputDirName);
+ tempStringPatDir = tempStringPatDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR + subject_name;
+
+ res=CreateDirectory(tempStringPatDir);
+ if (!res) {
+ std::cout << "[" << tempStringPatDir << "] Directory creation failure " << std::endl;
+ throw ( BrukerHopelessException ("Patient directory creation failure "));
+ }
+
+ BrukerFieldData b_entry=br_subject.GetFieldData("SUBJECT_entry");
+ std::string subject_entry = b_entry.GetStringValue()[0];
+ //cleanString(subject_entry);
+ subject_entry = subject_entry.substr(11, subject_entry.size()-11);
- BrukerFieldData b_position=br_subject.GetFieldData("SUBJECT_position");
- std::string subject_position = b_position.GetStringValue()[0];
- //cleanString(subject_position);
- subject_position = subject_position.substr(9, subject_position.size()-9);
+ BrukerFieldData b_position=br_subject.GetFieldData("SUBJECT_position");
+ std::string subject_position = b_position.GetStringValue()[0];
+ //cleanString(subject_position);
+ subject_position = subject_position.substr(9, subject_position.size()-9);
- BrukerFieldData b_date=br_subject.GetFieldData("SUBJECT_date");
- std::string subject_date = b_date.GetStringValue()[0];
- strStudyTimeDate = subject_date;
- cleanString(subject_date);
+ BrukerFieldData b_date=br_subject.GetFieldData("SUBJECT_date");
+ std::string subject_date = b_date.GetStringValue()[0];
+ strStudyTimeDate = subject_date;
+ cleanString(subject_date);
- BrukerFieldData b_study_name=br_subject.GetFieldData("SUBJECT_study_name");
- std::string subject_study_name = b_study_name.GetStringValue()[0];
- subject_study_name = subject_study_name.substr(1, subject_study_name.size()-2);
- cleanString(subject_date);
-
- // subject_name is already in 'Patient Name'
- strStudyDescr = /*subject_name + "." + */ subject_study_name + "." + subject_entry + "." + subject_position + "." + subject_date;
+ BrukerFieldData b_study_name=br_subject.GetFieldData("SUBJECT_study_name");
+ std::string subject_study_name = b_study_name.GetStringValue()[0];
+ subject_study_name = subject_study_name.substr(1, subject_study_name.size()-2);
+ cleanString(subject_study_name);
+ // subject_name is already in 'Patient Name'
+ strStudyDescr = /*subject_name + "." + */ subject_study_name + "." + subject_entry + "." + subject_position + "." + subject_date;
+
+ // creation directory : 'nom de la Study'
+
+ std::string tempStringStudyDir(OutputDirName);
+ tempStringStudyDir = tempStringPatDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR + strStudyDescr;
+
+ res=CreateDirectory(tempStringStudyDir);
+ if (!res) {
+ std::cout << "[" << tempStringStudyDir << "] Directory creation failure " << std::endl;
+ throw ( BrukerHopelessException ("Study directory creation failure "));
+ }
+
char outputDirName[(unsigned int) PATH_MAX+2];
- strStudyUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
- serieNumber = 0;
+ strStudyUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
+ serieNumber = 0;
instanceNumber = 0;
// -----------------------------------------------------
// Iterate to ALL the objets(files/directories) found in the input directory
// (this is level ZERO)
// each Directory (name : 1, 2, 3, ...) will be a Dicom Serie
// -----------------------------------------------------
-
+
GDCM_NAME_SPACE::DirListType::iterator it;
for (it = fileNames.begin();
+ "." + acqp_scan_name
+ "." + acqp_method.c_str();
- sprintf(outputDirName, "%s%c%s", OutputDirName.c_str(),
+ sprintf(outputDirName, "%s%c%s", tempStringStudyDir.c_str(), //OutputDirName.c_str(),
GDCM_NAME_SPACE::GDCM_FILESEPARATOR,
strSerieDescr.c_str() );
fileNames = dirList.GetFilenames();
char original2dseqName [(unsigned int) PATH_MAX+2];
+ char original2dseqName_XXX [(unsigned int) PATH_MAX+2];
char currentOutputMhdDirName [(unsigned int) PATH_MAX+2];
char outputMhdFileName [(unsigned int) PATH_MAX+2];
fp = fopen(original2dseqName, "rb");
if (!fp)
{
- std::cout << "Cannot open [" << original2dseqName << "] for reading" << std::endl;
- throw ( BrukerHopelessException ("Hopeless! Cannot open '2dseq'"));
- //exit (0);
+ // try 2dseq_Angio2D ?!?
+
+ sprintf( original2dseqName_XXX, "%s%s", original2dseqName, "_Angio2D");
+ fp = fopen(original2dseqName_XXX, "rb");
+ if (!fp)
+ {
+ std::cout << "Cannot open [" << original2dseqName << "] nor [" << original2dseqName_XXX << "] for reading" << std::endl;
+ fclose(fp);
+ throw ( BrukerHopelessException ("Hopeless! Cannot open '2dseq'"));
+ //exit (0);
+ }
}
unsigned char *buffer_2dseq = new unsigned char[NX*NY*pixelSize*nbSlices*nbInstants];
fprintf(fp, "DimSize = %d %d %d\n", NX, NY, nbSlices );
fprintf(fp, "HeaderSize = %d\n", 0);
//fprintf(fp, "ElementSpacing = %lf %lf %lf\n",fovX/NY, fovY/NY, sliceDistance );
- fprintf(fp, "ElementSpacing = %lf %lf %lf\n", spatResolX, spatResolX, sliceDistance );
+ fprintf(fp, "ElementSpacing = %lf %lf %lf\n", spatResolX, spatResolY, sliceDistance );
fprintf(fp, "Position = 0 0 %d\n", 0 );
fprintf(fp, "Offset = 0 0 0\n" );
fprintf(fp, "CenterOfRotation = 0 0 0\n" );
nbFrames,
pixelSize,
//fovX/NY, fovY/NY, sliceDistance,
- spatResolX, spatResolX, sliceDistance,
+ spatResolX, spatResolY, sliceDistance,
output2dseqSliceFileName,
strPatientName,
day,
fprintf(fp, "DimSize = %d %d %d\n", NX, NY, nbInstants);
fprintf(fp, "HeaderSize = %d\n", 0);
//fprintf(fp, "ElementSpacing = %lf %lf %lf\n",fovX/NY, fovY/NY, 1.0 ); //
- fprintf(fp, "ElementSpacing = %lf %lf %lf\n",spatResolX, spatResolX, 1.0 ); //slice distance : no meaning for temporal serie
+ fprintf(fp, "ElementSpacing = %lf %lf %lf\n",spatResolX, spatResolY, 1.0 ); //slice distance : no meaning for temporal serie
fprintf(fp, "Position = 0 0 %d\n", sliceNb );
fprintf(fp, "Offset = 0 0 0\n" );
fprintf(fp, "CenterOfRotation = 0 0 0\n" );