Skip to content

Commit

Permalink
Check slices in volume consistent with locations in acquisition (GE: …
Browse files Browse the repository at this point in the history
…0021,104F; public: 0054,0081).
  • Loading branch information
neurolabusc committed Oct 26, 2020
1 parent b7b7606 commit 07b47ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion console/nii_dicom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4266,7 +4266,8 @@ const uint32_t kEffectiveTE = 0x0018+ (0x9082 << 16);
#define kOrientationACR 0x0020+(0x0035 << 16 )
//#define kTemporalPositionIdentifier 0x0020+(0x0100 << 16 ) //IS
#define kOrientation 0x0020+(0x0037 << 16 )
#define kTemporalPosition 0x0020+(0x0100 << 16 ) //IS
//#define kTemporalPosition 0x0020+(0x0100 << 16 ) //IS
//#define kNumberOfTemporalPositions 0x0020+(0x0105 << 16 ) //IS public tag for NumberOfDynamicScans
#define kTemporalResolution 0x0020+(0x0110 << 16 ) //DS
#define kImagesInAcquisition 0x0020+(0x1002 << 16 ) //IS
//#define kSliceLocation 0x0020+(0x1041 << 16 ) //DS would be useful if not optional type 3
Expand Down
23 changes: 13 additions & 10 deletions console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,8 +936,6 @@ void json_Str(FILE *fp, const char *sLabel, char *sVal) { // issue131,425
}
sValEsc[o] = '\0';
fprintf(fp, sLabel, sValEsc );


} //json_Str

void json_FloatNotNan(FILE *fp, const char *sLabel, float sVal) {
Expand Down Expand Up @@ -4593,13 +4591,17 @@ void sliceTimeGE (struct TDICOMdata * d, int mb, int dim3, float TR, bool isInte
sliceTiming[i] = sliceTiming[i % nExcitations];
#define testSliceTimesGE
#ifdef testSliceTimesGE
printf("testSliceTimesGE reported vs estimated slice times:\n");
float maxErr = 0.0;
for (int i = 0; i < dim3; i++) {
printf("%d %g %g\n", i, sliceTiming[i], d->CSA.sliceTiming[i]);
maxErr = max(maxErr, fabs(sliceTiming[i] - d->CSA.sliceTiming[i]));
}
printf("max error: %g\n", maxErr);
for (int i = 0; i < dim3; i++)
maxErr = max(maxErr, fabs(sliceTiming[i] - d->CSA.sliceTiming[i]));
if ((d->CSA.sliceTiming[0] >= 0.0) && (!isSameFloatGE(maxErr, 0.0)) ) {
printMessage("GE estimated slice times differ from reported (max error: %g)\n", maxErr);
printMessage("Slice\tEstimated\tReported\n");
for (int i = 0; i < dim3; i++) {
printMessage("%d %g %g\n", i, sliceTiming[i], d->CSA.sliceTiming[i]);
maxErr = max(maxErr, fabs(sliceTiming[i] - d->CSA.sliceTiming[i]));
}
}
#endif
for (int i = 0; i < dim3; i++)
d->CSA.sliceTiming[i] = sliceTiming[i];
Expand Down Expand Up @@ -4658,7 +4660,7 @@ void rescueSliceTimingGE(struct TDICOMdata * d, int verbose, int nSL, const char
return;
}
mbAccel = max(mbAccel, 1);
if (nSlices != nSL)
if (nSlices != nSL) //redundant with locationsInAcquisition check?
printWarning("Missing DICOMs, number of slices estimated (%d) differs from Protocol Block (0025,101B) report (%d).\n", nSL, nSlices);
d->CSA.multiBandFactor = max(d->CSA.multiBandFactor, mbAccel);
bool isInterleaved = (sliceOrderGE != 0);
Expand Down Expand Up @@ -5080,6 +5082,8 @@ int saveDcm2NiiCore(int nConvert, struct TDCMsort dcmSort[],struct TDICOMdata dc
hdr0.dim[3] = nConvert/nAcq;
hdr0.dim[4] = nAcq;
hdr0.dim[0] = 4;
if ((dcmList[indx0].locationsInAcquisition > 0) && (dcmList[indx0].locationsInAcquisition != hdr0.dim[3]))
printMessage("DICOM images may be missing, expected %d spatial locations per volume, but found %d.\n", dcmList[indx0].locationsInAcquisition, hdr0.dim[3]);
} else if ((dcmList[indx0].isXA10A) && (nConvert > nAcq) && (nAcq > 1) ) {
nAcq -= 1;
hdr0.dim[3] = nConvert/nAcq;
Expand Down Expand Up @@ -5322,7 +5326,6 @@ int saveDcm2NiiCore(int nConvert, struct TDCMsort dcmSort[],struct TDICOMdata dc
if (dcmList[dcmSort[i].indx].CSA.numDti > 0)
dcmList[indx0].CSA.numDti =1;
}

/*if (nConvert > 1) { //next determine if TR is true time between volumes
double startTime = dcmList[indx0].acquisitionTime;
double endTime = startTime;
Expand Down

0 comments on commit 07b47ca

Please sign in to comment.