Skip to content

Commit

Permalink
Merge pull request #58 from Julievkm/sig
Browse files Browse the repository at this point in the history
fixed pydicom and depreciated scatter interpolation
  • Loading branch information
pjmark authored Jan 18, 2025
2 parents a86a231 + 526d558 commit 4d9caa3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
12 changes: 6 additions & 6 deletions niftypet/nipet/mmraux.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def fwhm2sig(fwhm):
def lm_pos(datain, Cnt):
'''get the position of table and gantry offset from the DICOM list-mode file'''
if 'lm_dcm' in datain and os.path.isfile(datain['lm_dcm']):
dhdr = dcm.read_file(datain['lm_dcm'])
dhdr = dcm.dcmread(datain['lm_dcm'])
elif 'lm_ima' in datain and os.path.isfile(datain['lm_ima']):
dhdr = dcm.read_file(datain['lm_ima'])
dhdr = dcm.dcmread(datain['lm_ima'])
else:
log.error('DICOM list-mode data not found!')
return None
Expand Down Expand Up @@ -91,9 +91,9 @@ def lm_pos(datain, Cnt):
def hdr_lm(datain, Cnt):
'''Get the headers from DICOM list-mode data file'''
if 'lm_dcm' in datain and os.path.isfile(datain['lm_dcm']):
dhdr = dcm.read_file(datain['lm_dcm'])
dhdr = dcm.dcmread(datain['lm_dcm'])
elif 'lm_ima' in datain and os.path.isfile(datain['lm_ima']):
dhdr = dcm.read_file(datain['lm_ima'])
dhdr = dcm.dcmread(datain['lm_ima'])
else:
log.error('DICOM list-mode data not found!')
return None
Expand Down Expand Up @@ -226,9 +226,9 @@ def hmu_resample0(hmupos, parts, Cnt):

def time_diff_norm_acq(datain):
if 'lm_dcm' in datain and os.path.isfile(datain['lm_dcm']):
dcm_lm = dcm.read_file(datain['lm_dcm'])
dcm_lm = dcm.dcmread(datain['lm_dcm'])
elif 'lm_ima' in datain and os.path.isfile(datain['lm_ima']):
dcm_lm = dcm.read_file(datain['lm_ima'])
dcm_lm = dcm.dcmread(datain['lm_ima'])
else:
log.error('dicom header of list-mode data does not exist.')
return None
Expand Down
2 changes: 1 addition & 1 deletion niftypet/nipet/mmrnorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_components(datain, Cnt):
# possible DICOM locations for the Interfile header
nhdr_locations = [[0x29, 0x1010], [0x29, 0x1110]]
# read the DICOM file
d = dcm.read_file(fnrm_hdr)
d = dcm.dcmread(fnrm_hdr)

# if d[0x0018, 0x1020].value == 'syngo MR B20P' or d[0x0018, 0x1020].value == 'syngo MR E11':
# nhdr = d[0x29,0x1010].value.decode()
Expand Down
10 changes: 7 additions & 3 deletions niftypet/nipet/sct/mmrsct.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import nibabel as nib
import numpy as np
import scipy.ndimage as ndi
from scipy.interpolate import interp2d
from scipy.interpolate import interp2d, RectBivariateSpline

Check failure on line 13 in niftypet/nipet/sct/mmrsct.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] niftypet/nipet/sct/mmrsct.py#L13

I001 isort found an import in the wrong position
Raw output
niftypet/nipet/sct/mmrsct.py:13:1: I001 isort found an import in the wrong position

Check failure on line 13 in niftypet/nipet/sct/mmrsct.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] niftypet/nipet/sct/mmrsct.py#L13

F401 'scipy.interpolate.interp2d' imported but unused
Raw output
niftypet/nipet/sct/mmrsct.py:13:1: F401 'scipy.interpolate.interp2d' imported but unused
from scipy.special import erfc

Check failure on line 14 in niftypet/nipet/sct/mmrsct.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] niftypet/nipet/sct/mmrsct.py#L14

I005 isort found an unexpected missing import
Raw output
niftypet/nipet/sct/mmrsct.py:14:1: I005 isort found an unexpected missing import

from .. import mmr_auxe, mmraux, mmrnorm
Expand Down Expand Up @@ -335,8 +335,12 @@ def intrp_bsct(sct3d, Cnt, sctLUT, ssrlut, dtype=np.float32):
sct2d = sct3d[0, si, jj, ii]

z = np.vstack([sct2d[-1, :], sct2d])
f = interp2d(x, y, z, kind='cubic')
znew = f(xnew, ynew)
# > old scatter interpolation
# f = interp2d(x, y, z, kind='cubic')
# znew = f(xnew, ynew)
f = RectBivariateSpline(x, y, z.T)
ft = lambda xnew, ynew: f(xnew, ynew).T

Check failure on line 342 in niftypet/nipet/sct/mmrsct.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] niftypet/nipet/sct/mmrsct.py#L342

E731 do not assign a lambda expression, use a def
Raw output
niftypet/nipet/sct/mmrsct.py:342:13: E731 do not assign a lambda expression, use a def

Check failure on line 342 in niftypet/nipet/sct/mmrsct.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] niftypet/nipet/sct/mmrsct.py#L342

B023 Function definition does not bind loop variable 'f'.
Raw output
niftypet/nipet/sct/mmrsct.py:342:37: B023 Function definition does not bind loop variable 'f'.
znew = ft(xnew, ynew)

# unroll
znew = znew[jjnew, iinew]
Expand Down

0 comments on commit 4d9caa3

Please sign in to comment.