From fb32a2dade65488d490162ab268c3c47c743de4c Mon Sep 17 00:00:00 2001 From: neurolabusc Date: Tue, 28 Mar 2023 04:35:29 -0400 Subject: [PATCH] corrupted 0028,0008 (https://github.com/rordenlab/dcm2niix/issues/695) --- README.md | 1 + console/base64.cpp | 3 ++- console/nii_dicom.cpp | 9 +++++---- console/nii_dicom_batch.cpp | 4 +--- console/ucm.cmake | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6941e434..3978a6cd 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/console/base64.cpp b/console/base64.cpp index e7033279..a645b77c 100644 --- a/console/base64.cpp +++ b/console/base64.cpp @@ -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++) { diff --git a/console/nii_dicom.cpp b/console/nii_dicom.cpp index 7b6a7d08..875e1fce 100644 --- a/console/nii_dicom.cpp +++ b/console/nii_dicom.cpp @@ -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) @@ -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; @@ -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)) @@ -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]; @@ -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 diff --git a/console/nii_dicom_batch.cpp b/console/nii_dicom_batch.cpp index b5b98fa9..f4ec1a63 100644 --- a/console/nii_dicom_batch.cpp +++ b/console/nii_dicom_batch.cpp @@ -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) @@ -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); @@ -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 diff --git a/console/ucm.cmake b/console/ucm.cmake index e6e7fc8f..37f025f3 100644 --- a/console/ucm.cmake +++ b/console/ucm.cmake @@ -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")