Film dosimetry

Film dosimetry#

For film dosimetry, tif image must contain the irradiated film(s) and an unirradiated one, separated by a minimum distance of 5 mm between them. The color image should have three channels: red, blue and green (RGB).

This is a common example for film calibration.

example scanned films

Film calibration#

Start importing two libraries.

from Dosepy.image import load
from pathlib import Path

Read the tif file for film calibration and create a list with the imparted doses.

path_to_file = "/home/luis/Documentos/calibration_file.tif"
cal_image = load(path_to_file, for_calib = True)

imparted_doses = [0, 0.5, 1, 1.5, 2, 3, 5, 8, 10]

Produce the calibration curve using the red channel, a central roi with size 16 mm width, 8 mm height and a rational fit function: \(y = -c + \frac{b}{x-a}\).

cal = cal_image.get_calibration(
    doses = imparted_doses,
    channel = "R", 
    roi = (16, 8),
    func = "RF"
    )
# Plot the curve
cal.plot()
_images/dec0db244876bf78f7957f3d4c087b3ae9bfcc3b1b4bbdfda79c0e8a0655c234.png
<Axes: xlabel='Normalized pixel value', ylabel='Dose [Gy]'>

Film to dose#

Load another tif file.

Note

Additionaly to the film to be transformed to dose, the scanned image must also have one unirradiated film. It is used as a reference for 0 Gy.

qa_image_path = "/home/luis/Documentos/test_file.tif"
qa_image = load(qa_image_path)
qa_image.plot()
_images/b3d2e4acf3d18ca668b8770b3c9725883787efad6386903f8edb0dc3973e6f18.png
<Axes: >

Apply the calibration curve

dose_img = qa_image.to_dose(cal)

Plot it

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots(ncols=1)

max_dose = np.percentile(dose_img.array, [99.9])[0]
pos = ax.imshow(dose_img.array, cmap='nipy_spectral')
pos.set_clim(-.05, max_dose)

# add a colorbar
fig.colorbar(pos, ax=ax)
plt.plot()
[]
_images/0c10dd45262c0dea150918ce9e3931f36b8a16c888cbe7711c83e3d48d202da8.png

Get mean doses from central rois, 20 mm width and 8 mm hight, in each founded films.

doses_in_central_rois = qa_image.doses_in_central_rois(cal, roi = (20, 8), show=True)
print(doses_in_central_rois)
_images/f5a09f60b394f3cefc8e43f013e7bc2c820ff1358f1159dbcd07c43603b2984e.png
[0.009378   0.51629414 5.01072407]

Save the dose distribution as a tif file (in cGy) useful for further analysis using ImageJ.

dose_img.save_as_tif("dose_in_tif_file")

Save as csv file

# np.savetxt("some_name.txt", dose_img.array, fmt = '%.3f', delimiter = ',')