Unable to analyze radiochromic film scan in Pylinac

71 views
Skip to first unread message

Megha Rai

unread,
Jul 20, 2024, 2:06:46 PM7/20/24
to Pylinac
0

I am trying to analyze a radiochromic film scan using Pylinac but I am getting a bunch of errors. I have tried both FieldAnalysis and FieldProfileAnalysis to no avail. I have also attached the scan I am using. Please help.

Input:

from pylinac import FieldProfileAnalysis, Edge

fa = FieldProfileAnalysis(img_path)  # nothing special needed as it's the default

# you may also specify the edge smoothing value. This is a gaussian filter applied to the derivative just for the purposes of finding the min/max derivative.
# This is to ensure the derivative is not caught by some noise. It is usually not necessary to change this.
fa.analyze(
    centering=Centering.BEAM_CENTER,
    x_width=0.02,
    y_width=0.02,
    normalization=Normalization.BEAM_CENTER,
    edge_type=Edge.INFLECTION_DERIVATIVE,
    ground=True,
    metrics=(
        PenumbraLeftMetric(),
        PenumbraRightMetric(),
        SymmetryAreaMetric(),
        FlatnessDifferenceMetric(),
    ),
)



Output:ValueError Traceback (most recent call last)

Cell In[41], line 7 3 fa = FieldProfileAnalysis(img_path) # nothing special needed as it's the default 5 # you may also specify the edge smoothing value. This is a gaussian filter applied to the derivative just for the purposes of finding the min/max derivative. 6 # This is to ensure the derivative is not caught by some noise. It is usually not necessary to change this. ----> 7 fa.analyze( 8 centering=Centering.BEAM_CENTER, 9 x_width=0.02, 10 y_width=0.02, 11 normalization=Normalization.BEAM_CENTER, 12 edge_type=Edge.INFLECTION_DERIVATIVE, 13 ground=True, 14 metrics=( 15 PenumbraLeftMetric(), 16 PenumbraRightMetric(), 17 SymmetryAreaMetric(), 18 FlatnessDifferenceMetric(), 19 ), 20 ) File ~\anaconda3\Lib\site-packages\pylinac\field_profile_analysis.py:154, in FieldProfileAnalysis.analyze(self, centering, position, x_width, y_width, normalization, edge_type, invert, ground, metrics, **kwargs) 145 x_values, y_values = self._get_profile_values(position, x_width, y_width) 147 self.x_profile = PROFILES[self._edge_type]( 148 values=x_values, 149 dpmm=self.image.dpmm, (...) 152 **kwargs, 153 ) --> 154 self.x_profile.compute(metrics=metrics) 155 self.y_profile = PROFILES[self._edge_type]( 156 values=y_values, 157 dpmm=self.image.dpmm, (...) 160 **kwargs, 161 ) 162 # we have to deep copy otherwise the metrics get re-used and the y-metrics override the x-metrics File ~\anaconda3\Lib\site-packages\pylinac\core\profile.py:601, in ProfileBase.compute(self, metrics) 599 metric.inject_profile(self) 600 self.metrics.append(metric) --> 601 values[metric.full_name] = metric.calculate() 602 # TODO: use |= when 3.9 is min version 603 self.metric_values.update(values) File ~\anaconda3\Lib\site-packages\pylinac\metrics\profile.py:272, in PenumbraLeftMetric.calculate(self) 270 left_edge_value = self.profile.y_at_x(left_edge) 271 lower_search_value = left_edge_value * 2 * self.lower / 100 --> 272 lower_index = self.profile.x_at_y(y=lower_search_value, side=self.side) 273 upper_search_value = left_edge_value * 2 * self.upper / 100 274 upper_index = self.profile.x_at_y(y=upper_search_value, side=self.side) File ~\anaconda3\Lib\site-packages\pylinac\core\profile.py:352, in ProfileBase.x_at_y(self, y, side) 350 s = self.x_idx_at_x(self.center_idx) 351 if side == LEFT: --> 352 f = interp1d(x=self.values[:s], y=self.x_values[:s]) 353 elif side == RIGHT: 354 f = interp1d(x=self.values[s:], y=self.x_values[s:]) File ~\anaconda3\Lib\site-packages\scipy\interpolate\_interpolate.py:529, in interp1d.__init__(self, x, y, kind, axis, copy, bounds_error, fill_value, assume_sorted) 527 # Interpolation goes internally along the first axis 528 self.y = y --> 529 self._y = self._reshape_yi(self.y) 530 self.x = x 531 del y, x # clean up namespace to prevent misuse; use attributes File ~\anaconda3\Lib\site-packages\scipy\interpolate\_polyint.py:112, in _Interpolator1D._reshape_yi(self, yi, check) 109 ok_shape = "%r + (N,) + %r" % (self._y_extra_shape[-self._y_axis:], 110 self._y_extra_shape[:-self._y_axis]) 111 raise ValueError("Data must be of shape %s" % ok_shape) --> 112 return yi.reshape((yi.shape[0], -1)) ValueError: cannot reshape array of size 0 into shape (0,newaxis)



field_scan.tif
Reply all
Reply to author
Forward
0 new messages