Skip to content

Commit 87ba2fb

Browse files
author
Mark Bray
committed
"image_classification" -> "classification_type"
1 parent 8b53a53 commit 87ba2fb

5 files changed

Lines changed: 32 additions & 19 deletions

File tree

Properties_README.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,27 @@ classifier_ignore_columns = <your_object_x_location_column>, <your_object_y_lo
258258

259259
image_tile_size = 50
260260

261+
# OPTIONAL
262+
# Provides the image width and height. Used for per-image classification.
263+
# If not set, it will be obtained from the Image_Width and Image_Height
264+
# measurements in CellProfiler.
265+
266+
image_width =
267+
image_height =
268+
261269
# OPTIONAL
262270
# Image Gallery can use a different tile size (in pixels) to create thumbnails for images
263271
# If not set, it will be the same as image_tile_size
264272

265273
image_size =
266274

267-
# ======== Image Classification =======
268-
# CPA 2.2.0 allows image classification instead of object classification
269-
# If set to yes, then Classifier will fetch whole images instead of objects
275+
# ======== Classification type =======
276+
# OPTIONAL
277+
# CPA 2.2.0 allows image classification instead of object classification.
278+
# If left blank or set to "object", then Classifier will fetch objects (default).
279+
# If set to "image", then Classifier will fetch whole images instead of objects.
270280

271-
image_classification = no
281+
classification_type =
272282

273283

274284
# ======== Auto Load Training Set ========

cpa/classifier.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def __init__(self, properties=None, parent=None, id=ID_CLASSIFIER, **kwargs):
8484
:] # used to store previous color mappings when toggling colors on/off with ctrl+1,2,3...
8585
self.brightness = 1.0
8686
self.required_fields = []
87-
if not p.image_classification == 'yes':
87+
if not p.classification_type == 'image':
8888
self.scale = 1.0
8989
self.required_fields = ['object_table', 'object_id', 'cell_x_loc', 'cell_y_loc']
9090
else:
@@ -1509,7 +1509,7 @@ def ScoreAll(self, evt=None):
15091509

15101510
# GET GROUPING METHOD AND FILTER FROM USER
15111511
enrichments = True
1512-
if p.image_classification == 'yes':
1512+
if p.classification_type == 'image':
15131513
enrichments = False
15141514

15151515
dlg = ScoreDialog(self, groupChoices, filterChoices, enrichments)

cpa/dbconnect.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def connect(self, empty_sqlite_db=False):
331331
self.connectionInfo[connID] = (p.db_host, p.db_user,
332332
(p.db_passwd or None), p.db_name)
333333
logging.debug('[%s] Connected to database: %s as %s@%s'%(connID, p.db_name, p.db_user, p.db_host))
334-
if p.image_classification == 'yes':
334+
if p.classification_type == 'image':
335335
self.CreateObjectImageTable()
336336
except DBError(), e:
337337
raise DBException, 'Failed to connect to database: %s as %s@%s (connID = "%s").\n %s'%(p.db_name, p.db_user, p.db_host, connID, e)
@@ -445,7 +445,7 @@ def regexp(expr, item):
445445
self.CreateSQLiteDB()
446446
else:
447447
raise DBException, 'Database at %s appears to be empty.'%(p.db_sqlite_file)
448-
if p.image_classification == 'yes':
448+
if p.classification_type == 'image':
449449
self.CreateObjectImageTable()
450450
logging.debug('[%s] Connected to database: %s'%(connID, p.db_sqlite_file))
451451

@@ -1257,7 +1257,7 @@ def CreateSQLiteDB(self):
12571257
self.execute('DROP TABLE IF EXISTS %s'%(p.image_table))
12581258
self.execute(statement)
12591259

1260-
if not p.image_classification == 'yes':
1260+
if not p.classification_type == 'image':
12611261
# CREATE THE OBJECT TABLE
12621262
# For the object table we assume that all values are type FLOAT
12631263
# except for the primary keys
@@ -1292,7 +1292,7 @@ def CreateSQLiteDB(self):
12921292
f.close()
12931293

12941294
# POPULATE THE OBJECT TABLE
1295-
if not p.image_classification == 'yes':
1295+
if not p.classification_type == 'image':
12961296
f = open(p.object_csv_file, 'U')
12971297
r = csv.reader(f)
12981298
row = r.next() # skip the headers
@@ -1391,7 +1391,7 @@ def CreateSQLiteDBFromCSVs(self):
13911391
logging.info("... loaded %d%% of CSV data"%(pct))
13921392

13931393
line_count = 0
1394-
if not p.image_classification == 'yes':
1394+
if not p.classification_type == 'image':
13951395
assert len(obcsvs)>0, ('Failed to parse object csv filenames from %s. '
13961396
'Make sure db_sql_file in your properties file is'
13971397
' set to the .SQL file output by CellProfiler\'s '

cpa/imagegallery.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, properties=None, parent=None, id=ID_IMAGE_GALLERY, **kwargs):
7777

7878
# self.required_fields = []
7979

80-
# if not p.image_classification == 'yes':
80+
# if not p.classification_type == 'image':
8181
# self.scale = 1.0
8282
# self.required_fields = ['object_table', 'object_id', 'cell_x_loc', 'cell_y_loc']
8383
# else:
@@ -98,7 +98,7 @@ def __init__(self, properties=None, parent=None, id=ID_IMAGE_GALLERY, **kwargs):
9898
self.toggleChMap = p.image_channel_colors[
9999
:] # used to store previous color mappings when toggling colors on/off with ctrl+1,2,3...
100100
self.brightness = 1.0
101-
if p.image_classification == 'yes':
101+
if p.classification_type == 'image':
102102
self.scale = 100.0 / float(p.image_tile_size) # guarantee it is parsed as float
103103
else:
104104
self.scale = 1.0
@@ -125,7 +125,8 @@ def __init__(self, properties=None, parent=None, id=ID_IMAGE_GALLERY, **kwargs):
125125

126126
# sorting bins
127127
self.gallery_panel = wx.Panel(self.bins_splitter)
128-
self.gallery_box = wx.StaticBox(self.gallery_panel, label=p.object_name[0] + ' image gallery')
128+
o_label = p.object_name[0] if p.classification_type == 'image' else '' + ' image gallery'
129+
self.gallery_box = wx.StaticBox(self.gallery_panel, label=o_label)
129130
self.gallery_sizer = wx.StaticBoxSizer(self.gallery_box, wx.VERTICAL)
130131
self.galleryBin = sortbin.SortBin(parent=self.gallery_panel,
131132
classifier=self,

cpa/properties.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
'link_tables_table',
5858
'link_columns_table',
5959
'image_rescale',
60-
'image_classification',
60+
'classification_type',
6161
'image_size',
6262
'image_width',
6363
'image_height'
@@ -117,7 +117,7 @@
117117
'plate_shape',
118118
'image_tile_size',
119119
'image_size',
120-
'image_classification',
120+
'classification_type',
121121
'image_width',
122122
'image_height'
123123
]
@@ -294,9 +294,9 @@ def load_file(self, filename):
294294

295295
f.close()
296296

297-
#if image_classification is defined
298-
if self.field_defined('image_classification') and self.image_classification.lower() in ['true', 'yes', 'on', 't', 'y', '1']:
299-
self.image_classification = 'yes'
297+
#if classification_type is defined
298+
if self.field_defined('classification_type') and self.classification_type.lower() in ['image']:
299+
self.classification_type = 'image'
300300
#2 cases:
301301
# object_table/object_id/cell_x_loc/cell_y_loc exist and point to a table/view of object tables
302302
# object_table/object_id/cell_x_loc/cell_y_loc don't exist
@@ -319,6 +319,8 @@ def load_file(self, filename):
319319
self.image_tile_size = min([self.image_width, self.image_height])
320320

321321
self.image_tile_size = int(self.image_tile_size)
322+
else:
323+
self.classification_type = "object"
322324

323325
# For image gallery
324326
if self.field_defined('image_size'):

0 commit comments

Comments
 (0)