Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
malaterre committed May 2, 2024
2 parents 7ccabc4 + 8f16bf1 commit 2a8399a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Source/MediaStorageAndFileFormat/gdcmSplitMosaicFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ bool SplitMosaicFilter::ComputeMOSAICSliceNormal( double slicenormalvector[3], b
}
else if( fabs(-1. - snv_dot) < 1e-6 )
{
gdcmWarningMacro("SliceNormalVector is opposite direction");
gdcmDebugMacro("SliceNormalVector is opposite direction");
inverted = true;
}
else
Expand All @@ -298,6 +298,9 @@ bool SplitMosaicFilter::ComputeMOSAICImagePositionPatient( double ret[3],
DataSet& ds = GetFile().GetDataSet();
DirectionCosines dc( dircos );
dc.Normalize();
double z[3];
dc.Cross (z);

const double *dircos_normalized = dc;
const double *x = dircos_normalized;
const double *y = dircos_normalized + 3;
Expand All @@ -315,9 +318,8 @@ bool SplitMosaicFilter::ComputeMOSAICImagePositionPatient( double ret[3],
if( size ) {
// two cases:
if( size == mosaic_dims[2] ) {
// all mosaic have there own slice position, simply need to pick the right one
// Handle inverted case:
size_t index = inverted ? size - 1 : 0;
// all mosaic have there own slice position, always pick the first one for computation:
size_t index = 0;
MrProtocol::Slice & slice = sa.Slices[index];
MrProtocol::Vector3 & p = slice.Position;
double pos[3];
Expand All @@ -327,6 +329,9 @@ bool SplitMosaicFilter::ComputeMOSAICImagePositionPatient( double ret[3],
for(int i = 0; i < 3; ++i ) {
ipp_csa[i] = pos[i] - mosaic_dims[0] / 2. * pixelspacing[0] * x[i] - mosaic_dims[1] / 2. * pixelspacing[1] * y[i];
}
if( inverted ) {
ipp_csa[2] = ipp_csa[2] + 1. * pixelspacing[2];
}
hasIppCsa = true;
} else if( size == 1 /*&& mosaic_dims[2] % 2 == 0*/) {
// there is a single SliceArray but multiple mosaics, assume this is exactly the center one
Expand Down Expand Up @@ -359,6 +364,12 @@ bool SplitMosaicFilter::ComputeMOSAICImagePositionPatient( double ret[3],
ipp_dcm[i] = ipp[i] + (image_dims[0] - mosaic_dims[0]) / 2. * pixelspacing[0] * x[i] +
(image_dims[1] - mosaic_dims[1]) / 2. * pixelspacing[1] * y[i] ;
}
// When SNV inverted, first slice is actually the last one:
if( inverted ) {
for(int i = 0; i < 3; ++i ) {
ipp_dcm[i] = ipp_dcm[i] - z[i] * pixelspacing[2] * (mosaic_dims[2] - 1);
}
}
}
if(hasIppCsa ) {
double diff[3];
Expand Down

0 comments on commit 2a8399a

Please sign in to comment.