Skip to content

Commit

Permalink
Merge pull request #871 from CGSchwarzMayo/DeIdentificationMethod_jso…
Browse files Browse the repository at this point in the history
…n_list2

Reformat json DeidentificationMethod
  • Loading branch information
neurolabusc authored Oct 3, 2024
2 parents 15b5356 + f3f8e66 commit f5bed4e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,27 @@ tse3d: T2*/
fprintf(fp, "\t\"NonlinearGradientCorrection\": false,\n");
if (d.isDerived) // DICOM is derived image or non-spatial file (sounds, etc)
fprintf(fp, "\t\"RawImage\": false,\n");
struct TDTI4D *d4D = (struct TDTI4D *)malloc(sizeof(struct TDTI4D));
struct TDICOMdata d2; // No need to preallocate with malloc()
char *fname = (char *)malloc(strlen(filename) + 1);
strcpy(fname, filename);
d2 = readDICOMv(fname, 0, 1, d4D);
if (strlen(d4D->deidentificationMethod) > 0) {
fprintf(fp, "\t\"DeidentificationMethod\": [\"");
bool isSep = false;
for (size_t i = 0; i < strlen(d4D->deidentificationMethod); i++) {
if (d4D->deidentificationMethod[i] != '\\') {
if (isSep)
fprintf(fp, "\", \"");
isSep = false;
fprintf(fp, "%c", d4D->deidentificationMethod[i]);
} else
isSep = true;
}
fprintf(fp, "\"],\n");
}
free(d4D);
free(fname);
if (d.deID_CS_n > 0) {
char *fname = (char *)malloc(strlen(filename) + 1);
strcpy(fname, filename);
Expand All @@ -1466,7 +1487,6 @@ tse3d: T2*/
struct TDICOMdata d2; // No need to preallocate with malloc()
d2 = readDICOMv(fname, 0, 1, d4D);
free(fname);
json_Str(fp, "\t\"DeidentificationMethod\": \"%s\",\n", d4D->deidentificationMethod);
fprintf(fp, "\t\"DeidentificationMethodCodeSequence\": [ \n");
for (int i = 0; i < d.deID_CS_n && i < MAX_DEID_CS; i++) {
fprintf(fp, "\t { \n");
Expand Down

0 comments on commit f5bed4e

Please sign in to comment.