Single Picket analysis

Hello everybody,

I have a quick question. I would like to verify the position of my MLCs to comply with French regulations. I’m wondering if it’s possible to use an image with only one pair of leaves (a single picket) for this purpose. I didn’t find any examples in the documentation, and when I attempted it, I encountered the following error:

PS C:\Users\ben-abdellah-aghzout\Code> python -u “c:\Users\ben-abdellah-aghzout\Code\positionnementMLC\positionnementMLC2.py”
C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\numpy\core\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.
return _methods._mean(a, axis=axis, dtype=dtype,
C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\numpy\core_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide
ret = ret.dtype.type(ret / rcount)
Traceback (most recent call last):
File “c:\Users\ben-abdellah-aghzout\Code\positionnementMLC\positionnementMLC2.py”, line 17, in
pf.analyze(separate_leaves=True,nominal_gap_mm=gap)
File “C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\pylinac\picketfence.py”, line 705, in analyze
window = self._get_mlc_window(
File “C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\pylinac\picketfence.py”, line 801, in _get_mlc_window
left_edge = max(int(approx_idx - spacing / 2), 0)
ValueError: cannot convert float NaN to integer

Is it possible to perfom an analysis on a single picket ?

Thanks in advance,
Safir

Hello, I would like to add that I upgraded to pylinac 3.21.1 because I saw the following changelog:

I still get an error:

Traceback (most recent call last):
File “c:\deploy\tempCodeRunnerFile.python”, line 20, in
pf.analyze(tolerance=toleranceChoix)
File “C:\Users\Administrateur\AppData\Local\Programs\Python\Python310\lib\site-packages\pylinac\picketfence.py”, line 706, in analyze
window = self._get_mlc_window(
File “C:\Users\Administrateur\AppData\Local\Programs\Python\Python310\lib\site-packages\pylinac\picketfence.py”, line 802, in _get_mlc_window
left_edge = max(int(approx_idx - spacing / 2), 0)
ValueError: cannot convert float NaN to integer

Hi Safir,

normally pylinac needs more than one picket to analyze the picket fence test, since the distance between the pickets is one of the analyzed parameters. In the analyze method there is a part were pylinac tries to determine the distance between the pickets and use this info to find the position of each “kiss”

grafik

you could try to give the picket_spacing parameter when doing the analyze and see what happens then.

Note:
picket_spacing - If None (default), the spacing between pickets is determined automatically. If given, it should be an int or float specifying the number of PIXELS apart the pickets are.

regards
Thomas

1 Like

As Thomas said, the pixel spacing would need to be set (to some random value). The num_pickets parameters should probably also be set to 1 for safety.

On bleeding edge pylinac I was able to get this working using the image generator:

from pylinac.core.image_generator import AS1200Image,  PerfectFieldLayer, \
    GaussianFilterLayer, \
    generate_picketfence

generate_picketfence(
    simulator=AS1200Image(1000),
    field_layer=PerfectFieldLayer,
    file_out='pf.dcm',
    final_layers=[GaussianFilterLayer(sigma_mm=1),],
    pickets=1,
)
pf = pylinac.PicketFence('pf.dcm')
pf.analyze(picket_spacing=30, num_pickets=1)
pf.plot_analyzed_image(leaf_error_subplot=False)

which gives:

Hello Thomas and James,

It worked ! Thank you very much for your help. Pylinac is a wonderful project and I’m thankful for your implication.

Respectfully,
Safir Ben Abdellah Aghzout