##turn off afc so that you could do an MDA if you wanted scope.mmc.enableContinuousFocus(False) ## Take your images channels=[Illuminations.BF2] if int(pos_label[3:])< 17: channels=[Illuminations.BF2,Illuminations.dimGREEN,Illuminations.dimRED] elif int(pos_label[3:])>17 and int(pos_label[3:])<25: channels=[Illuminations.BF2,Illuminations.dimRED] elif int(pos_label[3:])>25: channels=[Illuminations.BF2,Illuminations.dimGREEN] images,metadata=scope.complicated_multichannel_zstack(channels, z_width=3, z_increments=1, channels_for_z=channels[:1]) file_name="Timelapse_%s_t%s" % (pos_label,i) FileOut.mda_save2(out_dir=save_dir,prefix=file_name, mda=images,md=metadata,channels=channels) #for channel in channels: # scope.set_illumination(channel) # scope.mmc.snapImage() # img=scope.mmc.getImage() # md=scope.getFullSystemState() # # save your images # file_name="Timelapse_%s_%s_t%s" % (pos_label,channel.name,i) # save_loc=os.path.join(save_dir,file_name) # FileOut.tif_writer(numpy_array=img,path=save_loc,md_string=md) # if pos_label=="Pos4": # break ## this position will only take the first channel # record location info loc_data="%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s\n" % (pos_label, i, x,
def plateScan(scope, positions, scan_illumination, mda_channels, prefix="", blacklist=[], well_limit=15, well_count_dict={}, data_dir="", visible=True, stack_height=5, slice_height=.5, minAreaCOI=100, maxAreaCOI=1000, thresholdCOI=1000): """ Write the doc string!! """ if prefix=="": prefix=time.asctime().replace(" ","_").replace(":","_") if data_dir is not "": if os.path.isdir(data_dir) is False: os.mkdir(data_dir) data_dir=os.path.join(data_dir,"Scan_%s" % prefix) if os.path.isdir(data_dir) is False: os.mkdir(data_dir) order=-1 ## set up the rows=string.ascii_uppercase[1:7] columns=range(2,12) sites=range(0,225) well_count_dict={} for row in rows: ## flip the order that the columns are gone through order=order*-1 for column in columns[::order]: well="%s%s" % (row,column) if well not in well_count_dict: well_count_dict[well]=0 if well not in blacklist: for site in sites: try: #if scope.mmc.isContinuousFocusLocked() is False: # ## try waiting a few seconds # time.sleep(10) # if scope.mmc.isContinuousFocusLocked() is False: # ## tried waiting, that didnt work, lets exit # print "Lost focus on %s site %s" % (well, site) # return well_count_dict x,y=positions["%s%s-Site_%s" % (row,column,site)].get_xy() scope.mmc.setXYPosition("XYStage",x,y) print ">Looking at %s%s-Site_%s" % (row,column,site) site_name="%s%s-Site_%s" % (row,column,site) site_imaged,mda,md = plateScanSite(scope, scan_illumination, mda_channels, x, y, name=site_name, visible=visible, stack_height=stack_height, slice_height=slice_height, minAreaCOI=minAreaCOI, maxAreaCOI=maxAreaCOI, thresholdCOI=thresholdCOI) well_count_dict[well]+=site_imaged if mda: FileOut.mda_save2(out_dir=data_dir, prefix="%s%s-Site_%s" % (row, column, site), mda=mda, md=md, channels=mda_channels) del mda del md del site_imaged if well_count_dict[well] >= well_limit: count = well_count_dict[well] print "I have found %s cells/stacks in %s" %(count, well) break if scope.mmc.isContinuousFocusLocked() is False: ## try waiting a few seconds time.sleep(10) if scope.mmc.isContinuousFocusLocked() is False: ## tried waiting, that didnt work, lets exit msg="Lost focus on %s site %s" % (well, site) print msg return str(well_count_dict)+"\n\n"+msg except: tb=StringIO.StringIO() exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback, file=tb) message=str(well_count_dict)+"\n\n"+tb.getvalue() return message return well_count_dict