How to use pymedphys.gamma

Hello everyone,
I’m very happy because I have explored the “pymedphys” library and these forums.

  • I have a problem when using the pymedphys.gamma() function to calculate the gamma index between two datasets. The below image is data structure including 3 columns (x, y, z, relative dose(%)).

  • I have written a bit of code, but it doesn’t work.

import numpy as np
import MyGammaIndex
import matplotlib.pyplot as plt
import pymedphys

ref_data = np.loadtxt(r"test/Ref_results.txt")
cal_data = np.loadtxt(r"test/Cal_results.txt")
gamma_primo = np.loadtxt(r"test/Gamma_Ana.txt")

ref_matrix = np.array(ref_data[:,3]).flatten()
cal_matrix = np.array(cal_data[:,3]).flatten()
x = ref_data[:,0]
y = ref_data[:,1]
z = ref_data[:,2]
coords = (x,y,z)


gamma_cal = pymedphys.gamma(coords, ref_matrix, coords, cal_matrix, 1, 1)
plt.plot(gamma_cal)
plt.plot(gamma_primo[:,3])
  • I also change some line as following picture

gamma_cal = pymedphys.gamma(z, ref_matrix, z, cal_matrix, 1, 1)

It’s still not working. I show

ModuleNotFoundError: 
                    PyMedPhys was unable to import "scipy.interpolate.RegularGridInterpolator".
                    The easiest way to fix this issue is to use the "[user]"
                    option when installing PyMedPhys. For example,
                    with pip this can be done by calling
                    "pip install pymedphys[user]==0.38.0".

Please help me to solve it. Thank you in advance.

Try
pip list

You may need to update your installation of pymedphys…
Just installing with
pip install pymedphys
will not install a number of dependencies

pip install pymedphys[user]

Will install most of the dependencies.

If you still don’t see scipy in your list of packages then you may need to use pip to install scipy directly although you should be careful about the specific version you install (the current version in the lock file is 1.9.3, which is also the most current version).