| 12
 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
 
 | # -*- coding: utf-8 -*-
"""
Created on Mon Sep 26 13:23:54 2011
 
@author: claire
"""
 
import ConfigParser as CfgP
import os,sys,ast
#   
class ClassifConf():
    def __init__(self):
        self.config=CfgP.RawConfigParser()
        self.config.read('configuration.cfg')
        print self.config
        self.wdir=self.config.get('Images Path','work_dir')
        self.user=self.config.get('Images Path','user')
        self.slide=self.config.get('Images Path','slide')
        self.set_metaphaseList()
        self.path=None
        #False if no particles images saved
        self.particles=False
        self.trained=False
        #Fluo
        #self.counterstain=None
        self.set_ClassifConf()
        self.set_Fluorochromes() 
    def set_metaphaseList(self):
        '''convert the string containing the metaphases list
        stored in the config file to a list of integers'''
        tmp=self.config.get('Images Path','field_list')
        #self.metaphases_list=map(lambda x:int(x),tmp.split(','))
        self.metaphases_list=tmp.split(',')
    def set_particlespath(self,index):
        '''Set the path to the particles directory, in the DAPI directory'''
        #user,"Applications","ImagesTest","jp","Jpp48","13","DAPI","particules"
        print "index=None?",index
        print "self.metaphases_list",self.metaphases_list
        print "self.metaphases_list[0]",self.metaphases_list[index]
        #self.path=os.path.join(self.wdir,self.user,self.slide,self.metaphases_list[index],self.counterstain,"particles")
        #print "self.path",self.path
        return self.path
    def set_particles(self,path):
        '''set to true if chromosomes were segmented '''
        if os.path.isdir(path):
            self.particles=True
    def set_trained(self):
        '''set to true if chromosomes images were classified
        manually to single chr, overlapping chr, nuclei, dusts'''
        self.trained=False
    def set_ClassifConf(self):
        '''read conf param for the classif GUI:
            screen size, number of classif box their size'''
        #seen at stackoverflow.com: T2 = [map(int, x) for x in T1]
        #to convert a string to a list of tuples
        #map(lambda x: int(x), ['1', '2', '3'])
        tmpsize=self.config.get('ClassifierGUI','screen_size').split(',')
        #print tmpsize
        self.screensize=map(lambda x:int(x),tmpsize)
        self.catsize=int(self.config.get('ClassifierGUI','categories_number'))
        self.catlist=self.config.get('ClassifierGUI','categories_list') 
        tmpbox=self.config.get('ClassifierGUI','box_size').split(',')
        #print 'tmpbox',tmpbox
        self.boxsize=map(lambda x:int(x),tmpbox)
        tmpboxpos=ast.literal_eval(self.config.get('ClassifierGUI','box_position'))
        #print tmpboxpos
        self.boxpos=list(tmpboxpos)
 
    def set_Fluorochromes(self):
        '''#Fluorochromes'''
        self.counterstain=self.config.get('Fluorochromes','Counter_stain') 
        print "cs:",self.counterstain        
        self.probes=self.config.get('Fluorochromes','Probes').split(',')
def main():
    configurator=ClassifConf()
    print type(configurator.catlist)
    print configurator.screensize[0]+1
    print configurator.boxpos
    print configurator.boxpos[0][0]+1
    print '##########'
    print configurator.counterstain
    print configurator.probes[1]
    print "meta:",configurator.metaphases_list[0]
    path=configurator.set_particlespath(0)
    print "path:",path
    configurator.set_particlespath(path)
if __name__ == '__main__': main() |