Skip to content

Commit 7cd9e02

Browse files
committed
Merge branch 'release'
2 parents ce4f84f + 6d7c523 commit 7cd9e02

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Source/MediaStorageAndFileFormat/gdcmImageHelper.cxx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,18 @@ void ImageHelper::SetDimensionsValue(File& f, const Pixmap & img)
10471047

10481048
}
10491049

1050+
// We need special care to handle VR:FD -> VR:DS conversion
1051+
static double fd2ds(const double d)
1052+
{
1053+
Element<VR::DS,VM::VM1> in = {{ 0 }};
1054+
in.SetValue( d );
1055+
std::stringstream ss;
1056+
in.Write( ss );
1057+
Element<VR::DS,VM::VM1> out = {{ 0 }};
1058+
out.Read( ss );
1059+
return out.GetValue();
1060+
}
1061+
10501062
std::vector<double> ImageHelper::GetRescaleInterceptSlopeValue(File const & f)
10511063
{
10521064
std::vector<double> interceptslope;
@@ -1210,6 +1222,34 @@ std::vector<double> ImageHelper::GetRescaleInterceptSlopeValue(File const & f)
12101222
gdcmDebugMacro( "Forcing Modality LUT used for MR Image Storage: [" << dummy[0] << "," << dummy[1] << "]" );
12111223
}
12121224
}
1225+
else
1226+
{
1227+
const Tag trwvms(0x0040,0x9096); // Real World Value Mapping Sequence
1228+
if( ds.FindDataElement( trwvms ) )
1229+
{
1230+
SmartPointer<SequenceOfItems> sqi = ds.GetDataElement( trwvms ).GetValueAsSQ();
1231+
if( sqi )
1232+
{
1233+
const Tag trwvlutd(0x0040,0x9212); // Real World Value LUT Data
1234+
if( ds.FindDataElement( trwvlutd ) )
1235+
{
1236+
gdcmAssertAlwaysMacro(0); // Not supported !
1237+
}
1238+
// don't know how to handle multiples:
1239+
gdcmAssertAlwaysMacro( sqi->GetNumberOfItems() == 1 );
1240+
const Item &item = sqi->GetItem(1);
1241+
const DataSet & subds = item.GetNestedDataSet();
1242+
//const Tag trwvi(0x0040,0x9224); // Real World Value Intercept
1243+
//const Tag trwvs(0x0040,0x9225); // Real World Value Slope
1244+
Attribute<0x0040,0x9224> at1 = {0};
1245+
at1.SetFromDataSet( subds );
1246+
Attribute<0x0040,0x9225> at2 = {1};
1247+
at2.SetFromDataSet( subds );
1248+
interceptslope[0] = fd2ds(at1.GetValue());
1249+
interceptslope[1] = fd2ds(at2.GetValue());
1250+
}
1251+
}
1252+
}
12131253
}
12141254
#endif
12151255
}

0 commit comments

Comments
 (0)