double fovY = fov.GetDoubleValue()[1];
if (verbose)
std::cout << "FOV (ds method) " << fovX << " " << fovY << std::endl;
+
+ BrukerFieldData spatResol = br_method.GetFieldData("PVM_SpatResol");
+ double spatResolX = spatResol.GetDoubleValue()[0];
+ double spatResolY = spatResol.GetDoubleValue()[1];
+ if (verbose)
+ std::cout << "SpatResol (ds method) " << spatResolX << " " << spatResolY << std::endl;
+
/// \TODO probabely a more sophisticated accessor will be necessary :
/// (cf : non contiguous slices, overlapping, slice thickness, space between slices, etc)
fprintf(fp, "BinaryDataByteOrderMSB = False\n" );
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",fovX/NY, fovY/NY, sliceDistance );
+ fprintf(fp, "ElementSpacing = %lf %lf %lf\n", spatResolX, spatResolX, sliceDistance );
fprintf(fp, "Position = 0 0 %d\n", 0 );
fprintf(fp, "Offset = 0 0 0\n" );
fprintf(fp, "CenterOfRotation = 0 0 0\n" );
NY,
nbFrames,
pixelSize,
- fovX/NY, fovY/NY, sliceDistance,
+ //fovX/NY, fovY/NY, sliceDistance,
+ spatResolX, spatResolX, sliceDistance,
output2dseqSliceFileName,
strPatientName,
day,
fprintf(fp, "BinaryDataByteOrderMSB = False\n" );
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 ); // slice distance : no meaning for temporal serie
- fprintf(fp, "Position = 0 0 %d\n", sliceNb );
+ //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, "Position = 0 0 %d\n", sliceNb );
fprintf(fp, "Offset = 0 0 0\n" );
fprintf(fp, "CenterOfRotation = 0 0 0\n" );
fprintf(fp, "ElementNumberOfChannels = 1\n" );
NY,
nbInstants,
pixelSize,
- fovX/NY, fovY/NY, sliceDistance,
+ spatResolX, spatResolY, sliceDistance,
+ //fovX/NY, fovY/NY, sliceDistance,
output2dseqSliceFileName,
strPatientName,
day,
// deal with MatLab-generated Carto file.
// -----------------------------------------------------
- dealWithCarto(fileNames, NX, NY, nbSlices, fovX, fovY, sliceDistance,
+ dealWithCarto(fileNames, NX, NY, nbSlices, /*fovX, fovY,*/ spatResolX, spatResolY, sliceDistance,
copyFile, currentOutputDirName, outputMhdFileName, output2dseqCartoName);
}
// ===========================================================================================
void Bruker2Dicom::dealWithCarto(GDCM_NAME_SPACE::DirListType &fileNames, int NX, int NY, int nbSlices,
- double fovX, double fovY, double sliceDistance,
+ /*double fovX, double fovY, */
+ double spatResolX, double spatResolY, double sliceDistance,
char *copyFile, std::string ¤tOutputDirName,
char *outputMhdFileName, char *output2dseqCartoName)
{
if (verbose)
std::cout << "--- [" << *it << "] is a file..." << std::endl;
- icode = 0;
- iseparator = 0;
+ icode = 0;
while (code[icode][0] != 0)
- {
+ {
+ iseparator = 0;
while (separator[iseparator][0] != 0)
{
sprintf(file_name_ident, "2dseq%s%s",separator[iseparator],code[icode]); // e.g "2dseq_ADC"
}
fread(buffer_carto, NX*NY*sizeof(double), nbSlices, fp);
+ // ?!? sprintf(copyFile, "cp %s %s%c%s", (*it).c_str() ,
std::cout << "Deal with Carto file :[" <<*it << "], computed length : "
<< NX*NY*sizeof(double)*nbSlices << std::endl;
- std::string lastFileName = GDCM_NAME_SPACE::Util::GetName((*it).c_str());
+ std::string lastFileName = GDCM_NAME_SPACE::Util::GetName((*it).c_str());
if (mhd)
{
// Copy the data file in the new directory
currentOutputDirName.c_str(),GDCM_NAME_SPACE::GDCM_FILESEPARATOR, lastFileName.c_str());
system(copyFile);
sprintf(outputMhdFileName, "%s%c%s%s",
- currentOutputDirName.c_str(),GDCM_NAME_SPACE::GDCM_FILESEPARATOR, lastFileName.c_str(), ".mhd" );
+ currentOutputDirName.c_str(),GDCM_NAME_SPACE::GDCM_FILESEPARATOR, lastFileName.c_str(), ".mhd" );
if (verbose)
std::cout << "--- Output Carto MHD file [" << outputMhdFileName << "]" << std::endl;
fprintf(fp, "BinaryData = True \n" );
fprintf(fp, "BinaryDataByteOrderMSB = False\n" );
fprintf(fp, "DimSize = %d %d %d\n", NX, NY, nbSlices);
- fprintf(fp, "ElementSpacing = %lf %lf %lf\n",fovX/NY, fovY/NY, sliceDistance );
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, spatResolY, sliceDistance );
fprintf(fp, "Position = 0 0 0\n" );
fprintf(fp, "Offset = 0 0 0\n" );
fprintf(fp, "CenterOfRotation = 0 0 0\n" );
NY,
nbSlices,
8, // pixelSize
- fovX/NY, fovY/NY, sliceDistance,
+ //fovX/NY, fovY/NY, sliceDistance,
+ spatResolX, spatResolY, sliceDistance,
output2dseqCartoName,
strPatientName,
day,
if (verbose)
std::cout << "--- End writing Carto DICOM file [" << output2dseqCartoName << "]" << std::endl;
break; // don't check for more ident on same file name!
- }
- iseparator ++;
- }
- icode++;
- }
- }
- } // end iterate on files
-}
+
+ } // end deal with _ADC, -adc, etc
+ iseparator ++;
+ } // end iterate speparators
+ icode++;
+ } // end iterate code
+ } // end boost::filesystem::is_regular(*it)
+ } // end iterate on all objects (files, dir, etc)
+} // end method
// ==========================================================================================================
else
{
if (verbose)
- std::cout << "Output Directory [" << OutputDirName << "] already exists; Used as is." << std::endl;
+ std::cout << "Output Directory [" << OutputDirName << "] already exists; Used as is." << std::endl;
}
return 1;
fileH->Delete();
throw ( BrukerHopelessException ("Level 1 Unable to write Dicom file "));
}
- if (verbose)
- file->Print();
+ //if (verbose)
+ // file->Print();
file->Delete();
fileH->Delete();