forked from CellProfiler/CellProfiler-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dan Ruderman
committed
Jun 9, 2017
1 parent
0cf9235
commit ba4b467
Showing
5 changed files
with
765 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" Settings.py - GUIs for module settings | ||
""" | ||
|
||
import cellprofiler.setting | ||
|
||
class MeasurementMultiChoiceForCategory(cellprofiler.setting.MeasurementMultiChoice): | ||
'''A multi-choice setting for selecting multiple measurements within a given category''' | ||
|
||
def __init__(self, text, category_chooser, value='', *args, **kwargs): | ||
'''Initialize the measurement multi-choice | ||
At initialization, the choices are empty because the measurements | ||
can't be fetched here. It's done (bit of a hack) in test_valid. | ||
''' | ||
super(cellprofiler.setting.MeasurementMultiChoice, self).__init__(text, [], value, *args, **kwargs) | ||
self.category_chooser = category_chooser | ||
|
||
def populate_choices(self, pipeline): | ||
# | ||
# Find our module | ||
# | ||
for module in pipeline.modules(): | ||
for setting in module.visible_settings(): | ||
if id(setting) == id(self): | ||
break | ||
columns = pipeline.get_measurement_columns(module) | ||
|
||
def valid_mc(c): | ||
'''Disallow any measurement column with "," or "|" in its names. Must be from specified category.''' | ||
return not any([any([bad in f for f in c[:2]]) for bad in ",", "|"]) and c[0] == self.category_chooser.get_value() | ||
|
||
self.set_choices([self.make_measurement_choice(c[0], c[1]) | ||
for c in columns if valid_mc(c)]) |
Oops, something went wrong.