Skip to content

Commit

Permalink
corrupted 0028,0008 (#695)
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Mar 28, 2023
1 parent 6928d76 commit fb32a2d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ The following tools exploit dcm2niix
- [BraTS-Preprocessor](https://neuronflow.github.io/BraTS-Preprocessor/) uses dcm2niix to import files for [Brain Tumor Segmentation](https://www.frontiersin.org/articles/10.3389/fnins.2020.00125/full).
- [CardioNIfTI](https://github.com/UK-Digital-Heart-Project/CardioNIfTI) processes cardiac MR DICOM datasets and converts them to NIfTI.
- [clinica](https://github.com/aramis-lab/clinica) is a software platform for clinical neuroimaging studies that uses dcm2niix to convert DICOM images.
- [clinical_dicom2bids_smk](https://github.com/greydongilmore/clinical_dicom2bids_smk) Snakemake workflow to convert a clinical dicom directory into BIDS structure.
- [clpipe](https://github.com/cohenlabUNC/clpipe) uses dcm2bids for DICOM import.
- [conversion](https://github.com/pnlbwh/conversion) is a Python library that can convert dcm2niix created NIfTI files to the popular NRRD format (including DWI gradient tables). Note, recent versions of dcm2niix can directly convert DICOM images to NRRD.
- [convert_source](https://github.com/AdebayoBraimah/convert_source) to convert DICOM to BIDS directory layout.
Expand Down
3 changes: 2 additions & 1 deletion console/base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ unsigned char * base64_decode(const unsigned char *src, size_t len,
memset(dtable, 0x80, 256); //os_
for (i = 0; i < sizeof(base64_table) - 1; i++)
dtable[base64_table[i]] = (unsigned char) i;
dtable['='] = 0;
//next line rewritten to avoid warning -Wchar-subscripts
dtable[61] = 0; //dtable['='] = 0;

count = 0;
for (i = 0; i < len; i++) {
Expand Down
9 changes: 5 additions & 4 deletions console/nii_dicom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2314,7 +2314,6 @@ struct TDICOMdata nii_readParRec(char *parname, int isVerbose, struct TDTI4D *dt
}
isReal = true; //<- this is not correct, kludge for bug in ROGERS_20180526_WIP_B0_NS_8_1.PAR
}
int vx = vol;
if (isReal)
vol += num3DExpected;
if (isImaginary)
Expand Down Expand Up @@ -6025,6 +6024,8 @@ const uint32_t kEffectiveTE = 0x0018 + uint32_t(0x9082 << 16); //FD
d.isPlanarRGB = dcmInt(lLength, &buffer[lPos], d.isLittleEndian);
break;
case kDim3:
if (lLength < 1) //issue 695
break;
d.xyzDim[3] = dcmStrInt(lLength, &buffer[lPos]);
numberOfFrames = d.xyzDim[3];
break;
Expand Down Expand Up @@ -7451,7 +7452,7 @@ const uint32_t kEffectiveTE = 0x0018 + uint32_t(0x9082 << 16); //FD
d.xyzMM[3] = d.zSpacing; //use zSpacing if provided: depending on vendor, kZThick may or may not include a slice gap
//printMessage("patientPositions = %d XYZT = %d slicePerVol = %d numberOfDynamicScans %d\n",patientPositionNum,d.xyzDim[3], d.locationsInAcquisition, d.numberOfDynamicScans);
if ((d.manufacturer == kMANUFACTURER_PHILIPS) && (patientPositionNum > d.xyzDim[3])) {
d.CSA.numDti = d.xyzDim[3]; //issue506
d.CSA.numDti = d.xyzDim[3]; //issue506
printMessage("Please check slice thicknesses: Philips R3.2.2 bug can disrupt estimation (%d positions reported for %d slices)\n", patientPositionNum, d.xyzDim[3]); //Philips reported different positions for each slice!
}
if ((d.imageStart > 144) && (d.xyzDim[1] > 1) && (d.xyzDim[2] > 1))
Expand Down Expand Up @@ -7552,7 +7553,7 @@ const uint32_t kEffectiveTE = 0x0018 + uint32_t(0x9082 << 16); //FD
if ((B0Philips >= 0) && (d.CSA.numDti == 0)) {
d.CSA.dtiV[0] = B0Philips;
d.CSA.numDti = 1;
} //issue409 Siemens XA saved as classic 2D not enhanced
} //issue409 Siemens XA saved as classic 2D not enhanced
if (!isnan(patientPositionStartPhilips[1])) //for Philips data without
for (int k = 0; k < 4; k++)
d.patientPosition[k] = patientPositionStartPhilips[k];
Expand Down Expand Up @@ -7781,7 +7782,7 @@ const uint32_t kEffectiveTE = 0x0018 + uint32_t(0x9082 << 16); //FD
d.imageNum = abs((int)d.instanceUidCrc) % 2147483647; //INT_MAX;
if (d.imageNum == 0)
d.imageNum = 1; //https://github.com/rordenlab/dcm2niix/issues/341
//d.imageNum = 1; //not set
//d.imageNum = 1; //not set
}
if ((numDimensionIndexValues < 1) && (d.manufacturer == kMANUFACTURER_PHILIPS) && (d.seriesNum > 99999) && (philMRImageDiffBValueNumber > 0)) {
//Ugly kludge to distinguish Philips classic DICOM dti
Expand Down
4 changes: 1 addition & 3 deletions console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,6 @@ unsigned char *reorderVolumes(struct nifti_1_header *hdr, unsigned char *inImg,
for (int i = 0; i < numVol; i++)
inPos[i] = i;
unsigned char *tempVol = (unsigned char *)malloc(numVolBytes);
int outPos = 0;
for (int o = 0; o < numVol; o++) {
int i = inPos[volOrderIndex[o]]; //input volume
if (i == o)
Expand All @@ -2218,7 +2217,6 @@ unsigned char *reorderVolumes(struct nifti_1_header *hdr, unsigned char *inImg,
memcpy(&inImg[o * numVolBytes], &inImg[i * numVolBytes], numVolBytes); //copy volume to desire location dest, src, bytes
memcpy(&inImg[i * numVolBytes], &tempVol[0], numVolBytes); //copy unsorted volume
inPos[o] = i;
outPos += numVolBytes;
} //for each volume
free(inPos);
free(volOrderIndex);
Expand Down Expand Up @@ -8479,7 +8477,7 @@ int nii_loadDirCore(char *indir, struct TDCMopts *opts) {
free(dcmSort);
} //convert all images of this series
}
#else //avoid bubble sort - dont check all images for match, only those with identical series instance UID
#else //avoid bubble sort - do not check all images for match, only those with identical series instance UID
//3: stack DICOMs with the same Series
struct TWarnings warnings = setWarnings();
//sort by series instance UID ... avoids bubble-sort penalty
Expand Down
2 changes: 1 addition & 1 deletion console/ucm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ macro(ucm_add_target)
# also set the name of the target output as the original one
set_target_properties(${unity_target_name} PROPERTIES OUTPUT_NAME ${ARG_NAME})
if(UCM_NO_COTIRE_FOLDER)
# reset the folder property so all unity targets dont end up in a single folder in the solution explorer of VS
# reset the folder property so all unity targets do not end up in a single folder in the solution explorer of VS
set_target_properties(${unity_target_name} PROPERTIES FOLDER "")
endif()
set_target_properties(all_unity PROPERTIES FOLDER "CMakePredefinedTargets")
Expand Down

0 comments on commit fb32a2d

Please sign in to comment.