--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+#ifndef clitkChangeDicomTagGenericFilter_h
+#define clitkChangeDicomTagGenericFilter_h
+
+/* =================================================
+ * @file clitkChangeDicomTagGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkChangeDicomTag_ggo.h"
+
+//itk include
+#include "itkGDCMImageIO.h"
+#include "itkMetaDataDictionary.h"
+#include "itkGDCMSeriesFileNames.h"
+#include <vector>
+#include <itksys/SystemTools.hxx>
+
+namespace clitk
+{
+ template<class args_info_type>
+ class ITK_EXPORT ChangeDicomTagGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef ChangeDicomTagGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( ChangeDicomTagGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_type & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ ChangeDicomTagGenericFilter();
+ ~ChangeDicomTagGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_type m_ArgsInfo;
+ bool m_Verbose;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkChangeDicomTagGenericFilter.txx"
+#endif
+
+#endif // #define clitkChangeDicomTagGenericFilter_h
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+#ifndef clitkChangeDicomTagGenericFilter_txx
+#define clitkChangeDicomTagGenericFilter_txx
+
+/* =================================================
+ * @file clitkChangeDicomTagGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+// clitk
+#include "clitkResampleImageWithOptionsFilter.h"
+#if GDCM_MAJOR_VERSION >= 2
+#include "gdcmUIDGenerator.h"
+#include <gdcmImageHelper.h>
+#include <gdcmAttribute.h>
+#include <gdcmReader.h>
+#include <gdcmWriter.h>
+#include <gdcmDataElement.h>
+#include <gdcmTag.h>
+#else
+#include "gdcmFile.h"
+#include "gdcmUtil.h"
+#endif
+
+
+namespace clitk
+{
+
+
+//-----------------------------------------------------------
+// Constructor
+//-----------------------------------------------------------
+template<class args_info_type>
+ChangeDicomTagGenericFilter<args_info_type>::ChangeDicomTagGenericFilter()
+{
+ m_Verbose=false;
+}
+
+
+//-----------------------------------------------------------
+// Update
+//-----------------------------------------------------------
+template<class args_info_type>
+void ChangeDicomTagGenericFilter<args_info_type>::Update()
+{
+ UpdateWithDimAndPixelType();
+}
+
+//-------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype read from
+// the dicom files. The MHD files may be resampled to match the
+// dicom spacing (and number of slices). Rounding errors in resampling
+// are handled by removing files when generating the output dicom
+// series.
+//-------------------------------------------------------------------
+template<class args_info_type>
+void
+ChangeDicomTagGenericFilter<args_info_type>::UpdateWithDimAndPixelType()
+{
+ //Read the dicom file
+ gdcm::Reader reader;
+ reader.SetFileName( m_ArgsInfo.input_arg );
+ reader.Read();
+ gdcm::File &fileOutput = reader.GetFile();
+ gdcm::DataSet &dsOutput = fileOutput.GetDataSet();
+ const unsigned int ptr_len = 42;
+ char *ptr = new char[ptr_len];
+ memset(ptr,0,ptr_len);
+
+ unsigned int numberOfKeysGiven=m_ArgsInfo.key_given;
+ // For all input tag
+ for (unsigned int i = 0; i < numberOfKeysGiven; i++) {
+ // Split the tag element separated with '|' in 2 parts
+ char* copy = (char*)m_ArgsInfo.key_arg[i];
+ std::vector<char*> v;
+ char* chars_array = strtok(copy, "|");
+ while(chars_array) {
+ v.push_back(chars_array);
+ chars_array = strtok(NULL, "|");
+ }
+ std::stringstream str0(v[0]), str1(v[1]);
+ int first, second;
+ str0 >> first;
+ str1 >> second;
+
+ //Change the tag element by the corresponding value
+ gdcm::DataElement tagDE( gdcm::Tag(first, second) );
+ std::string value( m_ArgsInfo.tag_arg[i] );
+ tagDE.SetByteValue(value.c_str(), (uint32_t)strlen(value.c_str()));
+ dsOutput.Insert(tagDE);
+ }
+
+ //Write the output dicom file
+ gdcm::Writer w;
+ w.SetFile( fileOutput );
+ w.SetFileName( m_ArgsInfo.output_arg );
+ w.Write();
+}
+
+}//end clitk
+
+#endif //#define clitkChangeDicomTagGenericFilter_txx
target_link_libraries(clitkWriteDicomSeries clitkCommon )
set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkWriteDicomSeries)
+ WRAP_GGO(clitkChangeDicomTag_GGO_C clitkChangeDicomTag.ggo)
+ add_executable(clitkChangeDicomTag clitkChangeDicomTag.cxx ${clitkChangeDicomTag_GGO_C})
+ target_link_libraries(clitkChangeDicomTag clitkCommon )
+ set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkChangeDicomTag)
+
WRAP_GGO(clitkGateSimulation2Dicom_GGO_C clitkGateSimulation2Dicom.ggo)
add_executable(clitkGateSimulation2Dicom clitkGateSimulation2Dicom.cxx ${clitkGateSimulation2Dicom_GGO_C})
target_link_libraries(clitkGateSimulation2Dicom clitkCommon )
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+
+/* =================================================
+ * @file clitkChangeDicomTag.cxx
+ * @author TB
+ * @date 07/18
+ *
+ * @brief Change dicom tag value
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkChangeDicomTag_ggo.h"
+#include "clitkIO.h"
+#include "clitkChangeDicomTagGenericFilter.h"
+#include "clitkCommon.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+ // Init command line
+ GGO(clitkChangeDicomTag, args_info);
+ CLITK_INIT;
+
+ // Filter
+ typedef clitk::ChangeDicomTagGenericFilter<args_info_clitkChangeDicomTag> FilterType;
+ FilterType::Pointer genericFilter = FilterType::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkChangeDicomTag.ggo
+package "clitkChangeDicomTag"
+version "1.0"
+description "Change Dicom tag -k value to -t"
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input dicom file" string yes
+option "output" o "Output dicom file" string yes
+option "key" k "Keys of tags to modify" string no multiple default="0008|103e"
+option "tag" t "Tags values" string no multiple default="MIDPOSITION"