From dd1d99499ef95743d0dd0d7ea40ab6b1426d70aa Mon Sep 17 00:00:00 2001 From: Chris Rorden Date: Wed, 30 Aug 2017 10:35:22 -0400 Subject: [PATCH] Fix for https://github.com/rordenlab/dcm2niix/issues/124 --- README.md | 4 +++- console/nii_dicom.cpp | 11 +++++++++++ console/nii_dicom_batch.cpp | 14 +++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 640921f9..334f5c11 100644 --- a/README.md +++ b/README.md @@ -197,7 +197,9 @@ This requires a compiler that supports c++11. ## Links - - [Dcm2Bids](https://github.com/cbedetti/Dcm2Bids) uses dcm2niix to create [BIDS](http://bids.neuroimaging.io/) datasets. + - [Dcm2Bids](https://github.com/cbedetti/Dcm2Bids) uses dcm2niix to create [BIDS](http://bids.neuroimaging.io/) datasets. + - [bidskit](https://github.com/jmtyszka/bidskit) uses dcm2niix to create [BIDS](http://bids.neuroimaging.io/) datasets. + - [DAC2BIDS](https://github.com/dangom/dac2bids) uses dcm2niibatch to create [BIDS](http://bids.neuroimaging.io/) datasets. - [heudiconv](https://github.com/nipy/heudiconv) can use dcm2niix to create [BIDS](http://bids.neuroimaging.io/) datasets. - [nipype](https://github.com/nipy/nipype) can use dcm2niix to convert images. - [pydcm2niix is a Python module for working with dcm2niix](https://github.com/jstutters/pydcm2niix). diff --git a/console/nii_dicom.cpp b/console/nii_dicom.cpp index 4c6862c7..bdb057e4 100644 --- a/console/nii_dicom.cpp +++ b/console/nii_dicom.cpp @@ -2697,6 +2697,7 @@ struct TDICOMdata readDICOMv(char * fname, int isVerbose, int compressFlag, stru #define kComplexImageComponent (uint32_t) 0x0008+(0x9208 << 16 )//'0008' '9208' 'CS' 'ComplexImageComponent' #define kPatientName 0x0010+(0x0010 << 16 ) #define kPatientID 0x0010+(0x0020 << 16 ) +#define kAnatomicalOrientationType 0x0010+(0x2210 << 16 ) #define kBodyPartExamined 0x0018+(0x0015 << 16) #define kScanningSequence 0x0018+(0x0020 << 16) #define kSequenceVariant 0x0018+(0x0021 << 16) @@ -2765,6 +2766,9 @@ struct TDICOMdata readDICOMv(char * fname, int isVerbose, int compressFlag, stru #define kCoilSiemens 0x0051+(0x100F << 16 ) #define kImaPATModeText 0x0051+(0x1011 << 16 ) #define kLocationsInAcquisition 0x0054+(0x0081 << 16 ) +//ftp://dicom.nema.org/MEDICAL/dicom/2014c/output/chtml/part03/sect_C.8.9.4.html +//If ImageType is REPROJECTION we slice direction is reversed - need example to test +// #define kSeriesType 0x0054+(0x1000 << 16 ) #define kDoseCalibrationFactor 0x0054+(0x1322<< 16 ) #define kIconImageSequence 0x0088+(0x0200 << 16 ) #define kDiffusionBFactor 0x2001+(0x1003 << 16 )// FL @@ -3054,6 +3058,13 @@ struct TDICOMdata readDICOMv(char * fname, int isVerbose, int compressFlag, stru case kPatientName : dcmStr (lLength, &buffer[lPos], d.patientName); break; + case kAnatomicalOrientationType: { + char aotTxt[kDICOMStr]; //ftp://dicom.nema.org/MEDICAL/dicom/2015b/output/chtml/part03/sect_C.7.6.2.html#sect_C.7.6.2.1.1 + dcmStr (lLength, &buffer[lPos], aotTxt); + int slen = (int) strlen(aotTxt); + if((slen < 9) || (strstr(aotTxt, "QUADRUPED") == NULL) ) break; + printError("Anatomical Orientation Type (0010,2210) is QUADRUPED: rotate coordinates accordingly"); + break; } case kPatientID : dcmStr (lLength, &buffer[lPos], d.patientID); break; diff --git a/console/nii_dicom_batch.cpp b/console/nii_dicom_batch.cpp index 5a93e449..5323d6fc 100755 --- a/console/nii_dicom_batch.cpp +++ b/console/nii_dicom_batch.cpp @@ -1509,10 +1509,18 @@ int nii_saveNII(char * niiFilename, struct nifti_1_header hdr, unsigned char* im return EXIT_FAILURE; } #define kMaxPigz 3758096384 + //https://stackoverflow.com/questions/5272825/detecting-64bit-compile-in-c + #if UINTPTR_MAX == 0xffffffff + #define kMaxGz 2147483647 + #elif UINTPTR_MAX == 0xffffffffffffffff + #define kMaxGz kMaxPigz + #else + compiler error: unable to determine is 32 or 64 bit + #endif #ifndef myDisableZLib - if ((opts.isGz) && (strlen(opts.pigzname) < 1) && ((imgsz+hdr.vox_offset) >= 2147483647) ) { //use internal compressor - printWarning("Saving uncompressed data: internal compressor limited to 2Gb images.\n"); - if ((imgsz+hdr.vox_offset) < 3758096384) + if ((opts.isGz) && (strlen(opts.pigzname) < 1) && ((imgsz+hdr.vox_offset) >= kMaxGz) ) { //use internal compressor + printWarning("Saving uncompressed data: internal compressor limited to %d bytes images.\n", kMaxGz); + if ((imgsz+hdr.vox_offset) < kMaxPigz) printWarning(" Hint: using external compressor (pigz) should help.\n"); } else if ((opts.isGz) && (strlen(opts.pigzname) < 1) && ((imgsz+hdr.vox_offset) < 2147483647) ) { //use internal compressor writeNiiGz (niiFilename, hdr, im, imgsz, opts.gzLevel);