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\”
C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\numpy\core\ 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\ 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\”, line 17, in
File “C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\pylinac\”, line 705, in analyze
window = self._get_mlc_window(
File “C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\pylinac\”, 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,

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
File “C:\Users\Administrateur\AppData\Local\Programs\Python\Python310\lib\site-packages\pylinac\”, line 706, in analyze
window = self._get_mlc_window(
File “C:\Users\Administrateur\AppData\Local\Programs\Python\Python310\lib\site-packages\pylinac\”, 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”


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

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.


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, \

pf = pylinac.PicketFence('pf.dcm')
pf.analyze(picket_spacing=30, num_pickets=1)

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.

Safir Ben Abdellah Aghzout