Ejemplo n.º 1
0
    def test_mcnamara_cube(self):
        """ McNamara test on real cubes.
        """
        dose = pt.DosCube()
        dose.read(self.cube001)
        let = pt.LETCube()
        let.read(self.cube001)
        v = pt.VdxCube(dose)
        logger.info("Adding VDX from path " + self.vdx)
        v.read(self.vdx)

        # increasing LET should increase RBE
        abx = 10.0  # alpha/beta ratio for x-rays [Gy]
        rbe1 = rbe_mcnamara(dose.cube, let.cube, abx)
        rbe2 = rbe_mcnamara(dose.cube, let.cube, 2.0)

        self.assertTrue(np.all(rbe2 >= rbe1))  # RBE goes up as abx goes down.
Ejemplo n.º 2
0
    def import_let(self, let_path):
        """
        Import a let cube, add it to the list of loaded dos cubes.
        """

        model = self.model    # local object of plot_model
        pm = self.model.plot  # local object of plot_model

        logger.debug("Open LETCube {:s}".format(let_path))
        let = pt.LETCube()
        let.read(let_path)

        # update model
        model.let.append(let)
        pm.let = let  # display new loaded cube immediately.

        # add cube to the treeview
        self.tree.update_tree()
        self.plot.update_viewcanvas()
Ejemplo n.º 3
0
def load_data_cube(filename):
    """ Loads either a Dos or LET-cube.

    :params str filname: path to Dos or LET-cube.
    :returns: a DosCube or LETCube object and a str containing the path to the basename.
    """

    if not filename:
        logger.warn("Empty data cube filename")
        return None, None

    logger.info("Reading " + filename)

    d = None
    basename_cube = None

    # try to load LET cube
    data_header, _ = pt.LETCube.parse_path(filename)
    if data_header is not None:
        basename_cube = os.path.splitext(data_header)[0]
        d = pt.LETCube()

    # try to load DOS cube
    data_header, _ = pt.DosCube.parse_path(filename)
    if d is None and data_header is not None:
        basename_cube = os.path.splitext(data_header)[0]
        d = pt.DosCube()

    if d is not None:
        d.read(filename)
        logger.info("Data cube shape" + str(d.cube.shape))
        if isinstance(d, pt.DosCube):
            d *= 0.1  # convert %% to %

        dmax = d.cube.max()
        dmin = d.cube.min()
        logger.info("Data min, max values: {:g} {:g}".format(dmin, dmax))

    if d is None:
        logger.warn("Filename " + filename +
                    " is neither valid DOS neither LET cube")

    return d, basename_cube
Ejemplo n.º 4
0
#
#    You should have received a copy of the GNU General Public License
#    along with PyTRiP98.  If not, see <http://www.gnu.org/licenses/>.
#
"""
Simple example of how to do arithmetic on Cube objects in PyTRiP.
"""
import pytrip as pt

# sum two dose cubes, write result:
print("Two half boxes: out.dos")
d1 = pt.DosCube()
d2 = pt.DosCube()
d1.read("box052000.dos")
d2.read("box053000.dos")
d = (d1 + d2)
d.write("out.dos")

# print minium and maximum value found in cubes
print(d1.cube.min(), d1.cube.max())
print(d2.cube.min(), d2.cube.max())

# calculate new dose average LET cube
l1 = pt.LETCube()
l2 = pt.LETCube()
l1.read("box052000.dosemlet.dos")
l2.read("box053000.dosemlet.dos")

let = ((d1 * l1) + (d2 * l2)) / (d1 + d2)
let.write("out.dosemlet.dos")
Ejemplo n.º 5
0
 def import_let_from_file(self, path):
     logger.debug("Open LetCube {:s}".format(path))
     cube = pt.LETCube()
     cube.read(path)
     self.set_let(cube)