File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 33from typing import TYPE_CHECKING , Final , cast
44
55from django .db import models
6+ from django .db .models import Avg
67from django .utils .text import slugify
78
89from proteins .models .fluorescence_data import AbstractFluorescenceData
@@ -230,6 +231,17 @@ def stokes(self) -> float | None:
230231 except TypeError :
231232 return None
232233
234+ @property
235+ def local_brightness (self ) -> float :
236+ """Brightness relative to spectral neighbors. 1 = average."""
237+ if not (self .em_max and self .brightness ):
238+ return 1
239+ avg = FluorState .objects .exclude (id = self .id ).filter (em_max__around = self .em_max ).aggregate (Avg ("brightness" ))
240+ try :
241+ return round (self .brightness / avg ["brightness__avg" ], 4 )
242+ except TypeError :
243+ return 1
244+
233245 def has_spectra (self ) -> bool :
234246 if any ([self .ex_spectrum , self .em_spectrum ]):
235247 return True
You can’t perform that action at this time.
0 commit comments