Skip to content

Commit

Permalink
Handle the famous inverted case
Browse files Browse the repository at this point in the history
  • Loading branch information
malaterre committed Feb 8, 2024
1 parent 77e7193 commit 231e075
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions Source/MediaStorageAndFileFormat/gdcmSplitMosaicFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,11 @@ bool SplitMosaicFilter::ComputeMOSAICSliceNormal( double slicenormalvector[3], b
}

bool SplitMosaicFilter::ComputeMOSAICImagePositionPatient( double ret[3],
const double ipp[6],
const double dircos[6],
const double pixelspacing[3],
const unsigned int image_dims[3] ,
const unsigned int mosaic_dims[3] )
const double ipp[6],
const double dircos[6],
const double pixelspacing[3],
const unsigned int image_dims[3] ,
const unsigned int mosaic_dims[3] , bool inverted)
{
CSAHeader csa;
DataSet& ds = GetFile().GetDataSet();
Expand All @@ -313,11 +313,11 @@ bool SplitMosaicFilter::ComputeMOSAICImagePositionPatient( double ret[3],
if( b ) {
size_t size = sa.Slices.size();
if( size ) {
size_t index = 0;
// Handle inverted case:
size_t index = inverted ? size - 1 : 0;
MrProtocol::Slice & slice = sa.Slices[index];
MrProtocol::Vector3 & p = slice.Position;
double pos[3];
// FIXME should I care about inverted case ?
pos[0] = p.dSag;
pos[1] = p.dCor;
pos[2] = p.dTra;
Expand All @@ -343,8 +343,8 @@ bool SplitMosaicFilter::ComputeMOSAICImagePositionPatient( double ret[3],
diff[i] = ipp_dcm[i] - ipp_csa[i];
}
double n = DirectionCosines::Norm(diff);
if( n > 1e-6 ) {
gdcmErrorMacro( "Inconcistent values for IPP/CSA" );
if( n > 1e-4 ) {
gdcmErrorMacro( "Inconsistent values for IPP/CSA" );
return false;
}
}
Expand Down Expand Up @@ -410,7 +410,7 @@ bool SplitMosaicFilter::Split()
hasOriginCSA = false;
}
#else
if(!ComputeMOSAICImagePositionPatient( origin, inputimage.GetOrigin(), inputimage.GetDirectionCosines(), inputimage.GetSpacing(), inputimage.GetDimensions(), dims ))
if(!ComputeMOSAICImagePositionPatient( origin, inputimage.GetOrigin(), inputimage.GetDirectionCosines(), inputimage.GetSpacing(), inputimage.GetDimensions(), dims, inverted ))
{
gdcmWarningMacro( "Origin will not be accurate" );
hasOriginCSA = false;
Expand Down
2 changes: 1 addition & 1 deletion Source/MediaStorageAndFileFormat/gdcmSplitMosaicFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class GDCM_EXPORT SplitMosaicFilter
const double dircos[6],
const double pixelspacing[3],
const unsigned int image_dims[3] ,
const unsigned int mosaic_dims[3] );
const unsigned int mosaic_dims[3], bool inverted );

void SetImage(const Image& image);
const Image &GetImage() const { return *I; }
Expand Down

0 comments on commit 231e075

Please sign in to comment.