From 3fa7e34537d897adacfe4881641952aec66a9991 Mon Sep 17 00:00:00 2001 From: bpinsard Date: Thu, 25 Oct 2012 22:04:40 +0200 Subject: [PATCH 1/3] fix decimal rescale values causing Decimal data frame --- nibabel/nicom/dicomwrappers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nibabel/nicom/dicomwrappers.py b/nibabel/nicom/dicomwrappers.py index c9aef8b75a..adacfc72c1 100644 --- a/nibabel/nicom/dicomwrappers.py +++ b/nibabel/nicom/dicomwrappers.py @@ -353,8 +353,8 @@ def is_same_series(self, other): return True def _scale_data(self, data): - scale = self.get('RescaleSlope', 1) - offset = self.get('RescaleIntercept', 0) + scale = float(self.get('RescaleSlope', 1)) + offset = float(self.get('RescaleIntercept', 0)) # a little optimization. If we are applying either the scale or # the offset, we need to allow upcasting to float. if scale != 1: From 6033206f99711797721138975a46dc8583617f0e Mon Sep 17 00:00:00 2001 From: bpinsard Date: Mon, 3 Dec 2012 09:35:56 +0100 Subject: [PATCH 2/3] adding comment about float casting --- nibabel/nicom/dicomwrappers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nibabel/nicom/dicomwrappers.py b/nibabel/nicom/dicomwrappers.py index adacfc72c1..03c5d8679d 100644 --- a/nibabel/nicom/dicomwrappers.py +++ b/nibabel/nicom/dicomwrappers.py @@ -353,6 +353,7 @@ def is_same_series(self, other): return True def _scale_data(self, data): + # depending on pydicom and dicom files, values might need casting from Decimal to float scale = float(self.get('RescaleSlope', 1)) offset = float(self.get('RescaleIntercept', 0)) # a little optimization. If we are applying either the scale or From 8e4477edc7894b89a1807d166521b8f15b2cc2e0 Mon Sep 17 00:00:00 2001 From: Brendan Moloney Date: Thu, 28 Feb 2013 22:50:52 -0800 Subject: [PATCH 3/3] TST: Added test for decimal rescale issue. --- nibabel/nicom/tests/data/decimal_rescale.dcm | Bin 0 -> 26650 bytes nibabel/nicom/tests/test_dicomwrappers.py | 8 ++++++++ 2 files changed, 8 insertions(+) create mode 100644 nibabel/nicom/tests/data/decimal_rescale.dcm diff --git a/nibabel/nicom/tests/data/decimal_rescale.dcm b/nibabel/nicom/tests/data/decimal_rescale.dcm new file mode 100644 index 0000000000000000000000000000000000000000..148454a3acf09cd3ef9384af800657dab5a278f6 GIT binary patch literal 26650 zcmeH|OK%)S5XZ|CV+O}b#&$5Xh{GfS$$QvQchCERcC)*VNAf;rjfJ$*8i7HU@BBgDEeLYun<4p=5dPivjt5_I$bn0ZPNoxL;T?v^S9t(8;`(@9gOeaSfSTT_^x5j#a!UW zS20u+ionFu^XpV>FH`66(~~0)yLlFEP^)WGD<8Lqt#)D48`LhADK7@IeC#0|n`~G% zXfV#7M*sIuHkM!pE+ORKu_jZ_%>adhPyl)lxxhTuUs;Xcl2QEzP1 zDeVkwD)Mfx+b^)kImV0BIzBnJ>3b?BbN!r#{ke9WVtcNIbM5~j^n29)Xm<3;>FoI6 zo3oSIR}(qgYDslG$)!pWzgh7gI@d8zEBZNnY?_=Mo=gsp^qSRTMD!BRKQHOx@_pw* zH`J@ge;YrCoHBn0)tTq)koXUIhnkmUJgjh9V3cL>aXQ5cWx`Kn8m3VcdM;wLizRw8 zo}z7BdSFJyaM~MU^w7k}hb}!bN_AX%ALN(l^DotB5*{BIdmm~@9qbZ8onI>9f_tY} zB;{-C4@Sp961()H@zCpkf?6i20$)WUij_-0Bfdp)+ofO7%~0_A)%XWczZqKszu(K* zKTKq_Jm&v2o=N1=3u6sa1uK=c!g--r=<8?4Uz~WovG-UeF1Wm^-Y$*SitQC@4`xFYjCz5S{4K+Ik!3Z4Y*^=lylfLn70+VYNsz+JFsJ@P$yZO41-z zvB*-FT;r?rr;(1ZwN-dERC-?B8rhDv>u#>mTjgnLbg%5-8m*Sv!&*bp^Jw*w7}VMo zF%RE*j%d1%JyPJLs3B$Si#QEq6`(nSX(LPgOvqG5Dvf0tO&cL<6a*rXK@ck`JxZ`L zBsoj>&SOr(|V<*^-4|aP_CHu4Qg=+_?e3 zC;DHL*QCOl-*ru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