Skip to content

Commit

Permalink
more PET support (#802)
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Mar 11, 2024
1 parent cc7d7f3 commit f8baa94
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
2 changes: 1 addition & 1 deletion console/nii_dicom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
90 changes: 90 additions & 0 deletions console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit f8baa94

Please sign in to comment.