From 8d1daac3018c3ccbbaa087c0acf457a33ed1f90b Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Tue, 4 Jun 2013 11:07:46 +0200 Subject: [PATCH] First working version (allow to write rt-struct) --- tests_dav/clitkImage2DicomRTStruct.cxx | 177 +------------------------ tests_dav/clitkImage2DicomRTStruct.ggo | 13 +- 2 files changed, 10 insertions(+), 180 deletions(-) diff --git a/tests_dav/clitkImage2DicomRTStruct.cxx b/tests_dav/clitkImage2DicomRTStruct.cxx index b5916cf..264eb05 100644 --- a/tests_dav/clitkImage2DicomRTStruct.cxx +++ b/tests_dav/clitkImage2DicomRTStruct.cxx @@ -17,196 +17,31 @@ =========================================================================*/ +// clitk #include "clitkImage2DicomRTStructFilter.h" -#include "clitkDicomRT_StructureSet.h" #include "clitkImage2DicomRTStruct_ggo.h" -#include -#include -#include -#include -#include -#include - //-------------------------------------------------------------------- int main(int argc, char * argv[]) { // Init command line GGO(clitkImage2DicomRTStruct, args_info); - // // Read - // DD("read"); - // vtkSmartPointer reader = vtkGDCMPolyDataReader::New(); - // reader->SetFileName(args_info.rtstruct_arg); - // reader->Update(); - // DD("reader done"); - - // //====================================== - // // access to properties - // vtkRTStructSetProperties * p = reader->GetRTStructSetProperties(); - // DD(p->GetNumberOfStructureSetROIs()); - // DD(p->GetStructureSetROIName(0)); - // DD(p->GetStructureSetROINumber(0)); - - - // //====================================== - // // Test read binary image, convert to polydata - // typedef float PixelType; - // typedef itk::Image ImageType; - // ImageType::Pointer input_itk = clitk::readImage(args_info.input_arg, true); - // vvImage::Pointer input_vv = vvImageFromITK<3, PixelType>(input_itk); - // vtkImageData * input_vtk = input_vv->GetVTKImages()[0]; - - // vtkSmartPointer clipper = vtkSmartPointer::New(); - // clipper->SetInput(input_vtk); - // int* extent = input_vtk->GetExtent(); - // DDV(extent, 6); - // clipper->Delete(); - - // uint n = input_vtk->GetDimensions()[2]; - // DD(n); - // std::vector > contours; - // for(uint i=0; i squares = vtkSmartPointer::New(); - // squares->SetInput(input_vtk); - // squares->SetImageRange(extent[0], extent[1], extent[2], extent[3], i, i); - // squares->SetValue(1, 1.0); - // squares->Update(); - // // DD(squares->GetNumberOfContours()); - - // vtkSmartPointer m = squares->GetOutput(); - // contours.push_back(m); - // } - // DD("done"); - - // vtkSmartPointer append = vtkSmartPointer::New(); - // for(unsigned int i=0; iAddInput(contours[i]); - // } - // append->Update(); - - // vtkSmartPointer mMesh = vtkSmartPointer::New(); - // mMesh->DeepCopy(append->GetOutput()); - - // // Write vtk - // vtkPolyDataWriter * w = vtkPolyDataWriter::New(); - // w->SetInput(mMesh); - // w->SetFileName("toto.vtk"); - // w->Write(); - // //====================================== - - - // // Set polydata - // vtkPolyData * c = reader->GetOutput(1); // second one (Oso, not Aorta) - // DD(c->GetNumberOfVerts()); - // DD(c->GetNumberOfLines()); - // DD(c->GetNumberOfPolys()); - // DD(c->GetNumberOfStrips()); - - - // //====================================== - - // DD(p->GetNumberOfContourReferencedFrameOfReferences()); - // DD(p->GetNumberOfReferencedFrameOfReferences ()); - // DD(p->GetNumberOfStructureSetROIs ()); - - // // Write - // vtkSmartPointer writer = vtkGDCMPolyDataWriter::New(); - // DD(reader->GetNumberOfOutputPorts() ); - // int numMasks = reader->GetNumberOfOutputPorts()+1; - // DD(numMasks); - - // writer->SetNumberOfInputPorts( numMasks ); // Add one - // // // vtkRTStructSetProperties * p = reader->GetRTStructSetProperties(); - // // std::string ref = p->GetReferenceFrameOfReferenceUID(); - // // const char * algogen = p->GetStructureSetROIGenerationAlgorithm(0); - // // DD(ref); - // // DD(algogen); - // // vtkIdType id = p->GetNumberOfContourReferencedFrameOfReferences(); - // // p->AddStructureSetROI(id, ref.c_str(), "BIDON", algogen); - // // // int n = p->GetNumberOfContourReferencedFrameOfReferences(); - // // const char * classuid = p->GetContourReferencedFrameOfReferenceClassUID(0, 0); - // // const char *instanceuid = p->GetContourReferencedFrameOfReferenceInstanceUID(0, 0); - // // DD(classuid); - // // DD(instanceuid); - // // p->AddContourReferencedFrameOfReference(id, classuid, instanceuid); - // // p->AddContourReferencedFrameOfReference(id+1, classuid, instanceuid); - - // // DD(p->GetNumberOfContourReferencedFrameOfReferences()); - // // DD(p->GetNumberOfReferencedFrameOfReferences ()); - // // DD(p->GetNumberOfStructureSetROIs ()); - - // writer->SetFileName("./bidon.dcm"); - // writer->SetMedicalImageProperties(reader->GetMedicalImageProperties()); - - // vtkStringArray* roiNames = vtkStringArray::New(); - // vtkStringArray* roiAlgorithms = vtkStringArray::New(); - // vtkStringArray* roiTypes = vtkStringArray::New(); - // roiNames->SetNumberOfValues(numMasks); - // roiAlgorithms->SetNumberOfValues(numMasks); - // roiTypes->SetNumberOfValues(numMasks); - - // // Add one - // int num = reader->GetNumberOfOutputPorts(); - // DD(num); - // // writer->SetInput(0, mMesh); // FIXME first one - // vtkPolyData* blank = vtkPolyData::New(); - // writer->SetInput(0, blank); - // roiNames->InsertValue(0, "blank"); - // roiAlgorithms->InsertValue(0, "blank"); - // roiTypes->InsertValue(0, "ORGAN"); - - // for (int i = 1; i < numMasks; ++i) { - // DD(i); - // writer->SetInput(i, reader->GetOutput(i-1) ); - // std::string theString = reader->GetRTStructSetProperties()->GetStructureSetROIName(i-1); - // roiNames->InsertValue(i, theString); - // DD(theString); - // theString = reader->GetRTStructSetProperties()->GetStructureSetROIGenerationAlgorithm(i-1); - // roiAlgorithms->InsertValue(i, theString); - // theString = reader->GetRTStructSetProperties()->GetStructureSetRTROIInterpretedType(i-1); - // roiTypes->InsertValue(i, theString); - // } - - // vtkRTStructSetProperties* theProperties = vtkRTStructSetProperties::New(); - // // writer->SetRTStructSetProperties(reader->GetRTStructSetProperties()); - // writer->SetRTStructSetProperties(theProperties); - // writer->InitializeRTStructSet("./", - // reader->GetRTStructSetProperties()->GetStructureSetLabel(), - // reader->GetRTStructSetProperties()->GetStructureSetName(), - // roiNames, roiAlgorithms, roiTypes); - // writer->SetRTStructSetProperties(theProperties); - - // writer->Write(); - // DD("write done"); - - // DD("end"); - // writer->Delete(); - // reader->Delete(); - // exit(0); // FIXME stop here (test) - // Read initial 3D image typedef float PixelType; typedef itk::Image ImageType; - ImageType::Pointer input = clitk::readImage(args_info.input_arg, true); - - // // Read initial RT Struct - // clitk::DicomRT_StructureSet::Pointer structset = clitk::DicomRT_StructureSet::New(); - // structset->Read(args_info.rtstruct_arg); + ImageType::Pointer input = clitk::readImage(args_info.input_arg, args_info.verbose_flag); - // Create a filter to convert image into dicomRTStruct + // Create a filter to convert image into dicomRTStruct and write to disk clitk::Image2DicomRTStructFilter filter; + filter.SetVerboseFlag(args_info.verbose_flag); filter.SetInput(input); filter.SetDicomFolder(args_info.dicom_arg); filter.SetStructureSetFilename(args_info.rtstruct_arg); filter.SetOutputFilename(args_info.output_arg); + filter.SetROIName(args_info.roiname_arg, args_info.roitype_arg); + filter.SetThresholdValue(args_info.threshold_arg); filter.Update(); - - // // Write result - // clitk::DicomRT_StructureSet::Pointer s = filter.GetDicomRTStruct(); - // s->Write(args_info.output_arg); // This is the end my friend return 0; diff --git a/tests_dav/clitkImage2DicomRTStruct.ggo b/tests_dav/clitkImage2DicomRTStruct.ggo index 3499543..928d11b 100644 --- a/tests_dav/clitkImage2DicomRTStruct.ggo +++ b/tests_dav/clitkImage2DicomRTStruct.ggo @@ -1,6 +1,6 @@ # file clitkImage2DicomRTStruct.ggo package "clitk" -version "Convert (binary) image to DICOM RT Structure Set (contours)" +version "Add a (binary) image inside a DICOM RT Structure Set (contours)" option "config" - "Config file" string no option "verbose" v "Verbose" flag off @@ -10,12 +10,7 @@ option "rtstruct" r "Input rt struct" string yes option "dicom" d "Input folder where the initial dicom ct is" string yes option "output" o "Output DicomRT filename" string yes -# option "image" j "Used to read image info (spacing, origin)" string yes -# option "roi" r "ROI to binarize (if -1 = all roi)" int no default="-1" - -# option "crop" c "Crop binary mask" flag off - -#option "roi" r "ROI to print (ID)" int no -#option "contour" c "contour to print (ID)" int no -#option "offset" o "to display points as image offsets" flag off +option "threshold" t "Threshold for binary image" float no default = "0.5" +option "roiname" - "Name of the roi added into the rt-struct" string yes +option "roitype" - "Name of the type of roi added into the rt-struct" string no default = "ORGAN" -- 2.47.1