+/*
+# ---------------------------------------------------------------------
+#
+# 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 <creaImageIOGimmickView.h>
#include <creaImageIOSystem.h>
#include "boost/filesystem.hpp"
#if defined(USE_GDCM)
#include <gdcmGlobal.h>
#include <gdcmSerieHelper.h>
+#include <gdcmFileHelper.h>
+#include <gdcmUtil.h>
#include <vtkGdcmReader.h>
#endif
-#if defined(USE_GDCM2)
+/*#if defined(USE_GDCM2)
#include <vtkGDCMImageReader.h>
#include "gdcmSystem.h"
#include "gdcmCryptographicMessageSyntax.h"
#include "gdcmUIDGenerator.h"
#include "gdcmAnonymizer.h"
#include "gdcmGlobal.h"
-#endif
+#endif*/
namespace fs = boost::filesystem;
}
out.img->SetExtent(ext);
int dim[3];
+ double spac[3];
first->GetDimensions(dim);
+ first->GetSpacing(spac);
+ out.img->SetSpacing(spac);
out.img->SetDimensions(dim[0], dim[1], im.size() );
out.img->AllocateScalars();
out.img->Update();
{
vtkImageData* first = mReader.GetImage( im.front());
int dim[3];
+ double spac[3];
first->GetDimensions(dim);
+ first->GetSpacing(spac);
// differents formats char , short, etc...
// differents components 1..3 ex. jpg ->RGB 3
unsigned long imsize = dim[0] * dim[1];
OutStrGimmick out;
out.img = vtkImageData::New();
out.img->SetScalarType(first->GetScalarType());
-
+ out.img->SetSpacing(spac);
out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
int ext[6];
first->GetWholeExtent(ext); // send also 0,0 in Z
out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
int ext[6];
+ double spac[6];
first->GetWholeExtent(ext); // send also 0,0 in Z
ext[5] = 0;
out.img->SetExtent(ext);
-
+ first->GetSpacing(spac);
+ out.img->SetSpacing(spac);
out.img->SetDimensions(dim[0], dim[1], im.size() );
out.img->AllocateScalars();
out.img->Update();
}
-
+#if defined(USE_GDCM)
+////////////////////////////////////////////////////////////////////////
+void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
+{
+ bool res = true;
+ std::vector<GDCM_NAME_SPACE::FileHelper *> filesH;
+ std::vector<std::string> suid;
+ std::map<std::string, std::string> msuid;
+ std::string tempuid = GDCM_NAME_SPACE::Util::CreateUniqueUID();
+ int i = 1;
+ std::vector<std::string>::iterator it = i_filenames.begin();
+ for(; it != i_filenames.end(); it++)
+ {
+
+ GDCM_NAME_SPACE::File *file;
+ file = GDCM_NAME_SPACE::File::New( );
+ file->SetLoadMode( GDCM_NAME_SPACE::LD_ALL );
+ file->SetFileName( (*it).c_str() );
+ res = file->Load();
+ if ( !res )
+ {
+ std::cerr << "Sorry, " << (*it).c_str() <<" not a gdcm-readable "
+ << "DICOM / ACR File" <<std::endl;
+ file ->Delete();
+ //return 0;
+ }
+ std::cout << " ... is readable " << std::endl;
+
+ // We need a gdcm::FileHelper, since we want to load the pixels
+ GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(file);
+
+ uint8_t *imageData = fh->GetImageData();
+
+ // Institution name
+ file->AddAnonymizeElement(0x0008, 0x0080, "*");
+ // Patient's name
+ file->AddAnonymizeElement(0x0010, 0x0010, "*");
+ // Patient's ID
+ file->AddAnonymizeElement( 0x0010, 0x0020,"1515" );
+ // Study Instance UID
+ file->AddAnonymizeElement(0x0020, 0x000d, tempuid );
+ // Telephone
+ file->AddAnonymizeElement(0x0010, 0x2154, "3615" );
+
+ // Aware user will add here more fields to anonymize here
+
+ // The gdcm::File is modified in memory
+
+ file->AnonymizeFile();
+
+
+ i++;
+ fh->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE);
+
+ fh->WriteDcmExplVR(file->GetFileName() +".ano1" );
+ std::cout << i <<" End Anonymize" << std::cout;
+ file->ClearAnonymizeList();
+ file->Delete();
+ fh->Delete();
+ }
+}
+#endif
+#if defined(USE_GDCM2)
+void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
+{
+}
+#endif
////////////////////////////////////////////////////////////////////////
//void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
//{