Skip to content

Commit

Permalink
JSON ConversionSoftware/ConversionSoftwareVersion tags
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Jan 30, 2017
1 parent b6689d7 commit a0f46c5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion console/nii_dicom.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern "C" {
#define kDCMsuf " (openJPEG build)"
#endif
#endif
#define kDCMvers "v1.0.20170124" kDCMsuf
#define kDCMvers "v1.0.20170130" kDCMsuf

static const int kMaxDTI4D = 4000; //#define kMaxDTIv 4000
#define kDICOMStr 40
Expand Down
39 changes: 20 additions & 19 deletions console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,9 @@ void nii_SaveBIDS(char pathoutname[], struct TDICOMdata d, struct TDCMopts opts,
fprintf(fp, "-");
fprintf(fp, "\",\n");
} //only save PhaseEncodingDirection if BOTH direction and POLARITY are known
//fprintf(fp, "\t\"dcm2niixVersion\": \"%s\"\n", kDCMvers );
fprintf(fp, "\t\"DicomConversion\": [\"dcm2niix\", \"%s\"]\n", kDCMvers );
fprintf(fp, "\t\"ConversionSoftware\": \"dcm2niix\",\n", kDCMvers );
fprintf(fp, "\t\"ConversionSoftwareVersion\": \"%s\"\n", kDCMvers );
//fprintf(fp, "\t\"DicomConversion\": [\"dcm2niix\", \"%s\"]\n", kDCMvers );
fprintf(fp, "}\n");
fclose(fp);
}// nii_SaveBIDS()
Expand Down Expand Up @@ -552,7 +553,7 @@ int nii_SaveDTI(char pathoutname[],int nConvert, struct TDCMsort dcmSort[],struc
for (int j = 0; j < 3; j++)
bVectors[i+j*numDti] = vx[i].V[j+1];
}

// The image hasn't been created yet, so the attributes must be deferred
ImageList *images = (ImageList *) opts.imageList;
images->addDeferredAttribute("bValues", bValues);
Expand Down Expand Up @@ -963,49 +964,49 @@ void writeNiiGz (char * baseName, struct nifti_1_header hdr, unsigned char* src
int nii_saveNII (char *niiFilename, struct nifti_1_header hdr, unsigned char *im, struct TDCMopts opts)
{
hdr.vox_offset = 352;

// Extract the basename from the full file path
// R always uses '/' as the path separator, so this should work on all platforms
char *start = niiFilename + strlen(niiFilename);
while (*start != '/')
start--;
std::string name(++start);

nifti_image *image = nifti_convert_nhdr2nim(hdr, niiFilename);
if (image == NULL)
return EXIT_FAILURE;
image->data = (void *) im;

ImageList *images = (ImageList *) opts.imageList;
images->append(image, name);

free(image);
return EXIT_SUCCESS;
}

void nii_saveAttributes (struct TDICOMdata &data, struct nifti_1_header &header, struct TDCMopts &opts)
{
ImageList *images = (ImageList *) opts.imageList;

switch (data.manufacturer)
{
case kMANUFACTURER_SIEMENS:
images->addAttribute("manufacturer", "Siemens");
break;

case kMANUFACTURER_GE:
images->addAttribute("manufacturer", "GE");
break;

case kMANUFACTURER_PHILIPS:
images->addAttribute("manufacturer", "Philips");
break;

case kMANUFACTURER_TOSHIBA:
images->addAttribute("manufacturer", "Toshiba");
break;
}

if (strlen(data.manufacturersModelName) > 0)
images->addAttribute("scannerModelName", data.manufacturersModelName);
if (strlen(data.imageType) > 0)
Expand Down Expand Up @@ -1654,14 +1655,14 @@ int saveDcm2Nii(int nConvert, struct TDCMsort dcmSort[],struct TDICOMdata dcmLis
}
if ((opts.isCrop) && (dcmList[indx0].is3DAcq) && (hdr0.dim[3] > 1) && (hdr0.dim[0] < 4))//for T1 scan: && (dcmList[indx0].TE < 25)
returnCode = nii_saveCrop(pathoutname, hdr0, imgM,opts); //n.b. must be run AFTER nii_setOrtho()!

#ifdef HAVE_R
// Note that for R, only one image should be created per series
// Hence the logical OR here
if (returnCode == EXIT_SUCCESS || nii_saveNII(pathoutname,hdr0,imgM,opts) == EXIT_SUCCESS)
nii_saveAttributes(dcmList[dcmSort[0].indx], hdr0, opts);
#endif

free(imgM);
return EXIT_SUCCESS;
}// saveDcm2Nii()
Expand Down Expand Up @@ -2154,17 +2155,17 @@ int nii_loadDir(struct TDCMopts* opts) {
#ifdef HAVE_R
if (opts->isScanOnly) {
TWarnings warnings = setWarnings();

// Create the first series from the first DICOM file
TDicomSeries firstSeries;
firstSeries.representativeData = dcmList[0];
firstSeries.files.push_back(nameList.str[0]);
opts->series.push_back(firstSeries);

// Iterate over the remaining files
for (size_t i = 1; i < nDcm; i++) {
bool matched = false;

// If the file matches an existing series, add it to the corresponding file list
for (int j = 0; j < opts->series.size(); j++) {
if (isSameSet(opts->series[j].representativeData, dcmList[i], opts->isForceStackSameSeries, &warnings)) {
Expand All @@ -2173,7 +2174,7 @@ int nii_loadDir(struct TDCMopts* opts) {
break;
}
}

// If not, create a new series object
if (!matched) {
TDicomSeries nextSeries;
Expand All @@ -2182,7 +2183,7 @@ int nii_loadDir(struct TDCMopts* opts) {
opts->series.push_back(nextSeries);
}
}

// To avoid a spurious warning below
nConvertTotal = nDcm;
} else {
Expand Down

0 comments on commit a0f46c5

Please sign in to comment.