|
16 | 16 | #include "gdcmAttribute.h" |
17 | 17 | #include "gdcmImageHelper.h" |
18 | 18 | #include "gdcmDirectionCosines.h" |
| 19 | +#include "gdcmEquipmentManufacturer.h" |
19 | 20 |
|
20 | 21 | #include <cmath> |
21 | 22 |
|
@@ -120,14 +121,57 @@ bool SplitMosaicFilter::GetAcquisitionSize(unsigned int size[2], DataSet const & |
120 | 121 | return found; |
121 | 122 | } |
122 | 123 |
|
| 124 | +const DataElement& ComputeCSAHeaderInfo(const DataSet& ds, const PrivateTag &pt, const Tag &hardcodedCsaLocation, bool handleMissingPrivateCreator ) { |
| 125 | + if ( handleMissingPrivateCreator && !ds.FindDataElement(pt) ) { |
| 126 | + // check hardcoded location first: |
| 127 | + if ( ds.FindDataElement(hardcodedCsaLocation) ) { |
| 128 | + Attribute<0x0008, 0x0008> imageType; |
| 129 | + imageType.SetFromDataSet(ds); |
| 130 | + const unsigned int nvalues = imageType.GetNumberOfValues(); |
| 131 | + const std::string str4 = nvalues >= 5 ? imageType.GetValue(4).Trim() : ""; |
| 132 | + const char mosaic[] = "MOSAIC"; |
| 133 | + if ( str4 == mosaic ) { |
| 134 | + gdcmWarningMacro( "CSAImageHeaderInfo private creator missing. Using hardcoded location (0029,1010)" ); |
| 135 | + return ds.GetDataElement(hardcodedCsaLocation); |
| 136 | + } |
| 137 | + const EquipmentManufacturer::Type manufacturer = EquipmentManufacturer::Compute(ds); |
| 138 | + if ( manufacturer == EquipmentManufacturer::SIEMENS ) { |
| 139 | + gdcmWarningMacro( "CSAImageHeaderInfo private creator missing. Using hardcoded location (0029,1010)" ); |
| 140 | + return ds.GetDataElement(hardcodedCsaLocation); |
| 141 | + } |
| 142 | + } |
| 143 | + } |
| 144 | + return ds.GetDataElement(pt); |
| 145 | +} |
| 146 | + |
| 147 | +// For some reason anoymizer from ADNI DICOM remove the private creator for SIEMENS CSA |
| 148 | +// Since dcm2niix has a hardcoded location for SIEMENS CSA tag 0029,1010 we want to reproduce |
| 149 | +// the behavior for the average user. |
| 150 | +// ref: LEVEY^ADNI3 Basic / Axial rsfMRI (Eyes Open) |
| 151 | +// (0029,1008) CS [IMAGE NUM 4] # 12, 1 Unknown Tag & Data |
| 152 | +// (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 |
| 153 | +// (0029,1018) CS [MR] # 2, 1 Unknown Tag & Data |
| 154 | +// (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 |
| 155 | +const DataElement& SplitMosaicFilter::ComputeCSAImageHeaderInfo(const DataSet& ds, const bool handleMissingPrivateCreator ) { |
| 156 | + const PrivateTag &pt = CSAHeader::GetCSAImageHeaderInfoTag(); |
| 157 | + const Tag hardcodedCsaLocation(0x0029,0x1010); |
| 158 | + return ComputeCSAHeaderInfo(ds, pt, hardcodedCsaLocation, handleMissingPrivateCreator); |
| 159 | +} |
| 160 | + |
| 161 | +const DataElement& SplitMosaicFilter::ComputeCSASeriesHeaderInfo(const DataSet& ds, const bool handleMissingPrivateCreator ) { |
| 162 | + const PrivateTag &pt = CSAHeader::GetCSASeriesHeaderInfoTag(); |
| 163 | + const Tag hardcodedCsaLocation(0x0029,0x1020); |
| 164 | + return ComputeCSAHeaderInfo(ds, pt, hardcodedCsaLocation, handleMissingPrivateCreator); |
| 165 | +} |
| 166 | + |
123 | 167 | unsigned int SplitMosaicFilter::GetNumberOfImagesInMosaic( File const & file ) |
124 | 168 | { |
125 | 169 | unsigned int numberOfImagesInMosaic = 0; |
126 | 170 | DataSet const &ds = file.GetDataSet(); |
127 | 171 | CSAHeader csa; |
128 | 172 |
|
129 | | - const PrivateTag &t1 = csa.GetCSAImageHeaderInfoTag(); |
130 | | - if( csa.LoadFromDataElement( ds.GetDataElement( t1 ) ) ) |
| 173 | + const DataElement& csaEl = ComputeCSAImageHeaderInfo( ds ) ; |
| 174 | + if( csa.LoadFromDataElement( csaEl ) ) |
131 | 175 | { |
132 | 176 | if( csa.FindCSAElementByName( "NumberOfImagesInMosaic" ) ) |
133 | 177 | { |
@@ -234,9 +278,9 @@ bool SplitMosaicFilter::ComputeMOSAICSliceNormal( double slicenormalvector[3], b |
234 | 278 |
|
235 | 279 | double normal[3]; |
236 | 280 | bool snvfound = false; |
237 | | - const PrivateTag &t1 = csa.GetCSAImageHeaderInfoTag(); |
238 | 281 | static const char snvstr[] = "SliceNormalVector"; |
239 | | - if( csa.LoadFromDataElement( ds.GetDataElement( t1 ) ) ) |
| 282 | + const DataElement& csaEl = ComputeCSAImageHeaderInfo( ds ) ; |
| 283 | + if( csa.LoadFromDataElement( csaEl ) ) |
240 | 284 | { |
241 | 285 | if( csa.FindCSAElementByName( snvstr ) ) |
242 | 286 | { |
|
0 commit comments