Skip to content

Commit

Permalink
myNoRois option to ignore ROIs (#832)
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Jul 25, 2024
1 parent 0001daa commit 25ce4d0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion FILENAMING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ DICOM images can have up to [16](https://www.medicalconnections.co.uk/kb/Number-

## File Name Conflicts

dcm2niix will attempt to write your image using the naming scheme you specify with the '-f' parameter. However, if an image already exists with the specified output name, dcm2niix will append a letter (e.g. 'a') to the end of a file name to avoid overwriting existing images. Consider a situation where dcm2niix is run with '-f %t'. This will name images based on the study time. If a single study has multiple series (for example, a T1 sequence and a fMRI scan, the reulting file names will conflict with each other. In order to avoid overwriting images, dcm2niix will resort to adding the post fix 'a', 'b', etc. There are a few solutions to avoiding these situations. You may want to consider using both of these:
dcm2niix will attempt to write your image using the naming scheme you specify with the '-f' parameter. However, if an image already exists with the specified output name, dcm2niix will append a letter (e.g. 'a') to the end of a file name to avoid overwriting existing images. Consider a situation where dcm2niix is run with '-f %t'. This will name images based on the study time. If a single study has multiple series (for example, a T1 sequence and a fMRI scan, the resulting file names will conflict with each other. In order to avoid overwriting images, dcm2niix will resort to adding the post fix 'a', 'b', etc. There are a few solutions to avoiding these situations. You may want to consider using both of these:
- Make sure you specify a naming scheme that can discriminate between your images. For example '-f %t' will not disambiguate different series acquired in the same session. However, '-f %t_%s' will discriminate between series.
- Localizer (scout) images are the first scans acquired for any scanning session, and are used to plan the location for subsequent images. Localizers are not used in subsequent analyses (due to resolution, artefacts, etc). Localizers are often acquired with three orthogonal image planes (sagittal, coronal and axial). The NIfTI format requires that all slices in a volume are co-planar, so these localizers will generate naming conflicts. The solution is to use '-i y' which will ignore (not convert) localizers (it will also ignore derived images and 2D slices). This command helps exclude images that are not required for subsequent analyses.
- Be aware that if you run dcm2niix twice with the same parameters on the same data, you will encounter file naming conflicts.
Expand Down
1 change: 0 additions & 1 deletion GE/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ Anatomical localizers (e.g. scout images) are quick-and-dirty scans used to posi
## Sample Datasets

- [A validation dataset for dcm2niix commits](https://github.com/neurolabusc/dcm_qa_nih).
- [Slice Timing and Phase Encoding examples](https://github.com/jannikadon/cc-dcm2bids-wrapper/tree/main/dicom-qa-examples)
- [Slice timing validation](https://github.com/neurolabusc/dcm_qa_stc) for different varieties of GE EPI sequences.
- [Examples of phase encoding polarity, slice timing and diffusion gradients](https://github.com/neurolabusc/dcm_qa_ge).
- The dcm2niix [wiki](https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage) includes examples of diffusion data, slice timing, and other variations.
Expand Down
2 changes: 1 addition & 1 deletion console/main_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void showHelp(const char *argv[], struct TDCMopts opts) {
//#define kNAME_CONFLICT_OVERWRITE 1 //1 = overwrite existing file with same name
//#define kNAME_CONFLICT_ADD_SUFFIX 2 //default 2 = write with new suffix as a new file
printf(" -w : write behavior for name conflicts (0,1,2, default 2: 0=skip duplicates, 1=overwrite, 2=add suffix)\n");
printf(" -x : crop 3D acquisitions (y/n/i, default n, use 'i'gnore to neither crop nor rotate 3D acquistions)\n");
printf(" -x : crop 3D acquisitions (y/n/i, default n, use 'i'gnore to neither crop nor rotate 3D acquisitions)\n");
char gzCh = 'n';
if (opts.isGz)
gzCh = 'y';
Expand Down
3 changes: 3 additions & 0 deletions console/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ all:

sanitize:
g++ -O1 -g -fsanitize=address -fno-omit-frame-pointer $(LFLAGS) $(UFILES)

noroi:
g++ $(CFLAGS) -I. $(JSFLAGS) $(JFLAGS) $(LFLAGS) $(UFILES) -DmyNoRois
4 changes: 4 additions & 0 deletions console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1745,8 +1745,10 @@ tse3d: T2*/
fprintf(fp, "\t\"DiffGradientCyclingGE\": \"2TR\",\n");
if (d.diffCyclingModeGE == kGE_DIFF_CYCLING_3TR)
fprintf(fp, "\t\"DiffGradientCyclingGE\": \"3TR\",\n");
// codespell:disable
if (d.diffCyclingModeGE == kGE_DIFF_CYCLING_SPOFF)
fprintf(fp, "\t\"DiffGradientCyclingGE\": \"SPOFF\",\n");

Check failure on line 1750 in console/nii_dicom_batch.cpp

View workflow job for this annotation

GitHub Actions / Check for spelling errors

SPOFF ==> SPOOF, SPIFF, SPAFF, SCOFF
// codespell:enable
}
}
#ifdef myReadAsciiCsa
Expand Down Expand Up @@ -8401,6 +8403,7 @@ int saveDcm2NiiCore(int nConvert, struct TDCMsort dcmSort[], struct TDICOMdata d
else
nii_saveNII(pathoutnameADC, hdr0, imgM, opts, dcmList[dcmSort[0].indx]);
}
#ifndef myNoRois
if (isHasOverlay) { //each series can have up to 16 overlays, overlays may not be on all slices
for (int j = 0; j < kMaxOverlay; j++) {
bool isOverlay = false;
Expand Down Expand Up @@ -8452,6 +8455,7 @@ int saveDcm2NiiCore(int nConvert, struct TDCMsort dcmSort[], struct TDICOMdata d
nii_saveNII(pathoutnameROI, hdrr, imgR, opts, dcmList[dcmSort[0].indx]);
}
}
#endif //myNoRois
imgM = removeADC(&hdr0, imgM, numADC);
if (iVaries)
printMessage("Saving as 32-bit float (slope, intercept or bits allocated varies).\n");
Expand Down

0 comments on commit 25ce4d0

Please sign in to comment.