Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Modules/ThirdParty/GDCM/UpdateFromUpstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ readonly name="GDCM"
readonly ownership="GDCM Upstream <gdcm-developers@lists.sourceforge.net>"
readonly subtree="Modules/ThirdParty/GDCM/src/gdcm"
readonly repo="https://github.com/malaterre/GDCM.git"
readonly tag="v3.2.1"
readonly tag="v3.2.2"
readonly shortlog=false
readonly paths="
.gitattributes
Expand Down
2 changes: 1 addition & 1 deletion Modules/ThirdParty/GDCM/src/gdcm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ endif()
#----------------------------------------------------------------------------

project(GDCM
VERSION 3.2.1
VERSION 3.2.2
LANGUAGES CXX C
)
## NOTE: the "DESCRIPTION" feature of project() was introduced in cmake 3.10.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ std::istream& ReadValue(std::istream &is, bool /*readvalues*/)
const size_t lastf = Fragments.size() - 1;
const ByteValue *bv = Fragments[ lastf ].GetByteValue();
const char *a = bv->GetPointer();
gdcmAssertAlwaysMacro( (unsigned char)a[ bv->GetLength() - 3 ] == 0xfe );
gdcmAssertAlwaysMacro( bv->GetLength() >= 3 && (unsigned char)a[ bv->GetLength() - 3 ] == 0xfe );
Fragments[ lastf ].SetByteValue( bv->GetPointer(), bv->GetLength() - 3 );
is.seekg( -11, std::ios::cur );
gdcm_assert( is.good() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ bool PixelFormat::Validate()
gdcmDebugMacro( "Bits Stored is 0. Setting is to max value" );
BitsStored = BitsAllocated;
}
if ( HighBit == 0 && BitsStored > 1 )
{
gdcmDebugMacro( "High Bit is 0. Setting is to BitStored - 1" );
HighBit = BitsStored - 1;
}
if ( BitsAllocated == 24 )
{
gdcmDebugMacro( "ACR-NEMA way of storing RGB data. Updating" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ class GDCM_EXPORT PixelFormat
case 0x0ffe: hb = 11; break;
case 0x00fe: hb = 7; break;
}
if( hb < BitsStored )
if( BitsStored > 1 && hb == 0 )
HighBit = BitsStored - 1;
else if( hb < BitsStored )
HighBit = hb;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "gdcmAttribute.h"
#include "gdcmImageHelper.h"
#include "gdcmDirectionCosines.h"
#include "gdcmEquipmentManufacturer.h"

#include <cmath>

Expand Down Expand Up @@ -120,14 +121,57 @@ bool SplitMosaicFilter::GetAcquisitionSize(unsigned int size[2], DataSet const &
return found;
}

const DataElement& ComputeCSAHeaderInfo(const DataSet& ds, const PrivateTag &pt, const Tag &hardcodedCsaLocation, bool handleMissingPrivateCreator ) {
if ( handleMissingPrivateCreator && !ds.FindDataElement(pt) ) {
// check hardcoded location first:
if ( ds.FindDataElement(hardcodedCsaLocation) ) {
Attribute<0x0008, 0x0008> imageType;
imageType.SetFromDataSet(ds);
const unsigned int nvalues = imageType.GetNumberOfValues();
const std::string str4 = nvalues >= 5 ? imageType.GetValue(4).Trim() : "";
const char mosaic[] = "MOSAIC";
if ( str4 == mosaic ) {
gdcmWarningMacro( "CSAImageHeaderInfo private creator missing. Using hardcoded location (0029,1010)" );
return ds.GetDataElement(hardcodedCsaLocation);
}
const EquipmentManufacturer::Type manufacturer = EquipmentManufacturer::Compute(ds);
if ( manufacturer == EquipmentManufacturer::SIEMENS ) {
gdcmWarningMacro( "CSAImageHeaderInfo private creator missing. Using hardcoded location (0029,1010)" );
return ds.GetDataElement(hardcodedCsaLocation);
}
}
}
return ds.GetDataElement(pt);
}

// For some reason anoymizer from ADNI DICOM remove the private creator for SIEMENS CSA
// Since dcm2niix has a hardcoded location for SIEMENS CSA tag 0029,1010 we want to reproduce
// the behavior for the average user.
// ref: LEVEY^ADNI3 Basic / Axial rsfMRI (Eyes Open)
// (0029,1008) CS [IMAGE NUM 4] # 12, 1 Unknown Tag & Data
// (0029,1010) OB 53\56\31\30\04\03\02\01\65\00\00\00\4d\00\00\00\45\63\68\6f\4c\69... # 13012, 1 Unknown Tag & Data
// (0029,1018) CS [MR] # 2, 1 Unknown Tag & Data
// (0029,1020) OB 53\56\31\30\04\03\02\01\4f\00\00\00\4d\00\00\00\55\73\65\64\50\61... # 132968, 1 Unknown Tag & Data
const DataElement& SplitMosaicFilter::ComputeCSAImageHeaderInfo(const DataSet& ds, const bool handleMissingPrivateCreator ) {
const PrivateTag &pt = CSAHeader::GetCSAImageHeaderInfoTag();
const Tag hardcodedCsaLocation(0x0029,0x1010);
return ComputeCSAHeaderInfo(ds, pt, hardcodedCsaLocation, handleMissingPrivateCreator);
}

const DataElement& SplitMosaicFilter::ComputeCSASeriesHeaderInfo(const DataSet& ds, const bool handleMissingPrivateCreator ) {
const PrivateTag &pt = CSAHeader::GetCSASeriesHeaderInfoTag();
const Tag hardcodedCsaLocation(0x0029,0x1020);
return ComputeCSAHeaderInfo(ds, pt, hardcodedCsaLocation, handleMissingPrivateCreator);
}

unsigned int SplitMosaicFilter::GetNumberOfImagesInMosaic( File const & file )
{
unsigned int numberOfImagesInMosaic = 0;
DataSet const &ds = file.GetDataSet();
CSAHeader csa;

const PrivateTag &t1 = csa.GetCSAImageHeaderInfoTag();
if( csa.LoadFromDataElement( ds.GetDataElement( t1 ) ) )
const DataElement& csaEl = ComputeCSAImageHeaderInfo( ds ) ;
if( csa.LoadFromDataElement( csaEl ) )
{
if( csa.FindCSAElementByName( "NumberOfImagesInMosaic" ) )
{
Expand Down Expand Up @@ -234,9 +278,9 @@ bool SplitMosaicFilter::ComputeMOSAICSliceNormal( double slicenormalvector[3], b

double normal[3];
bool snvfound = false;
const PrivateTag &t1 = csa.GetCSAImageHeaderInfoTag();
static const char snvstr[] = "SliceNormalVector";
if( csa.LoadFromDataElement( ds.GetDataElement( t1 ) ) )
const DataElement& csaEl = ComputeCSAImageHeaderInfo( ds ) ;
if( csa.LoadFromDataElement( csaEl ) )
{
if( csa.FindCSAElementByName( snvstr ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ class GDCM_EXPORT SplitMosaicFilter

/// Return the value for NumberOfImagesInMosaic, or compute it from Acquisition Size
static unsigned int GetNumberOfImagesInMosaic( File const & file );

/// Return the DataElement for the CSA Image Header
static const DataElement& ComputeCSAImageHeaderInfo(const DataSet& ds, bool handleMissingPrivateCreator = true);

/// Return the DataElement for the CSA Series Header
static const DataElement& ComputeCSASeriesHeaderInfo(const DataSet& ds, bool handleMissingPrivateCreator = true);

protected:

Expand Down
Loading