+/*
+ # ---------------------------------------------------------------------
+ #
+ # 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 <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
bool Bruker2Dicom::Execute()
{
+ int dimension = 1;
// ----- Check input directory name -----
bool bigEndian = GDCM_NAME_SPACE::Util::IsCurrentProcessorBigEndian();
subject_name = b_name.GetStringValue()[0];
strPatientName = subject_name;
cleanString(subject_name);
- DealWithSingleStudyDirectory (fileNames);
+ DealWithSingleStudyDirectory (fileNames, dimension);
}
break;
}
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;
}
}
// ----------------------------------------------------------------------------------------------------------
-void Bruker2Dicom::DealWithMultiStudyDirectory (GDCM_NAME_SPACE::DirListType &dirNames)
+void Bruker2Dicom::DealWithMultiStudyDirectory (GDCM_NAME_SPACE::DirListType &dirNames, int dimension)
{
GDCM_NAME_SPACE::DirListType::iterator it;
subject_name = b_name.GetStringValue()[0];
strPatientName = subject_name;
cleanString(subject_name);
- DealWithSingleStudyDirectory(fileNames);
+ DealWithSingleStudyDirectory(fileNames,dimension);
}
}
else
// ----------------------------------------------------------------------------------------------------------
-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) {
if (verbose)
printf ("outputDirName [%s]\n", outputDirName);
try {
- DealWithNiveau1(*it, strOutputDirName);
+ DealWithNiveau1(*it, strOutputDirName, dimension);
}
catch (BrukerHopelessException &e)
{
// =====================================================================
-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
//
7 1
*/
try {
- DealWithNiveau2(*it, strOutputDirName);
+ DealWithNiveau2(*it, strOutputDirName, dimension);
}
catch (BrukerHopelessException &e)
{
// =====================================================================
-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
//
}
std::string strOutputDirName(outputDirName);
try {
- DealWithNiveau3(*it, strOutputDirName);
+ DealWithNiveau3(*it, strOutputDirName, dimension);
}
catch (BrukerHopelessException &e)
{
// =====================================================================
//
-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
// 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;
/// \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;
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;
// This one will be important!
// ---------------------------
try {
- imageSet = CreateImageSet ( );
+ imageSet = CreateImageSet ( dimension);
}
catch (BrukerInitException& e)
{
// ===========================================================================================
-std::vector<BrukerImage> Bruker2Dicom::CreateImageSet ( )
+std::vector<BrukerImage> Bruker2Dicom::CreateImageSet ( int dimension)
{
std::vector<BrukerImage> imageSet;
- br_acqp.SetLoopStructure();
+ br_acqp.SetLoopStructure(dimension);
std::vector<int> tempVect = br_acqp.GetLoopStructure() ;
std::map<std::string, BrukerFieldData> map = br_acqp.GetBrukerHeaderMap();