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)"
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
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();
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
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) {
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) {
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();
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;
}
*/
#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 ?
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 "
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();
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
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
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)) {
++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()) {
typedef typename Iter3::PixelType PixelType;
switch (mTypeOfOperation) {
- case 1: // Multiply
+ case 2: // Multiply
while (!ito.IsAtEnd()) {
ito.Set(it1.Get() * it2.Get());
++it1;