/
direct.py
694 lines (563 loc) · 24.9 KB
/
direct.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
"""
Authors: Ivan E. Cao-Berg and Jennifer Bakal
Created: February 22, 2012
Copyright (C) 2012 Murphy Lab
Lane Center for Computational Biology
School of Computer Science
Carnegie Mellon University
May 4, 2012
* J. Bakal Updated
April 10, 2013
* J. Bakal Included processOMEIDs and def processOMESearchSet methods
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
For additional information visit http://murphylab.web.cmu.edu or
send email to murphy@cmu.edu
"""
import omero
from omero.gateway import BlitzGateway
import pyslid.features
import pyslid.utilities
import copy
import pickle
from os.path import exists, join
import os
NUM_DIGIT_COUNT = 20
OMERO_CONTENTDB_PATH = os.environ['OMERO_CONTENTDB_PATH']
if not OMERO_CONTENTDB_PATH.endswith(os.sep):
OMERO_CONTENTDB_PATH = OMERO_CONTENTDB_PATH + os.sep
def search_file(filename, search_path):
"""Given a search path, find file
"""
file_found = 0
if exists(join(search_path, filename)):
file_found = 1
if file_found:
return join(search_path, filename)
else:
return None
def initializeNameTag(conn, featureset, did=None):
"""
Initialize a tagAnnotation for image-content DB Name and link it to the ExperimenterGroup.
@param conn (Blitzgateway)
@param featureset (featureset name)
@param did (Dataset ID. If did is specified, this function will retrieve the partircular DB that is attached to the dataset. Otherwise it will retrieve the general DB that includes all datasets)
@return NameSpace
@return DBName
"""
COUNT = ''
for i in range(NUM_DIGIT_COUNT-1):
COUNT +="0"
COUNT +="1"
gid = conn.getGroupFromContext().getId()
if did == None:
NameSpace = 'direct.edu.cmu.cs.compbio.omepslid:'+'all'+'_'+str(featureset)
DBName = str(gid)+'_all_'+str(featureset)+'_content_db_'+COUNT+'.pkl'
else:
NameSpace = 'direct.edu.cmu.cs.compbio.omepslid:'+str(did)+'_'+str(featureset)
DBName = str(gid)+'_'+str(did)+'_'+str(featureset)+'_content_db_'+COUNT+'.pkl'
#create an empty tag
tag = conn.getUpdateService().saveAndReturnObject(omero.model.TagAnnotationI())
tag.setNs(omero.rtypes.RStringI(NameSpace))
tag.setTextValue(omero.rtypes.RStringI(DBName))
tag=conn.getUpdateService().saveAndReturnObject(tag) # update the tag
flink = omero.model.ExperimenterGroupAnnotationLinkI()
# link the tag to the ExperimentGroup
flink.link(omero.model.ExperimenterGroupI(gid, False), tag)
conn.getUpdateService().saveObject(flink) # update the link
return NameSpace, DBName
def updateNameTag(conn, tag, DBName_new):
"""
Update the tag by updating DB Name. (Increase the number by 1)
@param conn (Blitzgateway)
@param tag (tagAnnotation object)
@param DBName_new (Old DBName)
@return Answer (True if successfully done)
"""
# change the DBName
tag.setTextValue(omero.rtypes.RStringI(DBName_new))
# update the tag
conn.getUpdateService().saveObject(tag)
return True
def deleteNameTag(conn, featureset, did=None):
"""
Delete all tagAnnotations and links for image-content DB Name.
Note that only the account who created the tag/link can delete them.
@param conn (Blitzgateway)
@param featureset (featureset name)
@param did (Dataset ID. If did is specified, this function will retrieve the partircular DB that is attached to the dataset. Otherwise it will retrieve the general DB that includes all datasets)
@return Answer (True if successfully done)
"""
#get the name of the active group to which the user belongs
groupname = conn.getGroupFromContext().getName()
groupid = conn.getGroupFromContext().getId()
#create query service
query = conn.getQueryService()
if did == None:
NameSpace = 'direct.edu.cmu.cs.compbio.omepslid:'+'all'+'_'+str(featureset)
else:
NameSpace = 'direct.edu.cmu.cs.compbio.omepslid:'+str(did)+'_'+str(featureset)
params = omero.sys.ParametersI()
params.addString("namesp", NameSpace )
params.addLong("gid", groupid )
#for ExperimeterGroupANnotationLink objects
query_string = "select grl from ExperimenterGroupAnnotationLink as grl join grl.child as ann where grl.parent.id = :gid and ann.ns=:namesp"
results_link = query.findAllByQuery(query_string, params)
#for tagAnnotation
query_string = "select ann from ExperimenterGroupAnnotationLink as grl join grl.child as ann where grl.parent.id = :gid and ann.ns=:namesp"
results_tag = query.findAllByQuery(query_string, params)
try:
for result in results_link:
conn.getUpdateService().deleteObject(result)
for result in results_tag:
conn.getUpdateService().deleteObject(result)
return True
except:
return False
def getRecentName(conn, featureset, did=None):
"""
Retreive the most recent public (entire) image-content DB file name for a specific featureset.
This function retrieves the DB file name from a tagAnnotation in the ExperimenterGroup (Collaborative).
@param conn (Blitzgateway)
@param featureset (featureset name)
@param did (Dataset ID. If did is specified, this function will retrieve the partircular DB that is attached to the dataset. Otherwise it will retrieve the general DB that includes all datasets)
@return DBName (DB file name)
@return DBName_next (DB file name for the next round)
@return tag (tagAnnotation)
"""
#get the name of the active group to which the user belongs
groupname = conn.getGroupFromContext().getName()
groupid = conn.getGroupFromContext().getId()
#create query service
query = conn.getQueryService()
if did == None:
NameSpace = 'direct.edu.cmu.cs.compbio.omepslid:'+'all'+'_'+str(featureset)
else:
NameSpace = 'direct.edu.cmu.cs.compbio.omepslid:'+str(did)+'_'+str(featureset)
params = omero.sys.ParametersI()
params.addString("namesp", NameSpace )
params.addLong("gid", groupid )
# get the most recent Tag
query_string = "select ann from ExperimenterGroupAnnotationLink as grl join grl.child as ann where grl.parent.id = :gid and ann.ns=:namesp order by ann.id desc"
result = query.findByQuery(query_string, params.page(0,1))
if result is None:
DBName = None
DBName_next = None
else:
DBName = result.getTextValue().getValue()
# get the next DBName
COUNT_old = DBName.split('.')[0].split('_')[-1]
COUNT_num = long(COUNT_old)
COUNT_num += 1
num_digit = len(str(COUNT_num))
num_zeros = NUM_DIGIT_COUNT - num_digit
COUNT_new = ""
for i in range(num_zeros):
COUNT_new +="0"
COUNT_new += str(COUNT_num)
DBName_next=DBName.replace(COUNT_old, COUNT_new)
return DBName, DBName_next, result
def has(conn, featureset, did=None):
"""
Check if the DB object(HDF5 file) exists on OMERO server
@param conn (Blitzgateway)
@param featureset (featureset name)
@param did (Dataset ID. If did is specified, this function will retrieve the partircular DB that is attached to the dataset. Otherwise it will retrieve the general DB that includes all datasets)
@return answer (True if it is successful)
@return result (Query result that points the newest DB)
"""
answer = False
DBfilename, DBfilename_next, tag = getRecentName(conn, featureset, did)
if DBfilename is None:
return False, None
# search the file from PATH_DB_FILES
result = search_file(DBfilename, OMERO_CONTENTDB_PATH)
if result is None:
answer = False
else:
answer = True
return answer, result
def deleteTableLink(conn, featureset, did=None):
"""
Delete all tables and links for image-content DB Name. (Also delete the tagAnnotation that contains the filename of the table)
Note that only the account who created the table/link can delete them.
@param conn (Blitzgateway)
@param featureset (featureset name)
@param did (Dataset ID. If did is specified, this function will retrieve the partircular DB that is attached to the dataset. Otherwise it will retrieve the general DB that includes all datasets)
@return Answer (True if successfully done)
"""
params = omero.sys.ParametersI()
mimetype = 'OMERO.tables'
params.addString( "mimetype", mimetype );
DBfilename, DBfilename_next, tag = getRecentName(conn, featureset, did)
if DBfilename is None:
return False
result = search_file(DBfilename, OMERO_CONTENTDB_PATH)
if result is None:
return False
else:
import os
try:
os.remove(result)
deleteNameTag(conn, featureset, did)
return True
except:
return False
def createColumns(feature_ids):
"""
Create a List variable (Columns) for content DB.
Note that the first 6 columns are fixed as 'INDEX', 'iid', 'pixels', 'channel', 'zslice', 'timepoint'.
Then the next columns are assigned by the input 'feature_ids'
@param feature_ids (Feature name array. The length of this argument should match with the number of features)
@return columns
"""
columns = []
columns.append(omero.grid.LongColumn( 'INDEX', 'Data Index', [] ))
columns.append(omero.grid.StringColumn( 'server', 'Server name', long(256),[]))
columns.append(omero.grid.StringColumn( 'username', 'Owner ID of the data', long(256), []))
columns.append(omero.grid.LongColumn( 'iid', 'Image ID', [] ))
columns.append(omero.grid.LongColumn( 'pixels', 'Pixel Index', [] ))
columns.append(omero.grid.LongColumn( 'channel', 'Channel Index', [] ))
columns.append(omero.grid.LongColumn( 'zslice', 'zSlice Index', [] ))
columns.append(omero.grid.LongColumn( 'timepoint', 'Time Point Index', [] ))
for feat_id in feature_ids:
columns.append(omero.grid.DoubleColumn( str(feat_id), str(feat_id), [] ))
return columns
def initialize(conn, feature_ids, featureset, did=None):
"""
Initialize a DB object(HDF5 file) onto OMERO server (without attaching to anything)
@param conn (Blitzgateway)
@param feature_ids (Feature name array. The length of this argument should match with the number of features)
@param featureset (Featureset name.)
@param did (Dataset ID. If did is specified, this function will initialize the partircular DB of the dataset. Otherwise it will be for all images)
@return answer (True if it is successful)
"""
answer, result = has(conn, featureset, did)
if answer == True:
# delete the old one
deleteTableLink(conn, featureset, did)
try:
#columns = createColumns(feature_ids)
NS, DBfilename = initializeNameTag(conn, featureset, did)
fullpath = OMERO_CONTENTDB_PATH + DBfilename
output = open(fullpath, 'wb')
Data={'info': featureset}
pickle.dump(Data, output)
output.close()
return True
except:
return False
def updatePerDataset(conn, server, username, dataset_id_list, featureset, field=True, did=None):
"""
Update the DB for given dataset list. Firstly retrieve OMERO.tables from each image in the dataset and add the data onto the DB.
@param conn (Blitzgateway)
@param server (server name)
@param username (user name)
@param dataset_id_list (list of dataset ids)
@param featureset (featureset name)
@param field (True if the featureset is for field-level features)
@param did (Dataset ID. If did is specified, this function will retrieve the partircular DB that is attached to the dataset. Otherwise it will retrieve the general DB that includes all datasets)
@return answer (True if it is successfuly saved)
@return Message (Error Message)
"""
# check the existence of the DB with DBfilename
answer, result = has(conn, featureset, did)
if answer is False:
feature_ids = pyslid.features.getIds(featureset)
initialize(conn, feature_ids, featureset, did)
answer, result = has(conn, featureset, did)
if answer is True:
# update image by image
for DID in dataset_id_list:
print 'starting dataset: '+str(DID)
ds = conn.getObject("Dataset", long(DID))
img_gen = ds.getChildLinks()
IID = []
PIXELS = []
CHANNEL = []
ZSLICE = []
TIMEPOINT = []
FEATURE_IDS =''
features_array = []
for im in img_gen:
iid = long(im.getId())
print iid
answer2, result =pyslid.features.hasTable(conn, iid, featureset, field)
if answer2:
scales=pyslid.features.getScales(conn, iid, featureset, field)
scale=scales[0]
# scale=0.645
[ids, feats] = pyslid.features.get(conn, 'vector', iid, scale, featureset, field)
if len(ids) == 0:
print str(iid)+' has wrong table'
else:
IID.append(long(iid))
for feat in feats:
PIXELS.append(long(feat[0]))
CHANNEL.append(long(feat[1]))
ZSLICE.append(long(feat[2]))
TIMEPOINT.append(long(feat[3]))
FEATURE_IDS = list(ids[5:])
features_array.append(list(feat[5:]))
updateDataset(conn, server, username, IID, PIXELS, CHANNEL, ZSLICE, TIMEPOINT, FEATURE_IDS, features_array, featureset, did)
return True
else:
return False
def update(conn, server, username, scale,
iid, pixels, channel, zslice, timepoint,
feature_ids, features, featureset, did=None):
"""
Update the DB for a feature vector.
@param conn (Blitzgateway)
@param server (server name)
@param username (user name)
@param scale (image feature scale parameter)
@param iid (image id)
@param pixels (pixels index)
@param channel (channel index)
@param zslice (zslice index)
@param timepoint (timpoint index)
@param featre_ids (id list for features)
@param features (feature vector)
@param featureset (featureset name)
@param did (Dataset ID. If did is specified, this function will retrieve the partircular DB that is attached to the dataset. Otherwise it will retrieve the general DB that includes all datasets)
@return answer (True if it is successfuly saved)
@return Message (Error Message)
"""
# check the existence of the DB with DBfilename
answer, result = has(conn, featureset, did)
if answer is False:
initialize(conn, feature_ids, featureset, did)
answer, result = has(conn, featureset, did)
if answer == True:
# result is the absolute path of the DB file
pkl_file = open(result, 'rb')
Data = pickle.load(pkl_file)
pkl_file.close()
if scale not in Data:
Data[scale] = []
num_data = len(Data[scale])
# 1. get the DB file name and tag
DBfilename_old, DBfilename_new, tag = getRecentName(conn, featureset, did)
# 2. update the table2 with new input data
IND = num_data + 1
tup = []
tup.append( long(IND) ) #INDEX
tup.append( str(server) )
tup.append( str(username) )
tup.append( str(server)+'/webclient/metadata_details/image/'+str(iid))
tup.append( str(server)+'/webclient/?show=image-' + str(iid))
tup.append( str(server)+'/webclient/img_detail/' + str(iid))
tup.append( long(iid ) )
tup.append( long(pixels) )
tup.append( long(channel) )
tup.append( long(zslice) )
tup.append( long(timepoint) )
for j in range(9, len(feature_ids)+9):
tup.append( float(features[j-9]) )
Data[scale].append(tup)
# 3. save it with the new DB file name
fullpath = OMERO_CONTENTDB_PATH + DBfilename_new
output = open(fullpath, 'wb')
pickle.dump(Data, output)
output.close()
# 4. up date the tag with a new file name
Answer = updateNameTag(conn, tag, DBfilename_new)
# 5. delete the previous one
import os
try:
os.remove(result)
except:
return False, "Couldn't remove the previous contentDB file"
Message = "Good"
return True, Message
else:
Message = "There is no table for the featureset"
return False, Message
def updateDataset(conn, server, username, scale,
iid, pixels, channel, zslice, timepoint,
feature_ids, features, featureset, did=None):
"""
Update the DB for a feature vector array (for a dataset).
@param conn (Blitzgateway)
@param server (server name)
@param username (user name)
@param scale (image feature scale parameter)
@param iid (image id array)
@param pixels (pixels index array)
@param channel (channel index array)
@param zslice (zslice index array)
@param timepoint (timpoint index array)
@param feature_ids (id list for features)
@param features (feature vector array)
@param featureset (featureset name array)
@param did (Dataset ID. If did is specified, this function will retrieve the partircular DB that is attached to the dataset. Otherwise it will retrieve the general DB that includes all datasets)
@return answer (True if it is successfuly saved)
@return Message (Error Message)
"""
# check the existence of the DB with DBfilename
answer, result = has(conn, featureset, did)
if answer is False:
initialize(conn, feature_ids, featureset, did)
answer, result = has(conn, featureset, did)
if answer == True:
# result is the absolute path of the DB file
pkl_file = open(result, 'rb')
Data = pickle.load(pkl_file)
pkl_file.close()
if scale not in Data:
Data[scale] = []
num_data = len(Data[scale])
# 1. get the DB file name and tag
DBfilename_old, DBfilename_new, tag = getRecentName(conn, featureset, did)
# 2. update the table2 with new input data
num_rows = len(iid)
for i in range(num_rows):
IND = num_data + i + 1
tup=[] # tuple (one row)
tup.append( long(IND) ) #INDEX
tup.append( str(server) )
tup.append( str(username) )
tup.append( str(server)+'/webclient/metadata_details/image/'+str(iid[i]))
tup.append( str(server)+'/webclient/?show=image-' + str(iid[i]))
tup.append( str(server)+'/webclient/img_detail/' + str(iid[i]))
tup.append( long(iid[i]) )
tup.append( long(pixels[i]) )
tup.append( long(channel[i]) )
tup.append( long(zslice[i]) )
tup.append( long(timepoint[i]) )
for j in range(9, len(feature_ids)+9):
tup.append( float(features[i][j-9]) )
Data[scale].append(tup)
# 3. save it with the new DB file name
fullpath = OMERO_CONTENTDB_PATH + DBfilename_new
output = open(fullpath, 'wb')
pickle.dump(Data, output)
output.close()
# 4. update the tag with a new file name
Answer = updateNameTag(conn, tag, DBfilename_new)
# 5. delete the previous one
import os
try:
os.remove(result)
except:
return False, "Couldn't remove the previous contentDB file"
Message = "Good"
return True, Message
else:
Message = "There is no table for the featureset"
return False, Message
def chunks(l, n):
'''
Get a chunk of data (Internal function)
'''
return [l[i:i+n] for i in range(0, len(l), n)]
def retrieve(conn, featureset, did=None):
"""
Retrieve a DB object(HDF5 file) from OMERO server
This function is using omero.client object. Thus this function cannot be called from OMERO.web directly.
Also, this function splits the table-reading process for fast reading (from OMERO 4.3.3)
@param conn (Blitzgateway)
@param featureset (featureset name)
@param did (Dataset ID. If did is specified, this function will retrieve the partircular DB that is attached to the dataset. Otherwise it will retrieve the general DB that includes all datasets
@return data (list of data lists) [ [IND,server,username,iid,pixels,channel,zslice,timepoint,...],
[IND,server,username,iid,pixels,channel,zslice,timepoint,...],
[IND,server,username,iid,pixels,channel,zslice,timepoint,...],
...]
@return Message (Error Message)
"""
Data = []
answer, result = has(conn, featureset, did)
if answer == True:
# result is the absolute path of the DB file
pkl_file = open(result, 'rb')
Data = pickle.load(pkl_file)
pkl_file.close()
Message = "Good"
else:
Message = "There is no table for the featureset"
return Data, Message
def retrieveRemote(conn_local, conn_remote, featureset, did=None):
"""
Retrieve a DB object(HDF5 file) from remote OMERO server
Also, this function splits the table-reading process for fast reading (from OMERO 4.3.3)
@param conn (Blitzgateway)
@param featureset (featureset name)
@param did (Dataset ID. If did is specified, this function will retrieve the partircular DB that is attached to the dataset. Otherwise it will retrieve the general DB that includes all datasets
@return data (list of data lists) [ [IND,server,username,iid,pixels,channel,zslice,timepoint,...],
[IND,server,username,iid,pixels,channel,zslice,timepoint,...],
[IND,server,username,iid,pixels,channel,zslice,timepoint,...],
...]
@return Message (Error Message)
"""
data = []
try:
answer, result = has(conn_remote, featureset, did)
if answer == True:
fid = result.getId().getValue()
table = conn.getSharedResources().openTable( omero.model.OriginalFileI( fid, False ) )
num_col = len(table.getHeaders())
num_row = table.getNumberOfRows()
chunk_col = chunks(range(num_col), 100) # read every 100 columns
chunk_row = chunks(range(num_row), 1000) # read every 1000 columns
data = []
for row in range(len(chunk_row)):
temp_col = []
for col in range(len(chunk_col)):
values = table.read(chunk_col[col], chunk_row[row][0], chunk_row[row][-1]+1)
values = values.columns
for cols in values:
column_value_list = cols.values
temp_col.append(list(column_value_list))
temp_col = zip(*temp_col)
for r in temp_col:
data.append(r)
table.close()
Message = "Good"
else:
Message = "There is no table for the featureset"
except:
Message = "Not Done Correctly"
return data, Message
def processOMEIDs(cdb_row):
'''
Process content database id
'''
info=cdb_row[6:11]
ID = ''.join([str(tmp)+'.' for tmp in info])[:-1]
cdbID = [ID,cdb_row[2],cdb_row[1]]
return cdbID
def processOMESearchSet(contentDB,image_refs_dict,dscale):
'''
Create dict with iids as keys and contentDB feature vector as value
to use instead of retrieving features from omero (too slow)
'''
iid_contentDB_dict={}
for key in contentDB[dscale]:
iid_contentDB_dict[key[6]]=key
goodSet_pos = []
for ID in image_refs_dict:
items = ID.split('.')
iid = long(items[0])
pixels = long(items[1])
channel = long(items[2])
zslice = long(items[3])
timepoint = long(items[4])
rid=[]
field=True
if iid_contentDB_dict.has_key(iid):
feats=iid_contentDB_dict[iid][11:]
goodSet_pos.append([ID, 1, feats])
else:
return []
return goodSet_pos