Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable XA partial vol detection for single slice files (#742) #814

Merged
merged 6 commits into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions console/nii_dicom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,10 @@ int readCSAImageHeader(unsigned char *buff, int lLength, struct TCSAdata *CSA, i
return EXIT_FAILURE;
int lPos = 8; //skip 8 bytes of data, 'SV10' plus 2 32-bit values unused1 and unused2
int lnTag = buff[lPos] + (buff[lPos + 1] << 8) + (buff[lPos + 2] << 16) + (buff[lPos + 3] << 24);
if ((lnTag > 128) || (lnTag < 1)){
printError("%d n_tags CSA Image Header corrupted (0029,1010) see issue 633.\n", lnTag);
return EXIT_FAILURE;
}
if (buff[lPos + 4] != 77)
return EXIT_FAILURE;
lPos += 8; //skip 8 bytes of data, 32-bit lnTag plus 77 00 00 0
Expand All @@ -1459,10 +1463,6 @@ int readCSAImageHeader(unsigned char *buff, int lLength, struct TCSAdata *CSA, i
// Storage order is always little-endian, so byte-swap required values if necessary
if (!littleEndianPlatform())
nifti_swap_4bytes(1, &tagCSA.nitems);
if (tagCSA.nitems > 128) {
printError("%d n_tags CSA Image Header corrupted (0029,1010) see issue 633.\n", tagCSA.nitems);
return EXIT_FAILURE;
}
if (isVerbose > 1) //extreme verbosity: show every CSA tag
printMessage(" %d CSA of %s %d\n", lPos, tagCSA.name, tagCSA.nitems);
if (tagCSA.nitems > 0) {
Expand Down Expand Up @@ -8041,7 +8041,19 @@ const uint32_t kEffectiveTE = 0x0018 + uint32_t(0x9082 << 16); //FD
//}
if (numberOfFramesICEdims < 2) //issue751: icedims[20] frames for EPI only
numberOfFramesICEdims = 0;
if ((numberOfFramesICEdims > 0) && (d.xyzDim[3] != numberOfFramesICEdims)) {
// Issue 742: Detect *currently* enhanced Siemens XA volumes with fewer
// than the expected number of slices, and mark them as derived, with
// SeriesNumber + 1000. However, valid XA series are often unenhanced,
// likely post-scanner, and can arrive as files with just 1 slice each
// in d.xyzDim[3] but the total number of z locations for the series in
// their ICEdims, so they appear to be partial volumes until the
// dcmList is completed (nii_dicom_batch.cpp). Thus we use the
// heuristic that d.xyzDim[3] == 1 is probably OK but between 1 and
// numberOfFramesICEdims (exclusively) is an enhanced partial
// volume. It would miss the case of a true enhanced partial volume
// with just 1 slice, but that seems much less likely than unenhanced
// DICOM with unmodified ICEDims tags.
if ((numberOfFramesICEdims > 0) && (d.xyzDim[3] > 1) && (d.xyzDim[3] != numberOfFramesICEdims)) {
printWarning("Series %ld includes partial volume (issue 742): %d slices acquired but ICE dims (0021,118e) specifies %d \n", d.seriesNum, d.xyzDim[3], numberOfFramesICEdims);
d.seriesNum += 1000;
d.isDerived = true;
Expand Down
Loading