Skip to content

Commit

Permalink
Make PR813 compilation conditional (#861)
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Sep 14, 2024
1 parent 382014a commit 4aca344
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
3 changes: 2 additions & 1 deletion console/dcm2niix_fswrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ void dcm2niix_fswrapper::seriesInfoDump(FILE *fpdump, const MRIFSSTRUCT *pmrifsS
// dcm2niix doesn't seem to retrieve this 0x51, 0x1016
//fprintf(fpdump, "SiemensCrit %s\n",e->d.string);

#ifdef myDeidentificationMethod
// kDeidentificationMethod 0x0012 + (0x0063 << 16) // '0012' '0063' 'LO' 'DeidentificationMethod'
fprintf(fpdump, "DeidentificationMethod %s\n", tdicomData->deidentificationMethod);

#endif // myDeidentificationMethod
}
33 changes: 24 additions & 9 deletions console/nii_dicom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4391,11 +4391,13 @@ struct TDICOMdata readDICOMx(char *fname, struct TDCMprefs *prefs, struct TDTI4D
#define kPatientWeight 0x0010 + (0x1030 << 16)
#define kAnatomicalOrientationType 0x0010 + (0x2210 << 16)
#define kDeidentificationMethod 0x0012 + (0x0063 << 16) //[DICOMANON, issue 383
#define kDeidentificationMethodCodeSequence 0x0012 + (0x0064 << 16)
#define kCodeValue 0x0008 + (0x0100 << 16)
#define kCodingSchemeDesignator 0x0008 + (0x0102 << 16)
#define kCodingSchemeVersion 0x0008 + (0x0103 << 16)
#define kCodeMeaning 0x0008 + (0x0104 << 16)
#ifdef myDeidentificationMethod
#define kDeidentificationMethodCodeSequence 0x0012 + (0x0064 << 16)
#define kCodeValue 0x0008 + (0x0100 << 16)
#define kCodingSchemeDesignator 0x0008 + (0x0102 << 16)
#define kCodingSchemeVersion 0x0008 + (0x0103 << 16)
#define kCodeMeaning 0x0008 + (0x0104 << 16)
#endif
#define kBodyPartExamined 0x0018 + (0x0015 << 16)
#define kBodyPartExamined 0x0018 + (0x0015 << 16)
#define kScanningSequence 0x0018 + (0x0020 << 16)
Expand Down Expand Up @@ -4796,7 +4798,9 @@ const uint32_t kEffectiveTE = 0x0018 + uint32_t(0x9082 << 16); //FD
bool isPaletteColor = false;
bool isInterpolated = false;
bool isIconImageSequence = false;
bool isDeidentificationMethodCodeSequence = false;
#ifdef myDeidentificationMethod
bool isDeidentificationMethodCodeSequence = false;
#endif
int sqDepthIcon = -1;
bool isSwitchToImplicitVR = false;
bool isSwitchToBigEndian = false;
Expand Down Expand Up @@ -5317,8 +5321,10 @@ const uint32_t kEffectiveTE = 0x0018 + uint32_t(0x9082 << 16); //FD
//return d;
}
if (lLength > 0) //issue695: skip empty tags, "gdcmanon --dumb --empty 0018,0089 good.dcm bad.dcm"
#ifdef myDeidentificationMethod
if(sqDepth < 1 && isDeidentificationMethodCodeSequence && groupElement != kItemDelimitationTag && groupElement != kItemTag )
isDeidentificationMethodCodeSequence = false;
#endif // myDeidentificationMethod
switch (groupElement) {
case kMediaStorageSOPClassUID: {
char mediaUID[kDICOMStr];
Expand Down Expand Up @@ -5678,10 +5684,18 @@ const uint32_t kEffectiveTE = 0x0018 + uint32_t(0x9082 << 16); //FD
//printError("Anatomical Orientation Type (0010,2210) is QUADRUPED: rotate coordinates accordingly\n");
break;
}
#ifdef myDeidentificationMethod
case kDeidentificationMethod: { //issue 383
dcmStr(lLength, &buffer[lPos], d.deidentificationMethod);
int slen = (int)strlen(d.deidentificationMethod);
if ((slen < 10) || (strstr(d.deidentificationMethod, "DICOMANON") == NULL))
#ifdef myDeidentificationMethod
dcmStr(lLength, &buffer[lPos], d.deidentificationMethod);
int slen = (int)strlen(d.deidentificationMethod);
if ((slen < 10) || (strstr(d.deidentificationMethod, "DICOMANON") == NULL))
#else
char anonTxt[kDICOMStr];
dcmStr(lLength, &buffer[lPos], anonTxt);
int slen = (int)strlen(anonTxt);
if ((slen < 10) || (strstr(anonTxt, "DICOMANON") == NULL))
#endif //
break;
isDICOMANON = true;
printWarning("Matlab DICOMANON can scramble SeriesInstanceUID (0020,000e) and remove crucial data (see issue 383). \n");
Expand Down Expand Up @@ -5714,6 +5728,7 @@ const uint32_t kEffectiveTE = 0x0018 + uint32_t(0x9082 << 16); //FD
}
break;
}
#endif // myDeidentificationMethod
case kPatientID:
if (strlen(d.patientID) > 1)
break;
Expand Down
17 changes: 12 additions & 5 deletions console/nii_dicom.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,12 @@ static const int kMaxOverlay = 16; //even group values 0x6000..0x601E
// Maximum number of dimensions for .dimensionIndexValues, i.e. possibly the
// number of axes in the output .nii.
static const uint8_t MAX_NUMBER_OF_DIMENSIONS = 8;
// Maximum supported number of entries in DeidentificationMethodCodeSequence
// Any additional will be ignored
static const uint8_t MAX_DEID_CS = 10;

#ifdef myDeidentificationMethod
// Maximum supported number of entries in DeidentificationMethodCodeSequence
// Any additional will be ignored
static const uint8_t MAX_DEID_CS = 10;
#endif // myDeidentificationMethod
struct TDTI {
float V[4];
//int totalSlicesIn4DOrder;
Expand Down Expand Up @@ -247,7 +250,6 @@ static const uint8_t MAX_DEID_CS = 10;
struct TDICOMdata {
long seriesNum;
int xyzDim[5];
int deID_CS_n = 0;
uint32_t coilCrc, seriesUidCrc, instanceUidCrc;
int overlayStart[kMaxOverlay];
int postLabelDelay, shimGradientX, shimGradientY, shimGradientZ, phaseNumber, spoiling, mtState, partialFourierDirection, interp3D, aslFlags, durationLabelPulseGE, epiVersionGE, internalepiVersionGE, maxEchoNumGE, rawDataRunNumber, numberOfTR, numberOfImagesInGridUIH, numberOfDiffusionT2GE, numberOfDiffusionDirectionGE, tensorFileGE, diffCyclingModeGE, phaseEncodingGE, protocolBlockStartGE, protocolBlockLengthGE, modality, dwellTime, effectiveEchoSpacingGE, phaseEncodingLines, phaseEncodingSteps, frequencyEncodingSteps, phaseEncodingStepsOutOfPlane, echoTrainLength, echoNum, sliceOrient, manufacturer, converted2NII, acquNum, imageNum, imageStart, imageBytes, bitsStored, bitsAllocated, samplesPerPixel,locationsInAcquisition, locationsInAcquisitionConflict, compressionScheme;
Expand All @@ -258,14 +260,19 @@ static const uint8_t MAX_DEID_CS = 10;
float pixelPaddingValue; // used for both FloatPixelPaddingValue (0028, 0122) and PixelPaddingValue (0028, 0120); NaN if not present.
double imagingFrequency, acquisitionDuration, triggerDelayTime, RWVScale, RWVIntercept, dateTime, acquisitionTime, acquisitionDate, bandwidthPerPixelPhaseEncode;
char parallelAcquisitionTechnique[kDICOMStr], radiopharmaceutical[kDICOMStr], convolutionKernel[kDICOMStr], unitsPT[kDICOMStr], tracerRadionuclide[kDICOMStr], decayCorrection[kDICOMStr], attenuationCorrectionMethod[kDICOMStr],reconstructionMethod[kDICOMStr], transferSyntax[kDICOMStr];
char prescanReuseString[kDICOMStr], imageOrientationText[kDICOMStr], pulseSequenceName[kDICOMStr], coilElements[kDICOMStr], coilName[kDICOMStr], phaseEncodingDirectionDisplayedUIH[kDICOMStr], imageBaseName[kDICOMStr], stationName[kDICOMStr], studyDescription[kDICOMStr], softwareVersions[kDICOMStr], deviceSerialNumber[kDICOMStr], institutionName[kDICOMStr], referringPhysicianName[kDICOMStr], instanceUID[kDICOMStr], seriesInstanceUID[kDICOMStr], studyInstanceUID[kDICOMStr], bodyPartExamined[kDICOMStr], procedureStepDescription[kDICOMStr], imageTypeText[kDICOMStr], imageType[kDICOMStr], institutionalDepartmentName[kDICOMStr], manufacturersModelName[kDICOMStr], patientID[kDICOMStr], patientOrient[kDICOMStr], patientName[kDICOMStr], accessionNumber[kDICOMStr], seriesDescription[kDICOMStr], studyID[kDICOMStr], sequenceName[kDICOMStr], protocolName[kDICOMStr],sequenceVariant[kDICOMStr],scanningSequence[kDICOMStr], patientBirthDate[kDICOMStr], patientAge[kDICOMStr], studyDate[kDICOMStr],studyTime[kDICOMStr], deidentificationMethod[kDICOMStr];
char prescanReuseString[kDICOMStr], imageOrientationText[kDICOMStr], pulseSequenceName[kDICOMStr], coilElements[kDICOMStr], coilName[kDICOMStr], phaseEncodingDirectionDisplayedUIH[kDICOMStr], imageBaseName[kDICOMStr], stationName[kDICOMStr], studyDescription[kDICOMStr], softwareVersions[kDICOMStr], deviceSerialNumber[kDICOMStr], institutionName[kDICOMStr], referringPhysicianName[kDICOMStr], instanceUID[kDICOMStr], seriesInstanceUID[kDICOMStr], studyInstanceUID[kDICOMStr], bodyPartExamined[kDICOMStr], procedureStepDescription[kDICOMStr], imageTypeText[kDICOMStr], imageType[kDICOMStr], institutionalDepartmentName[kDICOMStr], manufacturersModelName[kDICOMStr], patientID[kDICOMStr], patientOrient[kDICOMStr], patientName[kDICOMStr], accessionNumber[kDICOMStr], seriesDescription[kDICOMStr], studyID[kDICOMStr], sequenceName[kDICOMStr], protocolName[kDICOMStr],sequenceVariant[kDICOMStr],scanningSequence[kDICOMStr], patientBirthDate[kDICOMStr], patientAge[kDICOMStr], studyDate[kDICOMStr],studyTime[kDICOMStr];
char deepLearningText[kDICOMStrLarge], scanOptions[kDICOMStrLarge], institutionAddress[kDICOMStrLarge], imageComments[kDICOMStrLarge];
uint32_t dimensionIndexValues[MAX_NUMBER_OF_DIMENSIONS];
struct TCSAdata CSA;
bool isDeepLearning, isVariableFlipAngle, isQuadruped, isRealIsPhaseMapHz, isPrivateCreatorRemap, isHasOverlay, isEPI, isIR, isPartialFourier, isDiffusion, isVectorFromBMatrix, isRawDataStorage, isGrayscaleSoftcopyPresentationState, isStackableSeries, isCoilVaries, isNonParallelSlices, isBVecWorldCoordinates, isSegamiOasis, isXA10A, isScaleOrTEVaries, isScaleVariesEnh, isDerived, isXRay, isMultiEcho, isValid, is3DAcq, is2DAcq, isExplicitVR, isLittleEndian, isPlanarRGB, isSigned, isHasPhase, isHasImaginary, isHasReal, isHasMagnitude,isHasMixed, isFloat, isResampled, isLocalizer;
char phaseEncodingRC, patientSex;
#ifdef myDeidentificationMethod
int deID_CS_n = 0;
char deidentificationMethod[kDICOMStr];
struct TDeIDCodeSequence deID_CS[MAX_DEID_CS];
#endif
};

struct TDCMprefs {
int isVerbose, compressFlag, isIgnoreTriggerTimes;
};
Expand Down
2 changes: 2 additions & 0 deletions console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,7 @@ tse3d: T2*/
fprintf(fp, "\t\"NonlinearGradientCorrection\": false,\n");
if (d.isDerived) //DICOM is derived image or non-spatial file (sounds, etc)
fprintf(fp, "\t\"RawImage\": false,\n");
#ifdef myDeidentificationMethod
json_Str(fp, "\t\"DeidentificationMethod\": \"%s\",\n", d.deidentificationMethod);
if(d.deID_CS_n>0)
{
Expand All @@ -1483,6 +1484,7 @@ if(d.deID_CS_n>0)
}
fprintf(fp, "\t],\n");
}
#endif // myDeidentificationMethod
if (d.seriesNum > 0)
fprintf(fp, "\t\"SeriesNumber\": %ld,\n", d.seriesNum);
//Chris Gorgolewski: BIDS standard specifies ISO8601 date-time format (Example: 2016-07-06T12:49:15.679688)
Expand Down

0 comments on commit 4aca344

Please sign in to comment.