From 6c5f177ad97daf2b7b34ae0a3f08839a08c87dd3 Mon Sep 17 00:00:00 2001 From: neurolabusc Date: Thu, 7 Sep 2023 05:52:26 -0700 Subject: [PATCH] improve bids guess (https://github.com/rordenlab/dcm2niix/issues/751) --- console/nii_dicom.cpp | 4 ++++ console/nii_dicom_batch.cpp | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/console/nii_dicom.cpp b/console/nii_dicom.cpp index 0cf25ee6..37104fe1 100644 --- a/console/nii_dicom.cpp +++ b/console/nii_dicom.cpp @@ -7921,6 +7921,8 @@ const uint32_t kEffectiveTE = 0x0018 + uint32_t(0x9082 << 16); //FD //if (contentTime != 0.0) && (numDimensionIndexValues < (MAX_NUMBER_OF_DIMENSIONS - 1)){ // uint_32t timeCRC = mz_crc32X((unsigned char*) &contentTime, sizeof(double)); //} + if (numberOfFramesICEdims < 2) //issue751: icedims[20] frames for EPI only + numberOfFramesICEdims = 0; if ((numberOfFramesICEdims > 0) && (d.xyzDim[3] != numberOfFramesICEdims)) { printWarning("Series %ld includes partial volume (issue 742): %d slices acquired but ICE dims (0021,118e) specifies %d \n", d.seriesNum, d.xyzDim[3], numberOfFramesICEdims); d.seriesNum += 1000; @@ -8136,6 +8138,8 @@ const uint32_t kEffectiveTE = 0x0018 + uint32_t(0x9082 << 16); //FD d.isValid = false; } //printf("%g\t%g\t%s\n", d.intenIntercept, d.intenScale, fname); + if ((d.isLocalizer) && (strstr(d.seriesDescription, "b1map"))) //issue751 b1map uses same base as scout + d.isLocalizer = false; return d; } // readDICOMx() diff --git a/console/nii_dicom_batch.cpp b/console/nii_dicom_batch.cpp index afe6102d..5dd0f8d9 100644 --- a/console/nii_dicom_batch.cpp +++ b/console/nii_dicom_batch.cpp @@ -6442,12 +6442,10 @@ void reportProtocolBlockGE(struct TDICOMdata *d, const char *filename, int isVer #endif } //bidsGE -void bidsStr() { // - -} - void setBidsSiemens(struct TDICOMdata *d, int nConvert, int isVerbose, const char *filename) { char seqDetails[kDICOMStrLarge] = ""; + char acqStr[kDICOMStrLarge] = ""; + char preAcqStr[kDICOMStrLarge] = ""; float inv1 = NAN; float inv2 = NAN; bool isDualTI = false; @@ -6499,6 +6497,15 @@ void setBidsSiemens(struct TDICOMdata *d, int nConvert, int isVerbose, const cha if (((d->xyzDim[3] < 2) && (nConvert < 1)) || (d->isLocalizer)) { //need nConvert or nifti header strcpy(dataTypeBIDS, "discard"); strcpy(modalityBIDS, "localizer"); + } else if (strstr(seqDetails,"b1map")) { + //issue 751 nb both T1 and b1map can use tfl base + //https://bids-specification.readthedocs.io/en/stable/appendices/qmri.html#tb1tfl-and-tb1rfm-specific-notes + strcpy(dataTypeBIDS, "fmap"); + strcpy(modalityBIDS, "TB1TFL"); + if ((strstr(d->imageType, "FLIP ANGLE MAP")) || (strstr(d->imageType, "FLIP ANGLE MAP"))) + strcpy(preAcqStr, "famp"); + else + strcpy(preAcqStr, "anat"); } else if ((strstr(seqDetails, "tfl") != NULL) || (strstr(seqDetails, "mp2rage") != NULL) || (strstr(seqDetails, "wip925") != NULL)) { //prog_mprage strcpy(dataTypeBIDS, "anat"); if (isDualTI) @@ -6615,8 +6622,8 @@ void setBidsSiemens(struct TDICOMdata *d, int nConvert, int isVerbose, const cha strcpy(modalityBIDS, "epi"); isDirLabel = true; } - char acqStr[kDICOMStrLarge] = ""; - strcat(acqStr, "_acq-"); + strcpy(acqStr, "_acq-"); + strcat(acqStr, preAcqStr); int len = strlen(seqName); if (len > 0) { for (int i = 0; i < len; i++) {