From f8baa94756decadf38a2f5fdbeb604871ae9867f Mon Sep 17 00:00:00 2001 From: neurolabusc Date: Mon, 11 Mar 2024 16:06:36 -0400 Subject: [PATCH] more PET support (https://github.com/rordenlab/dcm2niix/issues/802) --- console/nii_dicom.cpp | 2 +- console/nii_dicom_batch.cpp | 90 +++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/console/nii_dicom.cpp b/console/nii_dicom.cpp index 1d972c7a..612efdb7 100644 --- a/console/nii_dicom.cpp +++ b/console/nii_dicom.cpp @@ -6680,7 +6680,7 @@ const uint32_t kEffectiveTE = 0x0018 + uint32_t(0x9082 << 16); //FD break; case kScatterFraction: d.scatterFraction = dcmStrFloat(lLength, &buffer[lPos]); - printf("SF%g\n", d.scatterFraction); //for each slice? + //printf("SF%g\n", d.scatterFraction); //for each slice? break; case kIconImageSequence: if (lLength > 8) diff --git a/console/nii_dicom_batch.cpp b/console/nii_dicom_batch.cpp index 3ac8913b..bca5d118 100644 --- a/console/nii_dicom_batch.cpp +++ b/console/nii_dicom_batch.cpp @@ -1511,6 +1511,96 @@ tse3d: T2*/ json_Str(fp, "\t\"DecayCorrectionFactor\": \"%s\",\n", d.decayCorrection); //renamed https://bids-specification.readthedocs.io/en/stable/glossary.html#objects.metadata.DecayCorrectionFactor json_Str(fp, "\t\"AttenuationCorrectionMethod\": \"%s\",\n", d.attenuationCorrectionMethod); json_Str(fp, "\t\"ReconstructionMethod\": \"%s\",\n", d.reconstructionMethod); + //START issue 802 + char reconMethodName[kDICOMStrLarge] = ""; + //start of autogenerated text + if (strstr(d.reconstructionMethod, "PSF+TOF3i21s")) + strcpy(reconMethodName, "Point-Spread Function + Time Of Flight"); + else if (strstr(d.reconstructionMethod, "PSF TOF 3D OSEM")) + strcpy(reconMethodName, "Point-Spread Function 3D Time Of Flight"); + else if (strstr(d.reconstructionMethod, "OP-OSEM")) + strcpy(reconMethodName, "Ordinary Poisson - Ordered Subset Expectation Maximization"); + else if (strstr(d.reconstructionMethod, "OSEM3D-OP-PSF")) + strcpy(reconMethodName, "Ordinary Poisson 3D Ordered Subset Expectation Maximization + Point-Spread Function"); + else if (strstr(d.reconstructionMethod, "LOR-RAMLA")) + strcpy(reconMethodName, "Line Of Response - Row Action Maximum Likelihood"); + else if (strstr(d.reconstructionMethod, "3D-RAMLA")) + strcpy(reconMethodName, "3D Row Action Maximum Likelihood"); + else if (strstr(d.reconstructionMethod, "3DRP")) + strcpy(reconMethodName, "3DRP"); + else if (strstr(d.reconstructionMethod, "3D Kinahan-Rogers")) + strcpy(reconMethodName, "3D Kinahan-Rogers"); + //end of autogenerated text + if (strlen(reconMethodName) < 1) { + if (strstr(d.reconstructionMethod, "OSEM")) + strcat(reconMethodName, "Ordered Subset Expectation Maximization "); + else if (strstr(d.reconstructionMethod, "OS")) + strcat(reconMethodName, "Ordered Subset "); + if (strstr(d.reconstructionMethod, "LOR")) + strcat(reconMethodName, "Line Of Response "); + if (strstr(d.reconstructionMethod, "RAMLA")) + strcat(reconMethodName, "Row Action Maximum Likelihood "); + if (strstr(d.reconstructionMethod, "OP")) + strcat(reconMethodName, "Ordinary Poisson "); + if (strstr(d.reconstructionMethod, "PSF")) + strcat(reconMethodName, "Point-Spread Function modelling "); + if (strstr(d.reconstructionMethod, "TOF")) + strcat(reconMethodName, "Time Of Flight "); + if (strstr(d.reconstructionMethod, "TF")) + strcat(reconMethodName, "Time Of Flight "); + if (strstr(d.reconstructionMethod, "VPHD")) + strcat(reconMethodName, "VUE Point HD "); + else if (strstr(d.reconstructionMethod, "VPHD-S")) + strcat(reconMethodName, "3D Ordered Subset Expectation Maximization with Point-Spread Function modelling "); + if (strstr(d.reconstructionMethod, "VPFX")) + strcat(reconMethodName, "VUE Point HD using Time Of Flight "); + else if (strstr(d.reconstructionMethod, "VPFXS")) + strcat(reconMethodName, "VUE Point HD using Time Of Flight with Point-Spread Function modelling "); + if (strstr(d.reconstructionMethod, "Q.Clear")) + strcat(reconMethodName, "VUE Point HD with regularization (smoothing) "); + if (strstr(d.reconstructionMethod, "BLOB")) + strcat(reconMethodName, "3D spherically symmetric basis function "); + if (strstr(d.reconstructionMethod, "FilteredBackProjection")) + strcat(reconMethodName, "Filtered Back Projection "); + if (strstr(d.reconstructionMethod, "3DRP")) + strcat(reconMethodName, "3D Kinahan-Rogers "); + //remove trailing spaces + if ((strlen(reconMethodName) > 0) && (reconMethodName[strlen(reconMethodName) -1] == ' ')) + reconMethodName[strlen(reconMethodName) -1] = '\0'; + } + json_Str(fp, "\t\"ReconMethodName\": \"%s\",\n", reconMethodName); + int iterations = 0; + //note, some vendors write 'OSEM3D-OP-PSFi10s16' others 'OP-OSEM4i21s' + // order matters `OP-OSEM4i21s` should have i=4 NOT i=21 + bool sEnd = d.reconstructionMethod[strlen(d.reconstructionMethod) -1] == 's'; + for (int i = 1; i < 33; i++) { + char stri[12]; + if (sEnd) + snprintf(stri, 12, "%di", i); + else + snprintf(stri, 12, "i%d", i); + if (strstr(d.reconstructionMethod, stri)) + iterations = i; + } + int subsets = 0; + for (int i = 1; i < 32; i++) { + char stri[12]; + if (sEnd) + snprintf(stri, 12, "%ds", i); + else + snprintf(stri, 12, "s%d", i); + if (strstr(d.reconstructionMethod, stri)) + subsets = i; + } + if ((subsets > 0) && (iterations > 0)) { + fprintf(fp, "\t\"ReconMethodParameterLabels\": [\"subsets\", \"iterations\"],\n"); + fprintf(fp, "\t\"ReconMethodParameterValues\": [\n"); + fprintf(fp, "\t\t%d,\n", subsets); + fprintf(fp, "\t\t%d\t],\n", iterations); + } + //printf("::::%s ->'%s' : s%d i%d\n", d.reconstructionMethod, reconMethodName, subsets, iterations); + //END issue 802 + json_Float(fp, "\t\"ScatterFraction\": %g,\n", d.scatterFraction); if (dti4D->decayFactor[0] >= 0.0) { //see BEP009 PET https://docs.google.com/document/d/1mqMLnxVdLwZjDd4ZiWFqjEAmOmfcModA_R535v3eQs0 fprintf(fp, "\t\"DecayFactor\": [\n");