From 7a849fb72c9e8d006fa69c74b24a3e12778c269f Mon Sep 17 00:00:00 2001 From: jean-pierre roux Date: Tue, 12 Jan 2010 09:58:20 +0000 Subject: [PATCH] use RECO_*, not PVM_* --- lib/src1/bruker2dicom.cxx | 49 ++++++++++++++++++++++++++++----------- lib/src1/brukerimage.cpp | 2 +- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/lib/src1/bruker2dicom.cxx b/lib/src1/bruker2dicom.cxx index 6e97c5b..34a5ea0 100644 --- a/lib/src1/bruker2dicom.cxx +++ b/lib/src1/bruker2dicom.cxx @@ -340,7 +340,7 @@ void Bruker2Dicom::DealWithNiveau1(std::string level1Directory, std::string curr br_method.FillMap(); /* a recuperer : - ##$PVM_Fov (dimension) + ##$PVM_Fov (dimension) // ou plutot RECO_fov ! */ /* dans method (pour perfusion seulement?) : @@ -603,19 +603,42 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr std::string mhdDataPixelType; int pixelSize; getImhDataType(bDPT, mhdDataPixelType, pixelSize); - + + + /* + + // See mail Denis : + // En regle generale il vaut mieux que l'on passe par RECO_* + // pour extraire les parametres de l'image + // + BrukerFieldData fov = br_method.GetFieldData("PVM_Fov"); double fovX = fov.GetDoubleValue()[0]; 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; +*/ + +// Better we use 'get' accessors from BrukerImage class, as Denis wrote them + + BrukerFieldData fov = br_reco.GetFieldData("RECO_Fov"); + double fovX = fov.GetDoubleValue()[0]; + double fovY = fov.GetDoubleValue()[1]; + if (verbose) + std::cout << "FOV (ds method) " << fovX << " " << fovY << std::endl; + + BrukerFieldData spatResol = br_reco.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) @@ -671,7 +694,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr //exit (0); } } - + unsigned char *buffer_2dseq = new unsigned char[NX*NY*pixelSize*nbSlices*nbInstants]; ///\ TODO : find a safer way to be sure to read everything! size_t lgr = fread(buffer_2dseq, 1, NX*NY*pixelSize*nbSlices*nbInstants, fp); @@ -689,7 +712,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr //return; throw (e); } - + serieNumber++; strSerieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID(); if (nbInstants==1) // creer un seul fichier .mhd pour toutes les Slices! (images natives) @@ -745,7 +768,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr { sprintf(output2dseqSliceFileName, "%s%c2dseq_All_the_Slices.dcm", currentOutputDirName.c_str(), GDCM_NAME_SPACE::GDCM_FILESEPARATOR); - + /* ----------- Write Dicom Image ---------------*/ MakeDicomImage(buffer_2dseq, NX, @@ -767,7 +790,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr ); } // end if dicom } // end if nbInstants = 1 - + else // more than ONE instant { // Interleaved ! @@ -910,12 +933,12 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr } // end nbInstants == 1 delete [] buffer_2dseq; /**/ - - + + // ----------------------------------------------------- // deal with MatLab-generated Carto file. // ----------------------------------------------------- - + dealWithCarto(fileNames, NX, NY, nbSlices, /*fovX, fovY,*/ spatResolX, spatResolY, sliceDistance, copyFile, currentOutputDirName, outputMhdFileName, output2dseqCartoName); } @@ -940,7 +963,7 @@ void Bruker2Dicom::dealWithCarto(GDCM_NAME_SPACE::DirListType &fileNames, int NX GDCM_NAME_SPACE::DirListType::iterator it; char file_name_ident[500]; FILE *fp; - + // Iterate to ALL the objets(files/directories) found in the input directory for (it = fileNames.begin(); it != fileNames.end(); @@ -965,7 +988,7 @@ void Bruker2Dicom::dealWithCarto(GDCM_NAME_SPACE::DirListType &fileNames, int NX if ( loc != std::string::npos ) { - + ///\ TODO : find a safer way to be sure to read everything! unsigned char *buffer_carto = new unsigned char[NX*NY*sizeof(double)*nbSlices]; fp = fopen ( (*it).c_str(), "rb"); @@ -989,7 +1012,7 @@ void Bruker2Dicom::dealWithCarto(GDCM_NAME_SPACE::DirListType &fileNames, int NX currentOutputDirName.c_str(),GDCM_NAME_SPACE::GDCM_FILESEPARATOR, lastFileName.c_str(), ".mhd" ); if (verbose) std::cout << "--- Output Carto MHD file [" << outputMhdFileName << "]" << std::endl; - + FILE *fp; fp=fopen(outputMhdFileName, "w"); if (!fp) diff --git a/lib/src1/brukerimage.cpp b/lib/src1/brukerimage.cpp index d1bff2b..7957475 100644 --- a/lib/src1/brukerimage.cpp +++ b/lib/src1/brukerimage.cpp @@ -50,7 +50,7 @@ bool BrukerImage::Init(BrukerDataSet &TheOrigAcqp, BrukerDataSet &TheOrigReco, i setImageByteSize (TheOrigAcqp,TheOrigReco,TheValue); setBeginingOfImageInBytes (TheOrigAcqp,TheOrigReco,TheValue); - return true; + return true; } /** -- 2.47.1