Skip to content

Commit

Permalink
fix GE phase-encoding polarity extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
leej3 committed Sep 17, 2018
1 parent cb05c3a commit e6bbc91
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions console/nii_dicom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5239,14 +5239,14 @@ double TE = 0.0; //most recent echo time recorded
//char const *hdr = &buffer[lPos + hdr_offset];
char *hdr = (char *)&buffer[lPos + hdr_offset];
int epi_chk_off = 0x003a;
int flag1_off = 0x0030;
int flag2_off = 0x0394;
int pepolar_off = 0x0030;
int kydir_off = 0x0394;
if (version >= 25.002) {
hdr += 0x004c;
flag2_off -= 0x008c;
kydir_off -= 0x008c;
}
//int seqOrInter =dcmInt(2,(unsigned char*)(hdr + flag1_off-638),true);
//int seqOrInter2 =dcmInt(2,(unsigned char*)(hdr + flag2_off-638),true);
//int seqOrInter =dcmInt(2,(unsigned char*)(hdr + pepolar_off-638),true);
//int seqOrInter2 =dcmInt(2,(unsigned char*)(hdr + kydir_off-638),true);
//printf("%d %d<<<\n", seqOrInter,seqOrInter2);
//check if EPI
if (true) {
Expand All @@ -5257,23 +5257,24 @@ double TE = 0.0; //most recent echo time recorded
break;
}
}
//Check for PE polarity
// int flag1 = *(short const *)(hdr + flag1_off) & 0x0004;
//Check for ky direction (view order)
// int flag2 = *(int const *)(hdr + flag2_off);
int phasePolarityFlag = dcmInt(2,(unsigned char*)hdr + flag1_off,true) & 0x0004;
//Check for ky direction (view order)
int sliceOrderFlag = dcmInt(2,(unsigned char*)hdr + flag2_off,true);
if (isVerboseX > 1)
printMessage(" GE phasePolarity/sliceOrder flags %d %d\n", phasePolarityFlag, sliceOrderFlag);
if (phasePolarityFlag == kGE_PHASE_ENCODING_POLARITY_FLIPPED)
d.phaseEncodingGE = kGE_PHASE_ENCODING_POLARITY_FLIPPED;
if (phasePolarityFlag == kGE_PHASE_ENCODING_POLARITY_UNFLIPPED)
d.phaseEncodingGE = kGE_PHASE_ENCODING_POLARITY_UNFLIPPED;
if (sliceOrderFlag == kGE_SLICE_ORDER_TOP_DOWN)
d.sliceOrderGE = kGE_SLICE_ORDER_TOP_DOWN;
if (sliceOrderFlag == kGE_SLICE_ORDER_BOTTOM_UP)
d.sliceOrderGE = kGE_SLICE_ORDER_BOTTOM_UP;
//Check for PE polarity
// int pepolar = *(short const *)(hdr + pepolar_off) & 0x0004;
//Check for ky direction (view order)
// int kydir = *(int const *)(hdr + kydir_off);
int pepolarFlag = dcmInt(2,(unsigned char*)hdr + pepolar_off,true) & 0x0004;
//Check for ky direction (view order)
int kyDirFlag = dcmInt(2,(unsigned char*)hdr + kydir_off,true);


printMessage(" GE phasePolarity flags %d %d\n", pepolarFlag, kyDirFlag);
if ((pepolarFlag && kyDirFlag) || (!pepolarFlag && !kyDirFlag)) {
if (isVerboseX > 1) printMessage(" Bottom up\n");
d.phaseEncodingGE = kGE_PHASE_ENCODING_POLARITY_FLIPPED;
}
else {
if (isVerboseX > 1) printMessage(" Top down\n");
d.phaseEncodingGE = kGE_PHASE_ENCODING_POLARITY_UNFLIPPED;
}
#endif
break;
}
Expand Down

0 comments on commit e6bbc91

Please sign in to comment.