from SlideRunner.dataAccess.database import Database delete_slides = [ "13,8,4,7,17,22,28,26,23,24,36,29,15,14,19,32,25,12", # 3 WSI "13,8,4,7,17,22,28,26,23,24,36,29,15,14,19", #6 WSI "13,8,4,7,17,22,28,26,23" ] #12 WSI import os DB = Database() WSI_lists = ['3', '6', '12'] for i, k in enumerate(WSI_lists): os.system( 'cp databases/MITOS_WSI_CMCT_ODAEL.sqlite databases/MITOS_WSI_CMCT_ODAEL_%sWSI.sqlite' % k) DB.open('databases/MITOS_WSI_CMCT_ODAEL_%sWSI.sqlite' % k) cnt = DB.execute( 'DELETE FROM Annotations_label where annoid in (SELECT uid from Annotations where slide in (%s))' % delete_slides[i]) cnt = DB.execute( 'DELETE FROM Annotations_coordinates where slide in (%s)' % delete_slides[i]) cnt = DB.execute('DELETE FROM Annotations where slide in (%s)' % delete_slides[i]) cnt = DB.execute('DELETE FROM Slides where uid in (%s)' % delete_slides[i]) DB.commit()
print('Center is: ', center, pos, size, W_hpf, H_hpf) img = slide.read_region(location=pos, level=0, size=(W_hpf, H_hpf)) x2 = pos[0] + W_hpf y2 = pos[1] + H_hpf x1 = pos[0] y1 = pos[1] print('Img:', np.array(img).shape) newfilename = filename[:-4] + '.tiff' img.save('%dHPF/%s' % (hpf, newfilename)) DBnew.execute('UPDATE Slides set filename="%s" where uid==%d' % (newfilename, uid)) DBnew.loadIntoMemory(uid) annolist = list(DBnew.annotations.keys()) for annoId in annolist: anno = DBnew.annotations[annoId] if (anno.x1 < x1) or (anno.x1 > x2) or (anno.y1 < y1) or (anno.y1 > y2): DBnew.removeAnnotation(anno.uid) else: DBnew.execute( 'UPDATE Annotations_coordinates SET coordinateX=%d, coordinateY=%d where annoId==%d' % (anno.x1 - x1, anno.y1 - y1, anno.uid)) DBnew.commit()