]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
authorDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Wed, 26 Jul 2017 06:13:15 +0000 (08:13 +0200)
committerDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Wed, 26 Jul 2017 06:13:15 +0000 (08:13 +0200)
cluster_tools/gate_power_merge.sh
common/clitkDicomRTStruct2ImageFilter.cxx
common/clitkDicomRT_Contour.cxx
tools/clitkDicom2Image.cxx
tools/clitkDicom2Image.ggo
tools/clitkVectorArithm.ggo
tools/clitkVectorArithmGenericFilter.txx

index aaf063b18d4f8cc85be856ef0f19df1087c1570d..e7ea96bccf1185cd3085daa7e4c3e39b9b992347 100755 (executable)
@@ -329,9 +329,9 @@ function merge_dispatcher {
     local firstpartialoutputextension="${firstpartialoutputfile##*.}"
     echo "${indent}testing file type on ${firstpartialoutputfile}"
 
-    if test "${firstpartialoutputextension}" == "hdr" && grep -qs 'INTERFILE' "${firstpartialoutputfile}"
+    if test "${firstpartialoutputextension}" == "hdr" && test grep -qs 'INTERFILE' "${firstpartialoutputfile}"
     then
-        echo "${indent}this is a interfile image"
+        echo "${indent}this is an interfile image"
         echo "${indent}creating mhd headers"
         for partialoutputfile in $partialoutputfiles; do write_mhd_header "${partialoutputfile}"; done
         local mhd_partialoutputfiles="$(for partialoutputfile in $partialoutputfiles; do echo "${partialoutputfile%.*}.mhd"; done)"
@@ -347,7 +347,7 @@ function merge_dispatcher {
 
     if test "${firstpartialoutputextension}" == "hdr"
     then
-        echo "${indent}this is a analyse image"
+        echo "${indent}this is an analyse image"
         local mergedfile="${outputdir}/$(basename "${firstpartialoutputfile}")"
         merge_hdr_image "${mergedfile}" ${partialoutputfiles} || error "error while merging"
         return
index 96fdea75ed2415c7b2d699e6ce7dfd620f1cdd80..fcc9e2be26da9c02cfdcb1a94f10e5ff67874745 100644 (file)
@@ -221,13 +221,11 @@ void clitk::DicomRTStruct2ImageFilter::Update()
   vtkSmartPointer<vtkLinearExtrusionFilter> extrude=vtkSmartPointer<vtkLinearExtrusionFilter>::New();
 #if VTK_MAJOR_VERSION <= 5
   extrude->SetInput(mesh);
-  ///We extrude in the -slice_spacing direction to respect the FOCAL convention (NEEDED !)
-  extrude->SetVector(0, 0, -0.5*mSpacing[2]);
 #else
   extrude->SetInputData(mesh);
-  ///We extrude in the -slice_spacing direction to respect the FOCAL convention (NEEDED !)
-  extrude->SetVector(0, 0, 0.5*mSpacing[2]);
 #endif
+  ///We extrude in the -slice_spacing direction to respect the FOCAL convention (NEEDED !)
+  extrude->SetVector(0, 0, -mSpacing[2]);
 
   // Binarization
   vtkSmartPointer<vtkPolyDataToImageStencil> sts=vtkSmartPointer<vtkPolyDataToImageStencil>::New();
index ee55e44bc704986ce736c82e19fa7a9c423b145b..7fc71114bc43c987ba9dd9756a5f037a2df99618 100644 (file)
@@ -82,7 +82,11 @@ void clitk::DicomRT_Contour::UpdateDicomItem()
     double * p = mData->GetPoint(i);
     points[i*3] = p[0];
     points[i*3+1] = p[1];
-    points[i*3+2] = p[2];
+#if VTK_MAJOR_VERSION <= 5
+    points[i*3+1] = p[2];
+#else
+    points[i*3+1] = p[2]-0.5;
+#endif
   }
 
   // Get attribute
@@ -157,7 +161,11 @@ bool clitk::DicomRT_Contour::Read(gdcm::Item * item)
     double p[3];
     p[0] = points[i*3];
     p[1] = points[i*3+1];
+#if VTK_MAJOR_VERSION <= 5
     p[2] = points[i*3+2];
+#else
+    p[2] = points[i*3+2]+0.5;
+#endif
     mData->SetPoint(i, p);
     if (mZ == -1) mZ = p[2];
     if (p[2] != mZ) {
@@ -204,7 +212,11 @@ bool clitk::DicomRT_Contour::Read(gdcm::SQItem * item)
     double p[3];
     p[0] = points[i*3];
     p[1] = points[i*3+1];
+#if VTK_MAJOR_VERSION <= 5
     p[2] = points[i*3+2];
+#else
+    p[2] = points[i*3+2]+0.5;
+#endif
     mData->SetPoint(i, p);
     if (mZ == -1) mZ = p[2];
     if (p[2] != mZ) {
index a6323da9de5ba6ad89c75ab8372049ef569b3200..b1b105d676746bc70817053004cad8e76208cd15 100644 (file)
@@ -58,13 +58,22 @@ int main(int argc, char * argv[])
   int series_number = -1;
   std::set<int> series_numbers;
   std::map< int, std::vector<double> > theorigin;
+  std::map< int, std::vector<double> > theorientation;
   std::map< int, std::vector<double> > sliceLocations;
   std::map< int, std::vector<std::string> > seriesFiles;
-  for(unsigned int i=0; i<args_info.inputs_num; i++) {
-    //std::cout << "Reading <" << input_files[i] << std::endl;
 #if GDCM_MAJOR_VERSION == 2
+  if (args_info.verbose_flag)
+    std::cout << "Using GDCM-2.x" << std::endl;
+#else
+  if (args_info.verbose_flag) {
+    std::cout << "Not using GDCM-2.x" << std::endl;
+    std::cout<< "The image orientation is not supported with this version of GDCM" <<std::endl;
+  }
+#endif
+  for(unsigned int i=0; i<args_info.inputs_num; i++) {
     if (args_info.verbose_flag)
-      std::cout << "Using GDCM-2.x" << std::endl;
+        std::cout << "Reading <" << input_files[i] << std::endl;
+#if GDCM_MAJOR_VERSION == 2
     gdcm::Reader hreader;
     hreader.SetFileName(input_files[i].c_str());
     hreader.Read();
@@ -72,13 +81,23 @@ int main(int argc, char * argv[])
 
     if (args_info.extract_series_flag) {
       gdcm::Attribute<0x20,0x11> series_number_att;
-      series_number_att.SetFromDataSet(hreader.GetFile().GetDataSet());
+      series_number_att.SetFromDataSet(ds);
       series_number = series_number_att.GetValue();
     }
     
     series_numbers.insert(series_number);
     theorigin[series_number] = gdcm::ImageHelper::GetOriginValue(hreader.GetFile());
-    sliceLocations[series_number].push_back(theorigin[series_number][2]);
+    theorientation[series_number] = gdcm::ImageHelper::GetDirectionCosinesValue(hreader.GetFile());
+    double n1 = theorientation[series_number][1]*theorientation[series_number][5]-
+                theorientation[series_number][2]*theorientation[series_number][4];
+    double n2 = theorientation[series_number][3]*theorientation[series_number][2]-
+                theorientation[series_number][5]*theorientation[series_number][0];
+    double n3 = theorientation[series_number][0]*theorientation[series_number][4]-
+                theorientation[series_number][1]*theorientation[series_number][3];
+    double sloc = theorigin[series_number][0]*n1+
+                  theorigin[series_number][1]*n2+
+                  theorigin[series_number][2]*n3;
+    sliceLocations[series_number].push_back(sloc);
     seriesFiles[series_number].push_back(input_files[i]);
     
     gdcm::Attribute<0x28, 0x100> pixel_size;
@@ -91,8 +110,6 @@ int main(int argc, char * argv[])
        }
     */
 #else
-    if (args_info.verbose_flag)
-      std::cout << "Not using GDCM-2.x" << std::endl;
   gdcm::File *header = new gdcm::File();
   header->SetFileName(input_files[i]);
   header->SetMaxSizeLoadEntry(16384); // required ?
@@ -127,7 +144,7 @@ int main(int argc, char * argv[])
     std::vector<std::string> files = seriesFiles[*sn];
     std::vector<int> sliceIndex;
     clitk::GetSortedIndex(locs, sliceIndex);
-    if (args_info.verboseSliceLocation_flag) {
+    if (args_info.verbose_flag) {
       std::cout << locs[sliceIndex[0]] << " -> "
                 << sliceIndex[0] << " / " << 0 << " => "
                 << "0 mm "
@@ -212,8 +229,24 @@ int main(int argc, char * argv[])
       name << *sn << "_" << args_info.output_arg;
       outfile = name.str();
     }
+    //Check on transform
+    bool bId = true;
+    for(unsigned int i=0; i<4; i++) {
+      for(unsigned int j=0; j<4; j++) {
+        double elt = image->GetTransform()[0]->GetMatrix()->GetElement(i,j);
+        if(i==j && elt!=1.) {
+          bId = false;
+        }
+        if(i!=j && elt!=0.) {
+          bId = false;
+        }
+      }
+    }
     vvImageWriter::Pointer writer = vvImageWriter::New();
     writer->SetInput(image);
+    if(!bId) {
+        writer->SetSaveTransform(true);
+    }
     writer->SetOutputFileName(outfile);
     writer->Update();
 
index a2d3a89beb6cb8b89f1d80ee392752606683c8a2..daf0a5bb2e0353fcbe4fa4a9b1184f62b5ffb5c3 100644 (file)
@@ -4,8 +4,6 @@ version "Try to convert a DICOM into an image (.hdr, .vox...)"
 
 option "config"                 -      "Config file"            string         no
 option "verbose"        v "Verbose"                     flag off
-option "verboseSliceLocation"   - "Verbose slices locations"            flag off
-option "name"           n "Display filename"    flag off
 option "tolerance"      t "Tolerance for slice position"        double default="0" no
 option "output"      o "Output image filename"         string  yes
 option "std_input"   - "Take the like of input file from stdin, to support huge lists of filenames" flag off
index 5c7d65efe1d315c21482df0d487e2ca312697dd2..3e21fca4b1676b500d58382cc4aafa61b323e444 100644 (file)
@@ -13,7 +13,7 @@ option "input2"          j    "Input second image filename"     string   no
 option "output"    o   "Output image filename"           string   yes
 
 option "scalar"           s    "Scalar value"            double   no
-option "operation" t   "Type of operation : \n With another image : 0=add, 1=multiply (dotproduct), 7=difference, 9=crossproduct\n; For 'scalar' : 0=add, 1=multiply, 5=absval (magnitude), 6=squared magnitude, 11=divide, 12=normalize"      int default="0" no 
+option "operation" t   "Type of operation : \n With another image : 0=add, 1=multiply, 2=dotproduct, 7=difference, 9=crossproduct\n; For 'scalar' : 0=add, 1=multiply, 5=absval (magnitude), 6=squared magnitude, 11=divide, 12=normalize"     int default="0" no
 option "pixelValue" -  "Default value for NaN/Inf"     double   default="0.0"  no
 
 option "setFloatOutput" f "Set output to float pixel type" flag off
index 1f4cb721ea246b222c5ceb370cba283597918860..50e36dda17fae29dfcc7e4d973765b6b51562786 100644 (file)
@@ -79,13 +79,16 @@ void VectorArithmGenericFilter<args_info_type>::SetArgsInfo(const args_info_type
   if (mArgsInfo.input2_given) {
     mIsOperationUseASecondImage = true;
     this->AddInputFilename(mArgsInfo.input2_arg);
-    if (mArgsInfo.operation_arg == 1)
+    if (mArgsInfo.operation_arg == 2)
       mIsOutputScalar = true;
   } 
   else if (mArgsInfo.operation_arg == 5 || mArgsInfo.operation_arg == 6)
     mIsOutputScalar = true;
 
-  if (mArgsInfo.output_given) this->SetOutputFilename(mArgsInfo.output_arg);
+  if (mArgsInfo.output_given) {
+    this->SetOutputFilename(mArgsInfo.output_arg);
+    mOverwriteInputImage = false;
+  }
 
   // Check type of operation (with scalar or with other image)
   if ((mArgsInfo.input2_given) && (mArgsInfo.scalar_given)) {
@@ -217,16 +220,18 @@ void  VectorArithmGenericFilter<args_info_type>::ComputeImage(Iter1 it1, Iter2 i
       ++ito;
     }
     break;
-    /*
-  case 1: // Multiply
+
+  case 1: // term to term Multiply
     while (!ito.IsAtEnd()) {
-      ito.Set(it1.Get() * it2.Get()) );
+      typename Iter1::PixelType outputPixel(ito.Get());
+      outputPixel.SetVnlVector(element_product(it1.Get().GetVnlVector(),it2.Get().GetVnlVector()));
+      ito.Set(outputPixel);
       ++it1;
       ++it2;
       ++ito;
     }
     break;
-    */
+
     /*
   case 2: // Divide
     while (!ito.IsAtEnd()) {
@@ -457,7 +462,7 @@ void  VectorArithmGenericFilter<args_info_type>::ComputeScalarImage(Iter1 it1, I
   typedef typename Iter3::PixelType PixelType;
 
   switch (mTypeOfOperation) {
-  case 1: // Multiply
+  case 2: // Multiply
     while (!ito.IsAtEnd()) {
       ito.Set(it1.Get() * it2.Get());
       ++it1;