Skip to content

Commit

Permalink
Faster conversion when opts.numSeries != 0
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Dec 26, 2017
1 parent 07140a2 commit ccba52a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ If you have any problems with the cmake build script described above or want to
- [divest](https://github.com/jonclayden/divest) R interface to dcm2niix.
- [sci-tran dcm2niix](https://github.com/scitran-apps/dcm2niix) docker.
- [neuro_docker](https://github.com/Neurita/neuro_docker) includes dcm2niix as part of a single, static Dockerfile.
- [https://github.com/lalet/boutiques-dcm2niix boutiques-dcm2niix] is a dockerfile for installing and validating dcm2niix.
- [neurodocker](https://github.com/kaczmarj/neurodocker) generates [custom](https://github.com/rordenlab/dcm2niix/issues/138) Dockerfiles given specific versions of neuroimaging software.
- [dcm2niix_afni](https://afni.nimh.nih.gov/pub/dist/doc/program_help/dcm2niix_afni.html) is a version of dcm2niix included with the [AFNI](https://afni.nimh.nih.gov/) distribution.
- [MRIcroGL](https://github.com/neurolabusc/MRIcroGL) is available for MacOS, Linux and Windows and provides a graphical interface for dcm2niix. You can get compiled copies from the [MRIcroGL NITRC web site](https://www.nitrc.org/projects/mricrogl/).
3 changes: 1 addition & 2 deletions console/main_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ int main(int argc, const char * argv[])
opts.isCreateText = true;
#if !defined(_WIN64) && !defined(_WIN32) //shell script for Unix only
} else if (argv[i][1] == 'u') {
checkUpToDate();
return checkUpToDate();
#endif
} else if ((argv[i][1] == 'v') && ((i+1) < argc)) {
i++;
Expand Down Expand Up @@ -340,7 +340,6 @@ int main(int argc, const char * argv[])
if (seriesNumber < 0)
opts.numSeries = -1; //report series: convert none
else if ((opts.numSeries >= 0) && (opts.numSeries < MAX_NUM_SERIES)) {

opts.seriesNumber[opts.numSeries] = seriesNumber;
opts.numSeries += 1;
}
Expand Down
14 changes: 5 additions & 9 deletions console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2477,8 +2477,12 @@ int saveDcm2Nii(int nConvert, struct TDCMsort dcmSort[],struct TDICOMdata dcmLis
free(imgM);
return EXIT_FAILURE;
}
if (opts.numSeries < 0) { //report series but do not convert
// Prevent these DICOM files from being reused.
for(int i = 0; i < nConvert; ++i)
dcmList[dcmSort[i].indx].converted2NII = 1;
if (opts.numSeries < 0) { //report series number but do not convert
printMessage("\t%d\t%s\n", dcmList[dcmSort[0].indx].seriesNum, pathoutname);
printMessage(" %s\n",nameList->str[dcmSort[0].indx]);
return EXIT_SUCCESS;
}
checkSliceTiming(&dcmList[indx0], &dcmList[indx1]);
Expand Down Expand Up @@ -2515,7 +2519,6 @@ int saveDcm2Nii(int nConvert, struct TDCMsort dcmSort[],struct TDICOMdata dcmLis
free(imgM);
return EXIT_SUCCESS;
}

nii_SaveText(pathoutname, dcmList[dcmSort[0].indx], opts, &hdr0, nameList->str[indx]);
int numADC = 0;
int * volOrderIndex = nii_SaveDTI(pathoutname,nConvert, dcmSort, dcmList, opts, sliceDir, dti4D, &numADC);
Expand Down Expand Up @@ -2586,20 +2589,13 @@ 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);

// Prevent these DICOM files from being reused.
for(int i = 0; i < nConvert; ++i)
dcmList[dcmSort[i].indx].converted2NII = 1;

return returnCode;//EXIT_SUCCESS;
}// saveDcm2Nii()

Expand Down

0 comments on commit ccba52a

Please sign in to comment.