Skip to content

Commit

Permalink
If integer scaling is used, append " isN" to NIfTI header (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Jun 15, 2018
1 parent 67907af commit e77bbbd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Support for Philips Private RLE (1.3.46.670589.33.1.4.1) transfer syntax.
- Optional support for JPEG-LS (1.2.840.10008.1.2.4.80/1.2.840.10008.1.2.4.81) transfer syntaxes (using [CharLS](https://github.com/team-charls/charls)). Requires c++14.
- [Improved GE support](https://github.com/rordenlab/dcm2niix/issues/163)
- Optional [lossless integer scaling](https://github.com/rordenlab/dcm2niix/issues/198) for INT16 and UINT16 DICOM images that only use a fraction of the possible range.

15-Dec-2017
- Support [Siemens XA10 images](https://github.com/rordenlab/dcm2niix/pull/145).
Expand Down
13 changes: 11 additions & 2 deletions console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2165,6 +2165,13 @@ void nii_scale16bitSigned(unsigned char *img, struct nifti_1_header *hdr){
printMessage("Maximizing 16-bit range: raw %d..%d\n", min16, max16);
}*/

void nii_storeIntegerScaleFactor(int scale, struct nifti_1_header *hdr) {
//appends NIfTI header description field with " isN" where N is integer scaling
char newstr[256];
sprintf(newstr, " is%d", scale);
if ((strlen(newstr)+strlen(hdr->descrip)) < 80)
strcat (hdr->descrip,newstr);
}
void nii_scale16bitSigned(unsigned char *img, struct nifti_1_header *hdr) {
//lossless scaling of INT16 data: e.g. input with range -100...3200 and scl_slope=1
// will be stored as -1000...32000 with scl_slope 0.1
Expand All @@ -2191,7 +2198,8 @@ void nii_scale16bitSigned(unsigned char *img, struct nifti_1_header *hdr) {
hdr->scl_slope = hdr->scl_slope/ scale;
for (int i=0; i < nVox; i++)
img16[i] = img16[i] * scale;
printMessage("Maximizing 16-bit range: raw %d..%d\n", min16, max16);
printMessage("Maximizing 16-bit range: raw %d..%d is%d\n", min16, max16, scale);
nii_storeIntegerScaleFactor(scale, hdr);
}


Expand All @@ -2215,7 +2223,8 @@ void nii_scale16bitUnsigned(unsigned char *img, struct nifti_1_header *hdr){
hdr->scl_slope = hdr->scl_slope/ scale;
for (int i=0; i < nVox; i++)
img16[i] = img16[i] * scale;
printMessage("Maximizing 16-bit range: raw max %d\n", max16);
printMessage("Maximizing 16-bit range: raw max %d is%d\n", max16, scale);
nii_storeIntegerScaleFactor(scale, hdr);
}

void nii_check16bitUnsigned(unsigned char *img, struct nifti_1_header *hdr){
Expand Down

0 comments on commit e77bbbd

Please sign in to comment.