Skip to content

Commit

Permalink
Make SecondaryCaptureImageStorage Image Plane Module opt-in
Browse files Browse the repository at this point in the history
Make this feature opt-in per the discussion:

  #158
  • Loading branch information
thewtex committed Mar 15, 2024
1 parent 70b2473 commit a991601
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Source/MediaStorageAndFileFormat/gdcmImageHelper.cxx
Expand Up @@ -48,6 +48,7 @@ namespace gdcm
bool ImageHelper::ForceRescaleInterceptSlope = false;
bool ImageHelper::PMSRescaleInterceptSlope = true;
bool ImageHelper::ForcePixelSpacing = false;
bool ImageHelper::SecondaryCaptureImagePlaneModule = false;

static bool GetOriginValueFromSequence(const DataSet& ds, const Tag& tfgs, std::vector<double> &ori)
{
Expand Down Expand Up @@ -578,7 +579,7 @@ std::vector<double> ImageHelper::GetOriginValue(File const & f)

// else
const Tag timagepositionpatient(0x0020, 0x0032);
if( ds.FindDataElement( timagepositionpatient ) )
if( (ms != MediaStorage::SecondaryCaptureImageStorage || SecondaryCaptureImagePlaneModule) && ds.FindDataElement( timagepositionpatient ) )
{
const DataElement& de = ds.GetDataElement( timagepositionpatient );
Attribute<0x0020,0x0032> at = {{0,0,0}}; // default value if empty
Expand Down Expand Up @@ -730,7 +731,7 @@ std::vector<double> ImageHelper::GetDirectionCosinesValue(File const & f)
}

dircos.resize( 6 );
if( !GetDirectionCosinesFromDataSet(ds, dircos) )
if( (ms == MediaStorage::SecondaryCaptureImageStorage && !SecondaryCaptureImagePlaneModule) || !GetDirectionCosinesFromDataSet(ds, dircos) )
{
dircos[0] = 1;
dircos[1] = 0;
Expand Down Expand Up @@ -774,6 +775,16 @@ bool ImageHelper::GetForcePixelSpacing()
return ForcePixelSpacing;
}

void ImageHelper::SetSecondaryCaptureImagePlaneModule(bool b)
{
SecondaryCaptureImagePlaneModule = b;
}

bool ImageHelper::GetSecondaryCaptureImagePlaneModule()
{
return SecondaryCaptureImagePlaneModule;
}

bool GetRescaleInterceptSlopeValueFromDataSet(const DataSet& ds, std::vector<double> & interceptslope)
{
Attribute<0x0028,0x1052> at1;
Expand Down
7 changes: 7 additions & 0 deletions Source/MediaStorageAndFileFormat/gdcmImageHelper.h
Expand Up @@ -85,6 +85,12 @@ class GDCM_EXPORT ImageHelper
static void SetForcePixelSpacing(bool);
static bool GetForcePixelSpacing();

/// Opt into Image Plane Module for Secondary Capture Image Storage
/// Enable reading Image Position Patient (IPP) and Image Orientation Patient (IOP)
/// for Secondary Capture Image Storage.
static void SetSecondaryCaptureImagePlaneModule(bool);
static bool GetSecondaryCaptureImagePlaneModule();

/// This function checks tags (0x0028, 0x0010) and (0x0028, 0x0011) for the
/// rows and columns of the image in pixels (as opposed to actual distances).
/// The output is {col , row}
Expand Down Expand Up @@ -156,6 +162,7 @@ class GDCM_EXPORT ImageHelper
static bool ForceRescaleInterceptSlope;
static bool PMSRescaleInterceptSlope;
static bool ForcePixelSpacing;
static bool SecondaryCaptureImagePlaneModule;
};

} // end namespace gdcm
Expand Down

0 comments on commit a991601

Please sign in to comment.