X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Fsrc1%2Fbruker2dicom.cxx;h=32cb9b29bb75041a6674d21063d7d330abfc6e6f;hb=fe149fbb0bb17796095186132dc484884e7e8be2;hp=8ac2129b0de2295420f5f5e902cac9f002fc028d;hpb=cc4fb89e6ab8668e7e8830a2e65dc53dc1773de5;p=creaBruker.git diff --git a/lib/src1/bruker2dicom.cxx b/lib/src1/bruker2dicom.cxx index 8ac2129..32cb9b2 100644 --- a/lib/src1/bruker2dicom.cxx +++ b/lib/src1/bruker2dicom.cxx @@ -1,3 +1,29 @@ +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la Santé) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ +*/ #include "bruker2dicom.h" #include #include @@ -9,6 +35,7 @@ bool Bruker2Dicom::Execute() { + int dimension = 1; // ----- Check input directory name ----- bool bigEndian = GDCM_NAME_SPACE::Util::IsCurrentProcessorBigEndian(); @@ -99,7 +126,7 @@ bool Bruker2Dicom::Execute() subject_name = b_name.GetStringValue()[0]; strPatientName = subject_name; cleanString(subject_name); - DealWithSingleStudyDirectory (fileNames); + DealWithSingleStudyDirectory (fileNames, dimension); } break; } @@ -107,13 +134,13 @@ bool Bruker2Dicom::Execute() case 2: { subject_name = "defaultPatName"; strPatientName = subject_name; - DealWithSingleStudyDirectory (fileNames); + DealWithSingleStudyDirectory (fileNames, dimension); break; } case 3: { std::cout << " User passed a 'non study' directory; Hope it's a *non recursive* 'set of studies' directory! (recursive not yet dealt with)" << std::endl; - DealWithMultiStudyDirectory (fileNames); + DealWithMultiStudyDirectory (fileNames, dimension); break; } } @@ -121,7 +148,7 @@ bool Bruker2Dicom::Execute() // ---------------------------------------------------------------------------------------------------------- -void Bruker2Dicom::DealWithMultiStudyDirectory (GDCM_NAME_SPACE::DirListType &dirNames) +void Bruker2Dicom::DealWithMultiStudyDirectory (GDCM_NAME_SPACE::DirListType &dirNames, int dimension) { GDCM_NAME_SPACE::DirListType::iterator it; @@ -164,7 +191,7 @@ void Bruker2Dicom::DealWithMultiStudyDirectory (GDCM_NAME_SPACE::DirListType &di subject_name = b_name.GetStringValue()[0]; strPatientName = subject_name; cleanString(subject_name); - DealWithSingleStudyDirectory(fileNames); + DealWithSingleStudyDirectory(fileNames,dimension); } } else @@ -177,12 +204,14 @@ void Bruker2Dicom::DealWithMultiStudyDirectory (GDCM_NAME_SPACE::DirListType &di // ---------------------------------------------------------------------------------------------------------- -void Bruker2Dicom::DealWithSingleStudyDirectory (GDCM_NAME_SPACE::DirListType &fileNames) +void Bruker2Dicom::DealWithSingleStudyDirectory (GDCM_NAME_SPACE::DirListType &fileNames, int dimension) { bool res; // creation directory : 'nom du patient' std::string tempStringPatDir(OutputDirName); - tempStringPatDir = tempStringPatDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR + subject_name; + + tempStringPatDir = tempStringPatDir + "/"+ subject_name; + //GDCM_NAME_SPACE::GDCM_FILESEPARATOR + subject_name; //FCY TO MODIFY res=CreateDirectory(tempStringPatDir); if (!res) { @@ -319,7 +348,7 @@ void Bruker2Dicom::DealWithSingleStudyDirectory (GDCM_NAME_SPACE::DirListType &f if (verbose) printf ("outputDirName [%s]\n", outputDirName); try { - DealWithNiveau1(*it, strOutputDirName); + DealWithNiveau1(*it, strOutputDirName, dimension); } catch (BrukerHopelessException &e) { @@ -332,7 +361,7 @@ void Bruker2Dicom::DealWithSingleStudyDirectory (GDCM_NAME_SPACE::DirListType &f // ===================================================================== -void Bruker2Dicom::DealWithNiveau1(std::string &level1Directory, std::string ¤tOutputDirName) { +void Bruker2Dicom::DealWithNiveau1(std::string &level1Directory, std::string ¤tOutputDirName, int dimension) { // // e.g. : at level 1, in B67d1.Bp1/6 // @@ -434,7 +463,7 @@ void Bruker2Dicom::DealWithNiveau1(std::string &level1Directory, std::string &cu 7 1 */ try { - DealWithNiveau2(*it, strOutputDirName); + DealWithNiveau2(*it, strOutputDirName, dimension); } catch (BrukerHopelessException &e) { @@ -447,7 +476,7 @@ void Bruker2Dicom::DealWithNiveau1(std::string &level1Directory, std::string &cu // ===================================================================== -void Bruker2Dicom::DealWithNiveau2(std::string &level2Directory, std::string ¤tOutputDirName) { +void Bruker2Dicom::DealWithNiveau2(std::string &level2Directory, std::string ¤tOutputDirName, int dimension) { // e.g. : at level 2 in B67d1.Bp1/6/pdata // @@ -510,13 +539,13 @@ void Bruker2Dicom::DealWithNiveau2(std::string &level2Directory, std::string &cu GDCM_NAME_SPACE::GDCM_FILESEPARATOR + "isa"; - std::string str_isa_func_name + std::string str_isa_func_name; canOpen = br_isa.LoadFile(str_isa); if (!canOpen) { sprintf(outputDirName, "%s%c%s", currentOutputDirName.c_str(), GDCM_NAME_SPACE::GDCM_FILESEPARATOR, - GDCM_NAME_SPACE::Util::GetName(*it).c_str() ) + GDCM_NAME_SPACE::Util::GetName(*it).c_str() ); } else { @@ -533,7 +562,7 @@ void Bruker2Dicom::DealWithNiveau2(std::string &level2Directory, std::string &cu } std::string strOutputDirName(outputDirName); try { - DealWithNiveau3(*it, strOutputDirName); + DealWithNiveau3(*it, strOutputDirName, dimension); } catch (BrukerHopelessException &e) { @@ -555,7 +584,7 @@ void Bruker2Dicom::DealWithNiveau2(std::string &level2Directory, std::string &cu // ===================================================================== // -void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string ¤tOutputDirName){ +void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string ¤tOutputDirName, int dimension){ // // e.g. at level 3, in @@ -720,20 +749,31 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu // 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]; + + double fovX; + double fovY; + fovX= fov.GetDoubleValue()[0]; + if(fov.GetDoubleValue().size() > 1) + fovY = fov.GetDoubleValue()[1]; if (verbose) std::cout << "FOV (ds reco) " << fovX << " " << fovY << std::endl; BrukerFieldData size = br_reco.GetFieldData("RECO_size"); - double sizeX = size.GetDoubleValue()[0]; - double sizeY = size.GetDoubleValue()[1]; + double sizeX; + double sizeY; + sizeX = size.GetDoubleValue()[0]; + + if(fov.GetDoubleValue().size() > 1) + sizeY = size.GetDoubleValue()[1]; if (verbose) std::cout << "SIZE (ds reco) " << sizeX << " " << sizeY << std::endl; - double spatResolX = fovX / sizeX; - double spatResolY = fovY / sizeY; + double spatResolX; + double spatResolY; + spatResolX = fovX / sizeX; + if(fov.GetDoubleValue().size() > 1) + spatResolY = fovY / sizeY; if (verbose) std::cout << "spatResol (ds reco : fov/size) " << spatResolX << " " << spatResolY << std::endl; @@ -742,10 +782,12 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu /// \TODO probabely a more sophisticated accessor will be necessary : /// (cf : non contiguous slices, overlapping, slice thickness, space between slices, etc) - + double sliceDistance; + if(dimension > 1) + { BrukerFieldData bsliceDistance = br_method.GetFieldData("PVM_SPackArrSliceDistance"); - double sliceDistance = bsliceDistance.GetDoubleValue()[0]; - + sliceDistance = bsliceDistance.GetDoubleValue()[0]; + } if (verbose) std::cout << "SPackArrSliceDistance (ds method) " << sliceDistance << std::endl; @@ -773,6 +815,8 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu if (verbose) std::cout << "nbSlices " << nbSlices << std::endl; int k; + if(dimension ==1) + nbSlices = 1; int nbInstants = nbFrames/nbSlices; if (verbose) std::cout << "nbInstants (deduced)" << nbInstants << std::endl; @@ -810,7 +854,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu // This one will be important! // --------------------------- try { - imageSet = CreateImageSet ( ); + imageSet = CreateImageSet ( dimension); } catch (BrukerInitException& e) { @@ -1361,10 +1405,10 @@ void Bruker2Dicom::getImhDataType(BrukerFieldData &bDPT, std::string &mhdDataPix // =========================================================================================== -std::vector Bruker2Dicom::CreateImageSet ( ) +std::vector Bruker2Dicom::CreateImageSet ( int dimension) { std::vector imageSet; - br_acqp.SetLoopStructure(); + br_acqp.SetLoopStructure(dimension); std::vector tempVect = br_acqp.GetLoopStructure() ; std::map map = br_acqp.GetBrukerHeaderMap(); @@ -1372,7 +1416,7 @@ std::vector Bruker2Dicom::CreateImageSet ( ) if (result == false) { - throw ( BrukerInitException ("ObjectVaryingProperties.init() failure in Bruker2Dicom::CreateImageSet()") ); + throw ( BrukerInitException ("ObjectVaryingProperties.init() failure in Bruker2Dicom::CreateImageSet()") ); } br_acqp.SetImageLoopStructure();